The download UI application is added.
authorJungki Kwak <jungki.kwak@samsung.com>
Tue, 21 Aug 2012 10:56:09 +0000 (19:56 +0900)
committerJungki Kwak <jungki.kwak@samsung.com>
Tue, 21 Aug 2012 10:56:09 +0000 (19:56 +0900)
This application is based on download daemon process.
new file:   CMakeLists.txt
new file:   INSTALL
new file:   LICENSE
new file:   NOTICE
new file:   packaging/org.tizen.download-manager.spec
new file:   po/CMakeLists.txt
new file:   po/POTFILES.in.in
new file:   po/ar.po
new file:   po/bg.po
new file:   po/ca.po
new file:   po/cs.po
new file:   po/da.po
new file:   po/de_DE.po
new file:   po/el_GR.po
new file:   po/en.po
new file:   po/en_US.po
new file:   po/es_ES.po
new file:   po/fi.po
new file:   po/fr_FR.po
new file:   po/he.po
new file:   po/hi.po
new file:   po/hr.po
new file:   po/hu.po
new file:   po/id.po
new file:   po/it_IT.po
new file:   po/ja_JP.po
new file:   po/ko_KR.po
new file:   po/lt.po
new file:   po/lv.po
new file:   po/ms.po
new file:   po/nl_NL.po
new file:   po/no.po
new file:   po/pl.po
new file:   po/pt_PT.po
new file:   po/ro.po
new file:   po/ru_RU.po
new file:   po/sk.po
new file:   po/sl.po
new file:   po/sr.po
new file:   po/sv.po
new file:   po/th.po
new file:   po/tr_TR.po
new file:   po/uk.po
new file:   po/vi.po
new file:   po/zh_CN.po
new file:   po/zh_HK.po
new file:   po/zh_TW.po
new file:   res/images/U06_icon_DRM.png
new file:   res/images/U06_icon_Java.png
new file:   res/images/U06_icon_Unknown.png
new file:   res/images/U06_icon_excel.png
new file:   res/images/U06_icon_html.png
new file:   res/images/U06_icon_image.png
new file:   res/images/U06_icon_music.png
new file:   res/images/U06_icon_pdf.png
new file:   res/images/U06_icon_ppt.png
new file:   res/images/U06_icon_ringtone.png
new file:   res/images/U06_icon_text.png
new file:   res/images/U06_icon_video.png
new file:   res/images/U06_icon_word.png
new file:   res/org.tizen.download-manager.xml
new file:   src/download-manager-dateTime.cpp
new file:   src/download-manager-downloadItem.cpp
new file:   src/download-manager-downloadRequest.cpp
new file:   src/download-manager-event.cpp
new file:   src/download-manager-history-db.cpp
new file:   src/download-manager-item.cpp
new file:   src/download-manager-items.cpp
new file:   src/download-manager-network.cpp
new file:   src/download-manager-util.cpp
new file:   src/download-manager-view.cpp
new file:   src/download-manager-viewItem.cpp
new file:   src/include/download-manager-common.h
new file:   src/include/download-manager-dateTime.h
new file:   src/include/download-manager-debug.h
new file:   src/include/download-manager-downloadItem.h
new file:   src/include/download-manager-downloadRequest.h
new file:   src/include/download-manager-event.h
new file:   src/include/download-manager-history-db.h
new file:   src/include/download-manager-item.h
new file:   src/include/download-manager-items.h
new file:   src/include/download-manager-network.h
new file:   src/include/download-manager-util.h
new file:   src/include/download-manager-view.h
new file:   src/include/download-manager-viewItem.h
new file:   src/main.cpp

86 files changed:
CMakeLists.txt [new file with mode: 0644]
INSTALL [new file with mode: 0644]
LICENSE [new file with mode: 0644]
NOTICE [new file with mode: 0644]
packaging/org.tizen.download-manager.spec [new file with mode: 0644]
po/CMakeLists.txt [new file with mode: 0644]
po/POTFILES.in.in [new file with mode: 0644]
po/ar.po [new file with mode: 0644]
po/bg.po [new file with mode: 0644]
po/ca.po [new file with mode: 0644]
po/cs.po [new file with mode: 0644]
po/da.po [new file with mode: 0644]
po/de_DE.po [new file with mode: 0644]
po/el_GR.po [new file with mode: 0644]
po/en.po [new file with mode: 0644]
po/en_US.po [new file with mode: 0644]
po/es_ES.po [new file with mode: 0644]
po/fi.po [new file with mode: 0644]
po/fr_FR.po [new file with mode: 0644]
po/he.po [new file with mode: 0644]
po/hi.po [new file with mode: 0644]
po/hr.po [new file with mode: 0644]
po/hu.po [new file with mode: 0644]
po/id.po [new file with mode: 0644]
po/it_IT.po [new file with mode: 0644]
po/ja_JP.po [new file with mode: 0644]
po/ko_KR.po [new file with mode: 0644]
po/lt.po [new file with mode: 0644]
po/lv.po [new file with mode: 0644]
po/ms.po [new file with mode: 0644]
po/nl_NL.po [new file with mode: 0644]
po/no.po [new file with mode: 0644]
po/pl.po [new file with mode: 0644]
po/pt_PT.po [new file with mode: 0644]
po/ro.po [new file with mode: 0644]
po/ru_RU.po [new file with mode: 0644]
po/sk.po [new file with mode: 0644]
po/sl.po [new file with mode: 0644]
po/sr.po [new file with mode: 0644]
po/sv.po [new file with mode: 0644]
po/th.po [new file with mode: 0644]
po/tr_TR.po [new file with mode: 0644]
po/uk.po [new file with mode: 0644]
po/vi.po [new file with mode: 0644]
po/zh_CN.po [new file with mode: 0644]
po/zh_HK.po [new file with mode: 0644]
po/zh_TW.po [new file with mode: 0644]
res/images/U06_icon_DRM.png [new file with mode: 0644]
res/images/U06_icon_Java.png [new file with mode: 0644]
res/images/U06_icon_Unknown.png [new file with mode: 0644]
res/images/U06_icon_excel.png [new file with mode: 0644]
res/images/U06_icon_html.png [new file with mode: 0644]
res/images/U06_icon_image.png [new file with mode: 0644]
res/images/U06_icon_music.png [new file with mode: 0644]
res/images/U06_icon_pdf.png [new file with mode: 0644]
res/images/U06_icon_ppt.png [new file with mode: 0644]
res/images/U06_icon_ringtone.png [new file with mode: 0644]
res/images/U06_icon_text.png [new file with mode: 0644]
res/images/U06_icon_video.png [new file with mode: 0644]
res/images/U06_icon_word.png [new file with mode: 0644]
res/org.tizen.download-manager.xml [new file with mode: 0644]
src/download-manager-dateTime.cpp [new file with mode: 0644]
src/download-manager-downloadItem.cpp [new file with mode: 0644]
src/download-manager-downloadRequest.cpp [new file with mode: 0644]
src/download-manager-event.cpp [new file with mode: 0644]
src/download-manager-history-db.cpp [new file with mode: 0644]
src/download-manager-item.cpp [new file with mode: 0644]
src/download-manager-items.cpp [new file with mode: 0644]
src/download-manager-network.cpp [new file with mode: 0644]
src/download-manager-util.cpp [new file with mode: 0644]
src/download-manager-view.cpp [new file with mode: 0644]
src/download-manager-viewItem.cpp [new file with mode: 0644]
src/include/download-manager-common.h [new file with mode: 0644]
src/include/download-manager-dateTime.h [new file with mode: 0644]
src/include/download-manager-debug.h [new file with mode: 0644]
src/include/download-manager-downloadItem.h [new file with mode: 0644]
src/include/download-manager-downloadRequest.h [new file with mode: 0644]
src/include/download-manager-event.h [new file with mode: 0644]
src/include/download-manager-history-db.h [new file with mode: 0644]
src/include/download-manager-item.h [new file with mode: 0644]
src/include/download-manager-items.h [new file with mode: 0644]
src/include/download-manager-network.h [new file with mode: 0644]
src/include/download-manager-util.h [new file with mode: 0644]
src/include/download-manager-view.h [new file with mode: 0644]
src/include/download-manager-viewItem.h [new file with mode: 0644]
src/main.cpp [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3322587
--- /dev/null
@@ -0,0 +1,114 @@
+#
+# Copyright (c) Samsung Electronics Co., Ltd.
+# All rights reserved.
+#
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(download-manager C CXX)
+
+SET(SRCS
+       src/main.cpp
+       src/download-manager-event.cpp
+       src/download-manager-network.cpp
+       src/download-manager-view.cpp
+       src/download-manager-viewItem.cpp
+       src/download-manager-items.cpp
+       src/download-manager-item.cpp
+       src/download-manager-downloadItem.cpp
+       src/download-manager-downloadRequest.cpp
+       src/download-manager-util.cpp
+       src/download-manager-history-db.cpp
+       src/download-manager-dateTime.cpp
+       src/download-manager-network.cpp
+)
+
+SET(VENDOR "tizen")
+SET(PACKAGE ${PROJECT_NAME})
+SET(PKGNAME "org.${VENDOR}.${PACKAGE}")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/bin")
+SET(RESDIR "${PREFIX}/res")
+SET(IMAGEDIR "${RESDIR}/images")
+SET(DATADIR "${PREFIX}/data")
+SET(DBDATADIR "${PREFIX}/data/db")
+SET(LOCALEDIR "${RESDIR}/locale")
+SET(ICONDIR "/opt/share/icons/default/small/")
+SET(HISTORYDB ".download-history.db")
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+       capi-web-url-download
+       capi-system-runtime-info
+       capi-appfw-application
+       capi-network-connection
+       capi-content-media-content
+       elementary
+       aul
+       bundle
+       ecore
+       edje
+       icu-i18n
+       xdgmime
+ )
+
+FIND_LIBRARY(LIB_DL dl)
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+FOREACH(flag ${pkgs_include_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+MESSAGE("ARCH: ${ARCH}")
+MESSAGE("LIB_DL: ${LIB_DL}")
+
+SET(CMAKE_C_FLAGS "${INC_FLAGS}${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+SET(CMAKE_CXX_FLAGS "${INC_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -Wall")
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -Wall")
+SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
+
+IF("${ARCH}" MATCHES "^arm.*")
+       ADD_DEFINITIONS("-DTARGET")
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie")
+    SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mabi=aapcs-linux -mfpu=vfp -mfloat-abi=softfp")
+    SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
+ENDIF("${ARCH}" MATCHES "^arm.*")
+
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -Wl,--hash-style=both")
+
+ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
+ADD_DEFINITIONS("-DIMAGEDIR=\"${IMAGEDIR}\"")
+ADD_DEFINITIONS("-DDATADIR=\"${DATADIR}\"")
+ADD_DEFINITIONS("-DDBDATADIR=\"${DBDATADIR}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+ADD_DEFINITIONS("-DICONDIR=\"${ICONDIR}\"")
+ADD_DEFINITIONS("-DHISTORYDB=\"${HISTORYDB}\"")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${LIB_DL})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
+
+INSTALL(DIRECTORY DESTINATION ${DATADIR})
+INSTALL(DIRECTORY DESTINATION ${DBDATADIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/res/${PKGNAME}.xml DESTINATION /opt/share/packages)
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res/images DESTINATION ${RESDIR})
+
+# i18n
+ADD_SUBDIRECTORY(po)
+
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..f1d14d9
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,33 @@
+1. make the build directory
+
+  ex)
+
+   $ mkdir build
+
+
+2. change the working directory to the build directory
+
+  ex)
+
+   $ cd build
+
+
+3. run 'cmake'
+
+  $ cmake ${SOURCE_DIR} -DCMAKE_INSTALL_PREFIX=/opt/apps/@@PKGNAME@@
+
+  ex)
+
+   $ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/apps/@@PKGNAME@@
+
+   or
+
+   $ cmake ..
+
+
+4. make & make install
+
+  ex)
+
+   $ make -j 2 && make install
+
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..ccbf311
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,75 @@
+Flora License\r
+\r
+Version 1.0, May, 2012\r
+\r
+http://www.tizenopensource.org/license\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, and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.\r
+\r
+"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.\r
+\r
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.\r
+\r
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.\r
+\r
+"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.\r
+\r
+"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).\r
+\r
+"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.\r
+\r
+"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."\r
+\r
+"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.\r
+\r
+"Tizen Certified Platform" shall mean a software platform that complies with the standards set forth in the Compatibility Definition Document and passes the Compatibility Test Suite as defined from time to time by the Tizen Technical Steering Group and certified by the Tizen Association or its designated agent.\r
+\r
+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.\r
+\r
+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 solely as incorporated into a Tizen Certified Platform, 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 solely as incorporated into a Tizen Certified Platform 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.\r
+\r
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof pursuant to the copyright license above, in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:\r
+\r
+  1. You must give any other recipients of the Work or Derivative Works a copy of this License; and\r
+\r
+  2. You must cause any modified files to carry prominent notices stating that You changed the files; and\r
+\r
+  3. 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\r
+\r
+  4. 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.\r
+\r
+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.\r
+\r
+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.\r
+\r
+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.\r
+\r
+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.\r
+\r
+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.\r
+\r
+END OF TERMS AND CONDITIONS\r
+\r
+APPENDIX: How to apply the Flora License to your work\r
+\r
+To apply the Flora 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.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Flora License, Version 1.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.tizenopensource.org/license\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
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..b97249e
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
\ No newline at end of file
diff --git a/packaging/org.tizen.download-manager.spec b/packaging/org.tizen.download-manager.spec
new file mode 100644 (file)
index 0000000..6935329
--- /dev/null
@@ -0,0 +1,72 @@
+
+Name:  org.tizen.download-manager
+Summary:       Application for support of the content download
+Version:       0.0.1
+Release:       4
+Group:         TO_BE_FILLED_IN
+License:       TO_BE_FILLED_IN
+URL:           N/A
+Source0:       %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(capi-web-url-download)
+BuildRequires: pkgconfig(capi-system-runtime-info)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(capi-content-media-content)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(xdgmime)
+BuildRequires: pkgconfig(icu-i18n)
+BuildRequires: cmake
+BuildRequires: gettext-devel
+BuildRequires: expat-devel
+BuildRequires: edje-tools
+
+%description
+Application for support of the content download
+
+%prep
+%setup -q
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX="/opt/apps/org.tizen.download-manager"
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%post
+#### Download History ####
+if [ ! -f /opt/apps/org.tizen.download-manager/data/db/.download-history.db ];
+then
+               sqlite3 /opt/apps/org.tizen.download-manager/data/db/.download-history.db 'PRAGMA journal_mode=PERSIST;
+               create table history(id integer primary key autoincrement, historyid integer, downloadtype integer, contenttype integer, state integer, err integer, name, path, url, cookie, date datetime);'
+fi
+
+chown -R 5000:5000 /opt/apps/org.tizen.download-manager/data
+chmod 660 /opt/apps/org.tizen.download-manager/data/db/.download-history.db
+chmod 660 /opt/apps/org.tizen.download-manager/data/db/.download-history.db-journal
+
+%files
+%defattr(-,root,root,-)
+/opt/apps/org.tizen.download-manager/bin/*
+/opt/apps/org.tizen.download-manager/data
+/opt/apps/org.tizen.download-manager/res/*
+/opt/share/packages/org.tizen.download-manager.xml
+
+%changelog
+* Mon Aug 17 2012 Jungki Kwak <jungki.kwak@samsung.com>
+- Add https protocol to service uri field
+
+* Mon Aug 16 2012 Jungki Kwak <jungki.kwak@samsung.com>
+- Change boilerplates and licence to flora
+
+* Mon Aug 10 2012 Jungki Kwak <jungki.kwak@samsung.com>
+- Do not display installing message
+
+* Fri Aug 03 2012 Jungki Kwak <jungki.kwak@samsung.com>
+- Initial release
+
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7ad9f2a
--- /dev/null
@@ -0,0 +1,26 @@
+# for i18n
+
+SET(POFILES ar.po ca.po da.po el_GR.po en_US.po fi.po he.po hr.po id.po ja_JP.po lt.po ms.po no.po pt_PT.po
+       ru_RU.po sl.po sv.po tr_TR.po vi.po zh_HK.po bg.po cs.po de_DE.po en.po es_ES.po fr_FR.po hi.po hu.po
+       it_IT.po ko_KR.po lv.po nl_NL.po pl.po ro.po sk.po sr.po th.po uk.po zh_CN.po zh_TW.po)
+
+SET(MSGFMT "/usr/bin/msgfmt")
+
+FOREACH(pofile ${POFILES})
+       SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile})
+       MESSAGE("PO: ${pofile}")
+       GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE)
+       GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE)
+       SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo)
+       ADD_CUSTOM_COMMAND(
+                       OUTPUT ${moFile}
+                       COMMAND ${MSGFMT} -o ${moFile} ${absPofile}
+                       DEPENDS ${absPofile}
+       )
+       INSTALL(FILES ${moFile}
+                       DESTINATION ${LOCALEDIR}/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo)
+       SET(moFiles ${moFiles} ${moFile})
+ENDFOREACH(pofile)
+
+MESSAGE(".mo files: ${moFiles}")
+ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles})
diff --git a/po/POTFILES.in.in b/po/POTFILES.in.in
new file mode 100644 (file)
index 0000000..bcb7f1f
--- /dev/null
@@ -0,0 +1,2 @@
+# List of source files containing translatable strings.
+@@APPNAME@@.c
diff --git a/po/ar.po b/po/ar.po
new file mode 100644 (file)
index 0000000..2f73a05
--- /dev/null
+++ b/po/ar.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "جاري الإخطار..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "إ. محاولة"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "مدير التحميل"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "الموصف غير صالح"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "لا توجد ملفات محملة"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "كامل"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "غير قادر على فتح ملف"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "تنزيل؟"
+
diff --git a/po/bg.po b/po/bg.po
new file mode 100644 (file)
index 0000000..4cd1e56
--- /dev/null
+++ b/po/bg.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Известяване..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Отново"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Диспечер на изтеглянето"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Невалиден дескриптор"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Няма изтегляния"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Завършено"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Файлът не може да се отвори"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Изтегляне?"
+
diff --git a/po/ca.po b/po/ca.po
new file mode 100644 (file)
index 0000000..bf78e84
--- /dev/null
+++ b/po/ca.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Notificant..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Reintent"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Administrador de descàrregues"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Descriptor no vàlid"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Sense descàrregues"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Finalitzar"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "No s'ha pogut obrir el fitxer"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Descarregar?"
+
diff --git a/po/cs.po b/po/cs.po
new file mode 100644 (file)
index 0000000..970f5f7
--- /dev/null
+++ b/po/cs.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Probíhá oznamování..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Opakovat"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Správce stahování"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Chybný deskriptor"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Žádné stažené položky"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Dokončeno"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Soubor nelze otevřít"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Stáhnout?"
+
diff --git a/po/da.po b/po/da.po
new file mode 100644 (file)
index 0000000..7e991ec
--- /dev/null
+++ b/po/da.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Giver besked..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Prøv igen"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Downloadstyring"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Ugyldig beskrivelse"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Ingen downloads"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "udført"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Kunne ikke åbne fil"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Download?"
+
diff --git a/po/de_DE.po b/po/de_DE.po
new file mode 100644 (file)
index 0000000..1d0cd55
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Benachrichtigung..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Ern. vers."
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Download-Manager"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Ungültiger Descriptor"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Keine Downloads"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Abgeschlossen"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Datei kann nicht geöffnet werden"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Herunterladen?"
+
diff --git a/po/el_GR.po b/po/el_GR.po
new file mode 100644 (file)
index 0000000..9b71a13
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Ειδοποίηση..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Επανάληψη"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Διαχείριση λήψεων"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Μη έγκυρη περιγραφή"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Δεν υπάρχουν λήψεις"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Ολοκληρώθηκε"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Δεν είναι δυνατό το άνοιγμα αρχείου"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Λήψη;"
+
diff --git a/po/en.po b/po/en.po
new file mode 100644 (file)
index 0000000..0910a1f
--- /dev/null
+++ b/po/en.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Notifying..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Retry"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Download manager"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Invalid descriptor"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "No downloads"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Complete"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Unable to open file"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Download?"
+
diff --git a/po/en_US.po b/po/en_US.po
new file mode 100644 (file)
index 0000000..0910a1f
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Notifying..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Retry"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Download manager"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Invalid descriptor"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "No downloads"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Complete"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Unable to open file"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Download?"
+
diff --git a/po/es_ES.po b/po/es_ES.po
new file mode 100644 (file)
index 0000000..e994881
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Notificando..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Reint."
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Administrador de descarga"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Descriptor no válido"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Sin descargas"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Completo"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "No se puede abrir el archivo"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "¿Descargar?"
+
diff --git a/po/fi.po b/po/fi.po
new file mode 100644 (file)
index 0000000..ce7f5b5
--- /dev/null
+++ b/po/fi.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Ilmoitetaan..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Yritä uud."
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Latauksen hallinta"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Virheellinen kuvaus"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Latauksia ei ole"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Valmis"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Tiedostoa ei voi avata"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Ladataanko?"
+
diff --git a/po/fr_FR.po b/po/fr_FR.po
new file mode 100644 (file)
index 0000000..c42e416
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Notification..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Réessayer"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Gestionnaire de téléchargement"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Descripteur non valide"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Aucun téléchargement"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "OK"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Impossible d'ouvrir le fichier"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Télécharger ?"
+
diff --git a/po/he.po b/po/he.po
new file mode 100644 (file)
index 0000000..0cd3831
--- /dev/null
+++ b/po/he.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "מדווח..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "נסה שוב"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "מנהל ההורדות"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "מתאר לא חוקי"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "אין הורדות"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "השלם"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "לא ניתן לפתוח קובץ"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "להוריד?"
+
diff --git a/po/hi.po b/po/hi.po
new file mode 100644 (file)
index 0000000..def175b
--- /dev/null
+++ b/po/hi.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "सूचित किया जा रहा है..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "पुन: प्रयास"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "डाउनलोड प्रबंधक"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "अमान्य वर्णनकर्ता"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "कोई डाउनलोड नहीं"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "पूर्ण"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "फाईल खोलने में अक्षम"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "डाउनलोड?"
+
diff --git a/po/hr.po b/po/hr.po
new file mode 100644 (file)
index 0000000..c4f3ce3
--- /dev/null
+++ b/po/hr.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Obaviješćivanje..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Ponovi"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Upravljanje skidanja"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Neispravan opis"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Nema skidanja"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Dovrši"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Nemoguće otvoriti datoteku"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Skinuti?"
+
diff --git a/po/hu.po b/po/hu.po
new file mode 100644 (file)
index 0000000..7098988
--- /dev/null
+++ b/po/hu.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Értesítés..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Újra"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Letöltéskezelő"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Érvénytelen leíró"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Nincsenek letöltések"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Befejeződött"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "A fájl nem nyitható meg"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Letöltés?"
+
diff --git a/po/id.po b/po/id.po
new file mode 100644 (file)
index 0000000..c8f4cc1
--- /dev/null
+++ b/po/id.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Mengingatkan..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Coba ulang"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Pengelola download"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Deskriptor tidak berlaku"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Tidak ada unduhan"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Selesai"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Tdk dapat utk buka file"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Unduh?"
+
diff --git a/po/it_IT.po b/po/it_IT.po
new file mode 100644 (file)
index 0000000..c98402c
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Notifica in corso..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Riprova"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Gestione download"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Descrittore non valido"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Nessun download"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Completo"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Impossibile aprire file"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Scaricare?"
+
diff --git a/po/ja_JP.po b/po/ja_JP.po
new file mode 100644 (file)
index 0000000..a6ae09f
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "通知中..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "再接続"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "ダウンロードマネージャー"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "識別子​が​無効​です。"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "ダウンロードデータがありません。"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "完了"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "ファイル​を​開く​こと​が​できません"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "ダウンロードしますか?"
+
diff --git a/po/ko_KR.po b/po/ko_KR.po
new file mode 100644 (file)
index 0000000..d15b0c4
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "알림 준비 중..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "재시도"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "다운로드 관리자"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "설명이 바르지 않습니다"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "다운로드가 없습니다"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "완료"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "파일을 열 수 없습니다"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "다운로드할까요?"
+
diff --git a/po/lt.po b/po/lt.po
new file mode 100644 (file)
index 0000000..486001f
--- /dev/null
+++ b/po/lt.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Informuojama..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Bandyti dar kartą"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Atsisiuntimų tvarkytuvė"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Netinkamas aprašymas"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Nėra atsisiuntimų"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Užbaigta"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Negalima atidaryti failo"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Ar atsisiųsti?"
+
diff --git a/po/lv.po b/po/lv.po
new file mode 100644 (file)
index 0000000..d9837d0
--- /dev/null
+++ b/po/lv.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Paziņo..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Atkārtot"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Lejupielāžu pārvaldnieks"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Nederīgs deskriptors"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Nav lejupielāžu"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Pabeigta"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Nevar atvērt failu"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Vai lejupielādēt?"
+
diff --git a/po/ms.po b/po/ms.po
new file mode 100644 (file)
index 0000000..f8ae49d
--- /dev/null
+++ b/po/ms.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Memberitahu..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Cuba lg"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Pengurus muat turun"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Pemerihal tidak sah"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Tiada muat turun"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Lengkap"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Tdk dpt buka fail"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Muat turun?"
+
diff --git a/po/nl_NL.po b/po/nl_NL.po
new file mode 100644 (file)
index 0000000..c9c21fa
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Melden..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Opnieuw"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Downloadmanager"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Ongeldige descriptor"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Geen downloads"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Voltooid"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Kan bestand niet openen"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Downloaden?"
+
diff --git a/po/no.po b/po/no.po
new file mode 100644 (file)
index 0000000..79bce21
--- /dev/null
+++ b/po/no.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Varsler..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Prøv igjen"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Nedlastingsbehandling"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Ugyldig deskriptor"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Ingen nedlastinger"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Fullført"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Kan ikke åpne fil"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Laste ned?"
+
diff --git a/po/pl.po b/po/pl.po
new file mode 100644 (file)
index 0000000..2b23e40
--- /dev/null
+++ b/po/pl.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Powiadamianie..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Ponów"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Menedżer pobierania"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Nieprawidłowy deskryptor"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Brak pobranych elementów"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Zakończono"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Nie można otworzyć pliku"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Pobrać?"
+
diff --git a/po/pt_PT.po b/po/pt_PT.po
new file mode 100644 (file)
index 0000000..3d35c41
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "A notificar..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Repetir"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Gestor de transferências"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Descrição inválida"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Nenhumas transferências"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Concluída"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Impossível abrir ficheiro"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Transferir?"
+
diff --git a/po/ro.po b/po/ro.po
new file mode 100644 (file)
index 0000000..85891d4
--- /dev/null
+++ b/po/ro.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Se notifică..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Reîncerc."
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Manager descărcare"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "JAD invalid"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Nicio descărcare"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "terminat"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Imposibil de deschis fişierul"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Descărcaţi?"
+
diff --git a/po/ru_RU.po b/po/ru_RU.po
new file mode 100644 (file)
index 0000000..6980dfa
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Уведомление..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Повтор"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Диспетчер загрузки"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Неверный дескриптор"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Нет загрузок"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Завершено"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Невозможно открыть файл"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Загрузить?"
+
diff --git a/po/sk.po b/po/sk.po
new file mode 100644 (file)
index 0000000..75c2c11
--- /dev/null
+++ b/po/sk.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Odosiela sa notifikácia..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Opakovať"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Správca sťahovaní"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Chybný deskriptor"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Žiadne sťahovania"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Dokončené"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Súbor sa nedá otvoriť"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Stiahnuť?"
+
diff --git a/po/sl.po b/po/sl.po
new file mode 100644 (file)
index 0000000..91ba809
--- /dev/null
+++ b/po/sl.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Obveščam ..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Pos.znova"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Upravitelj prenosov"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Neveljaven deskriptor"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Ni prenosov"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Končano"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Datoteke ni mogoče odpreti"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Prenesem?"
+
diff --git a/po/sr.po b/po/sr.po
new file mode 100644 (file)
index 0000000..4ac55f1
--- /dev/null
+++ b/po/sr.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Obaveštavanje..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Pokušaj ponovo"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Menadžer preuzimanja"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Neispravan deskriptor"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Nema preuzimanja"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Završeno"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Nemoguće otvoriti fajl"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Preuzmi?"
+
diff --git a/po/sv.po b/po/sv.po
new file mode 100644 (file)
index 0000000..6c46a4c
--- /dev/null
+++ b/po/sv.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Meddelar..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Försök"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Hämtningshanterare"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Ogiltig beskrivning"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Inga nedladdningar"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Klar"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Det går inte att öppna filen"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Hämta?"
+
diff --git a/po/th.po b/po/th.po
new file mode 100644 (file)
index 0000000..75c98e1
--- /dev/null
+++ b/po/th.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "กำลัง​แจ้ง​ข้อมูล..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "ลอง​ใหม่"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "การจัดการการ​ดาวน์​โหลด"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "ตัว​อธิบาย​ไม่​ถูก​ต้อง"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "ไม่​มี​การ​ดาวน์​โหลด"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "ครบ​ถ้วน"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "เปิด​ไฟล์​ไม่​ได้​เข้า​กัน​ไม่​ได้"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "ดาวน์​โหลด?"
+
diff --git a/po/tr_TR.po b/po/tr_TR.po
new file mode 100644 (file)
index 0000000..a4e0af2
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Bildiriliyor..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Y.dene"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "İndirme Yöneticisi"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Geçersiz Tanımlayıcı"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "İndirme yok"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Tamamlandı"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Dosyayı açamıyor"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Yüklensin mi?"
+
diff --git a/po/uk.po b/po/uk.po
new file mode 100644 (file)
index 0000000..6c261cf
--- /dev/null
+++ b/po/uk.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Сповіщення..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Повтор."
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Диспетчер завантажень"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Хибний JAD"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Немає завантажень"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Завершено"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Неможливо відкрити файл"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Завантажити?"
+
diff --git a/po/vi.po b/po/vi.po
new file mode 100644 (file)
index 0000000..a200bf3
--- /dev/null
+++ b/po/vi.po
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "Đang báo tin..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "Thử lại"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "Quản lý tải về"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "Miêu tả không hợp lệ"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "Không có tải xuống"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "Hoàn tất"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "Không thể mở file"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "Tải xuống?"
+
diff --git a/po/zh_CN.po b/po/zh_CN.po
new file mode 100644 (file)
index 0000000..ba5632f
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "通知中..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "重试"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "下载管理器"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "描述符无效"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "无下载项"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "完成"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "无法打开文件"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "下载?"
+
diff --git a/po/zh_HK.po b/po/zh_HK.po
new file mode 100644 (file)
index 0000000..91d044c
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "正在通知..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "重試"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "下載管理員"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "無效描述項"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "無下載項目"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "完成"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "無法開啟檔案"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "要下載嗎?"
+
diff --git a/po/zh_TW.po b/po/zh_TW.po
new file mode 100644 (file)
index 0000000..9476813
--- /dev/null
@@ -0,0 +1,24 @@
+msgid "IDS_BR_BODY_NOTIFYING_ING"
+msgstr "正在通知..."
+
+msgid "IDS_BR_SK_RETRY"
+msgstr "重試"
+
+msgid "IDS_BR_HEADER_DOWNLOAD_MANAGER"
+msgstr "下載管理員"
+
+msgid "IDS_BR_POP_INVALIDDESCRIPTOR"
+msgstr "描述元無效"
+
+msgid "IDS_DL_BODY_NO_DOWNLOADS"
+msgstr "無下載"
+
+msgid "IDS_EMAIL_BODY_COMPLETE"
+msgstr "完成"
+
+msgid "IDS_BR_POP_UNABLE_TO_OPEN_FILE"
+msgstr "無法開啟檔案"
+
+msgid "IDS_BR_POP_DOWNLOAD_Q"
+msgstr "要下載嗎?"
+
diff --git a/res/images/U06_icon_DRM.png b/res/images/U06_icon_DRM.png
new file mode 100644 (file)
index 0000000..adb9254
Binary files /dev/null and b/res/images/U06_icon_DRM.png differ
diff --git a/res/images/U06_icon_Java.png b/res/images/U06_icon_Java.png
new file mode 100644 (file)
index 0000000..317be17
Binary files /dev/null and b/res/images/U06_icon_Java.png differ
diff --git a/res/images/U06_icon_Unknown.png b/res/images/U06_icon_Unknown.png
new file mode 100644 (file)
index 0000000..024cfc1
Binary files /dev/null and b/res/images/U06_icon_Unknown.png differ
diff --git a/res/images/U06_icon_excel.png b/res/images/U06_icon_excel.png
new file mode 100644 (file)
index 0000000..2ef1042
Binary files /dev/null and b/res/images/U06_icon_excel.png differ
diff --git a/res/images/U06_icon_html.png b/res/images/U06_icon_html.png
new file mode 100644 (file)
index 0000000..72fed4a
Binary files /dev/null and b/res/images/U06_icon_html.png differ
diff --git a/res/images/U06_icon_image.png b/res/images/U06_icon_image.png
new file mode 100644 (file)
index 0000000..5b11f78
Binary files /dev/null and b/res/images/U06_icon_image.png differ
diff --git a/res/images/U06_icon_music.png b/res/images/U06_icon_music.png
new file mode 100644 (file)
index 0000000..12b6cb8
Binary files /dev/null and b/res/images/U06_icon_music.png differ
diff --git a/res/images/U06_icon_pdf.png b/res/images/U06_icon_pdf.png
new file mode 100644 (file)
index 0000000..b99803e
Binary files /dev/null and b/res/images/U06_icon_pdf.png differ
diff --git a/res/images/U06_icon_ppt.png b/res/images/U06_icon_ppt.png
new file mode 100644 (file)
index 0000000..60341e3
Binary files /dev/null and b/res/images/U06_icon_ppt.png differ
diff --git a/res/images/U06_icon_ringtone.png b/res/images/U06_icon_ringtone.png
new file mode 100644 (file)
index 0000000..4ea1672
Binary files /dev/null and b/res/images/U06_icon_ringtone.png differ
diff --git a/res/images/U06_icon_text.png b/res/images/U06_icon_text.png
new file mode 100644 (file)
index 0000000..b156b91
Binary files /dev/null and b/res/images/U06_icon_text.png differ
diff --git a/res/images/U06_icon_video.png b/res/images/U06_icon_video.png
new file mode 100644 (file)
index 0000000..0ee8587
Binary files /dev/null and b/res/images/U06_icon_video.png differ
diff --git a/res/images/U06_icon_word.png b/res/images/U06_icon_word.png
new file mode 100644 (file)
index 0000000..96d3e50
Binary files /dev/null and b/res/images/U06_icon_word.png differ
diff --git a/res/org.tizen.download-manager.xml b/res/org.tizen.download-manager.xml
new file mode 100644 (file)
index 0000000..3f4ea81
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+       <manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.download-manager" version="0.0.1" install-location="internal-only">
+       <label>Download Manager</label>
+       <author email="jungki.kwak@samsung.com" href="www.samsung.com">Jungki Kwak</author>
+       <description>Download UI Application</description>
+       <ui-application appid="org.tizen.download-manager" exec="/opt/apps/org.tizen.download-manager/bin/download-manager" nodisplay="true" multiple="false" type="capp" taskmanage="false">
+               <label>Download Manager</label>
+               <label xml:lang="en-us">Download Manager</label>
+               <application-service>
+                       <operation name="http://tizen.org/appsvc/operation/download" />
+                               <uri name="http" />
+                               <uri name="https" />
+                               <uri name="NULL" />
+               </application-service>
+       </ui-application>
+</manifest>
diff --git a/src/download-manager-dateTime.cpp b/src/download-manager-dateTime.cpp
new file mode 100644 (file)
index 0000000..44a8cf3
--- /dev/null
@@ -0,0 +1,219 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-dateTime.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      data and utility APIs for Date and Time
+ */
+
+#include "runtime_info.h"
+#include "download-manager-dateTime.h"
+
+#define MAX_SKELETON_BUFFER_LEN 8
+#define MAX_PATTERN_BUFFER_LEN 128
+
+DateGroup::DateGroup()
+       : count(0)
+       , type(DATETIME::DATE_TYPE_NONE)
+       , m_glGroupItem(NULL)
+{
+}
+
+DateGroup::~DateGroup()
+{
+}
+
+void DateGroup::initData()
+{
+       count = 0;
+       m_glGroupItem = NULL;
+}
+
+DateUtil::DateUtil()
+       : m_todayStandardTime(0)
+       , dateShortFormat(NULL)
+       , dateMediumFormat(NULL)
+       , dateFullFormat(NULL)
+       , timeFormat12H(NULL)
+       , timeFormat24H(NULL)
+{
+}
+
+DateUtil::~DateUtil()
+{
+       deinitLocaleData();
+}
+
+void DateUtil::deinitLocaleData()
+{
+       if (dateShortFormat)
+               udat_close(dateShortFormat);
+       if (dateMediumFormat)
+               udat_close(dateMediumFormat);
+       if (dateFullFormat)
+               udat_close(dateFullFormat);
+       if (timeFormat12H)
+               udat_close(timeFormat12H);
+       if (timeFormat24H)
+               udat_close(timeFormat24H);
+       dateShortFormat = NULL;
+       dateMediumFormat = NULL;
+       dateFullFormat = NULL;
+       timeFormat12H = NULL;
+       timeFormat24H = NULL;
+}
+
+int DateUtil::getDiffDaysFromToday()
+{
+       time_t now = time(NULL);
+       DP_LOGD("todayStandardTime[%ld]", m_todayStandardTime);
+       if (m_todayStandardTime == 0)
+               return 0;
+       else
+               return getDiffDays(now, m_todayStandardTime);
+}
+
+int DateUtil::getDiffDays(time_t nowTime,time_t refTime)
+{
+       int diffDays = 0;
+       int nowYear = 0;
+       int nowYday = 0;
+       int refYday = 0;
+       int refYear = 0;
+       struct tm *nowDate = localtime(&nowTime);
+       nowYday = nowDate->tm_yday;
+       nowYear = nowDate->tm_year;
+       struct tm *finishedDate = localtime(&refTime);
+       refYday = finishedDate->tm_yday;
+       refYear = finishedDate->tm_year;
+       diffDays = nowYday - refYday;
+       /*DP_LOGD("refDate[%d/%d/%d]refTime[%ld]yday[%d]",
+               (finishedDate->tm_year + 1900), (finishedDate->tm_mon + 1),
+               finishedDate->tm_mday, refTime, refYday);*/
+       if ((nowYear-refYear)>0 && diffDays < 0) {
+               int year = nowDate->tm_year;
+               diffDays = diffDays + 365;
+               /* leap year */
+               if ((year%4 == 0 && year%100 != 0) || year%400 == 0)
+                       diffDays++;
+       }
+       DP_LOGD("diffDays[%d]",diffDays);
+       return diffDays;
+}
+
+UDateFormat *DateUtil::getBestPattern(const char *patternStr,
+       UDateTimePatternGenerator *generator, const char *locale)
+{
+       UDateFormat *format = NULL;
+       UChar customSkeleton[MAX_SKELETON_BUFFER_LEN] = {0,};
+       UChar bestPattern[MAX_PATTERN_BUFFER_LEN] = {0,};
+       UErrorCode status = U_ZERO_ERROR;
+       int32_t patternLen = 0;
+
+       if (patternStr) {
+               u_uastrncpy(customSkeleton, patternStr, strlen(patternStr));
+               patternLen = udatpg_getBestPattern(generator, customSkeleton,
+               u_strlen(customSkeleton), bestPattern, MAX_PATTERN_BUFFER_LEN,
+                       &status);
+               DP_LOGD("udatpg_getBestPattern status[%d] bestPattern[%s]", status,
+                       bestPattern);
+               if (patternLen < 1) {
+                       format = udat_open(UDAT_SHORT, UDAT_NONE, locale, NULL, -1,
+                               NULL, -1, &status);
+                       return format;
+               }
+       }
+       format = udat_open(UDAT_IGNORE, UDAT_NONE, locale, NULL, -1,
+               bestPattern, -1, &status);
+       return format;
+}
+
+void DateUtil::updateLocale()
+{
+       UDateTimePatternGenerator *generator = NULL;
+       UErrorCode status = U_ZERO_ERROR;
+       const char *locale = NULL;
+
+       DP_LOGD_FUNC();
+
+       deinitLocaleData();
+
+       uloc_setDefault(getenv("LC_TIME"), &status);
+       DP_LOGD("uloc_setDefault status[%d]",status);
+
+       locale = uloc_getDefault();
+       generator = udatpg_open(locale,&status);
+       DP_LOGD("udatpg_open status[%d]",status);
+
+       timeFormat12H = getBestPattern("hm", generator, locale);
+       timeFormat24H = getBestPattern("Hm", generator, locale);
+
+       dateShortFormat = udat_open(UDAT_NONE, UDAT_SHORT, locale, NULL, -1, NULL,
+               -1, &status);
+       dateMediumFormat = udat_open(UDAT_NONE, UDAT_MEDIUM, locale, NULL, -1, NULL,
+               -1, &status);
+       dateFullFormat = getBestPattern("yMMMEEEd", generator, locale);
+       udatpg_close(generator);
+}
+
+void DateUtil::getDateStr(int style, double time, string &outBuf)
+{
+       UDateFormat *format = NULL;
+       UErrorCode status = U_ZERO_ERROR;
+       UChar str[MAX_BUF_LEN] = {0,};
+       bool value = false;
+
+       DP_LOGD_FUNC();
+       switch (style) {
+       case LOCALE_STYLE::TIME:
+               if (runtime_info_get_value_bool(
+                               RUNTIME_INFO_KEY_24HOUR_CLOCK_FORMAT_ENABLED,&value) != 0) {
+                       DP_LOGE("runtime_info_get_value_bool is failed");
+                       format = timeFormat12H;
+               } else {
+                       if (value)
+                               format = timeFormat24H;
+                       else
+                               format = timeFormat12H;
+               }
+               break;
+       case LOCALE_STYLE::SHORT_DATE:
+               format = dateShortFormat;
+               break;
+       case LOCALE_STYLE::MEDIUM_DATE:
+               format = dateMediumFormat;
+               break;
+       case LOCALE_STYLE::FULL_DATE:
+               format = dateFullFormat;
+               break;
+       default :
+               DP_LOGE("Critical: cannot enter here");
+               format = timeFormat12H;
+               break;
+       }
+       if (format) {
+               char tempBuf[MAX_BUF_LEN] = {0,};
+               udat_format(format, time, str, MAX_BUF_LEN - 1, NULL, &status);
+               DP_LOGD("udat_format : status[%d]", status);
+               u_austrncpy(tempBuf, str, MAX_BUF_LEN-1);
+               outBuf = string(tempBuf);
+       } else {
+               DP_LOGE("Critical: fail to get time value");
+               outBuf = string(S_("IDS_COM_POP_ERROR"));
+       }
+}
+
diff --git a/src/download-manager-downloadItem.cpp b/src/download-manager-downloadItem.cpp
new file mode 100644 (file)
index 0000000..e536790
--- /dev/null
@@ -0,0 +1,443 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-downloadItem.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      download item class for interface of download agent
+ */
+
+#include <Ecore.h>
+#include <iostream>
+#include "download-manager-downloadItem.h"
+#include "download-manager-common.h"
+
+static Ecore_Pipe *ecore_pipe = NULL;
+static void __ecore_cb_pipe_update(void *data, void *buffer, unsigned int nbyte);
+
+namespace DA_CB {
+enum TYPE {
+       STARTED = 1,
+       PROGRESS,
+       PAUSED,
+       COMPLETED,
+       STOPPED
+};
+}
+
+class CbData {
+public:
+       CbData() {}
+       ~CbData() {}
+
+       void updateDownloadItem();
+
+       inline void setType(DA_CB::TYPE type) { m_type = type; }
+       inline void setUserData(void *userData) { m_userData = userData; }
+       inline void setDownloadHandle(url_download_h handle) { m_download_handle = handle; }
+       inline void setReceivedFileSize(unsigned long int size) { m_receivedFileSize = size; }
+       inline void setFileSize(unsigned long int size) { m_fileSize = size; }
+       inline void setContentName(const char *name) { if (name) m_contentName = name; }
+       inline void setRegisteredFilePath(const char *path) { if (path) m_registeredFilePath = path; }
+       inline void setMimeType(const char *mime) { m_mimeType = mime; }
+       inline void setErrorCode(int err) { m_error = err;      }
+
+private:
+       DA_CB::TYPE m_type;
+       void *m_userData;
+       url_download_h m_download_handle;
+       int m_error;
+       unsigned long int m_receivedFileSize;
+       unsigned long int m_fileSize;
+       string m_contentName;
+       string m_registeredFilePath;
+       string m_mimeType;
+};
+
+struct pipe_data_t {
+       CbData *cbData;
+};
+
+DownloadEngine::DownloadEngine()
+{
+}
+
+DownloadEngine::~DownloadEngine()
+{
+       DP_LOG_FUNC();
+}
+
+void DownloadEngine::initEngine(void)
+{
+       ecore_pipe = ecore_pipe_add(__ecore_cb_pipe_update, NULL);
+}
+
+void DownloadEngine::deinitEngine(void)
+{
+       DP_LOG_FUNC();
+       if (ecore_pipe) {
+               ecore_pipe_del(ecore_pipe);
+               ecore_pipe = NULL;
+       }
+}
+
+void CbData::updateDownloadItem()
+{
+//     DP_LOGD_FUNC();
+
+       if (!m_userData) {
+               DP_LOGE("download item is NULL");
+               return;
+       }
+
+       DownloadItem *downloadItem = static_cast<DownloadItem*>(m_userData);
+       if (downloadItem->state() == DL_ITEM::FAILED) {
+               DP_LOGE("download item is already failed");
+               return;
+       }
+       downloadItem->setDownloadHandle(m_download_handle);
+
+       switch(m_type) {
+       case DA_CB::STARTED:
+               downloadItem->setState(DL_ITEM::STARTED);
+               //downloadItem->setFileSize(m_fileSize);
+               if (!m_contentName.empty())
+                       downloadItem->setContentName(m_contentName);
+               if (!m_mimeType.empty())
+                       downloadItem->setMimeType(m_mimeType);
+               break;
+       case DA_CB::PROGRESS:
+               downloadItem->setState(DL_ITEM::UPDATING);
+               downloadItem->setFileSize(m_fileSize);
+               downloadItem->setReceivedFileSize(m_receivedFileSize);
+               break;
+       case DA_CB::PAUSED:
+               downloadItem->setState(DL_ITEM::SUSPENDED);
+               downloadItem->setFileSize(m_fileSize);
+               downloadItem->setReceivedFileSize(m_receivedFileSize);
+               break;
+       case DA_CB::COMPLETED:
+               downloadItem->setState(DL_ITEM::FINISHED);
+               if (!m_registeredFilePath.empty()) {
+                       DP_LOGD("registeredFilePath[%s]", m_registeredFilePath.c_str());
+                       downloadItem->setRegisteredFilePath(m_registeredFilePath);
+               }
+               break;
+       case DA_CB::STOPPED:
+               if (m_error != URL_DOWNLOAD_ERROR_NONE) {
+                       downloadItem->setState(DL_ITEM::FAILED);
+                       downloadItem->setErrorCode(downloadItem->_convert_error(m_error));
+               } else {
+                       downloadItem->setState(DL_ITEM::CANCELED);
+               }
+               break;
+       default:
+               break;
+       }
+       downloadItem->notify();
+}
+
+void __ecore_cb_pipe_update(void *data, void *buffer, unsigned int nbyte)
+{
+//     DP_LOGD_FUNC();
+
+       if (!buffer)
+               return;
+       pipe_data_t *pipe_data = static_cast<pipe_data_t *>(buffer);
+       CbData *cbData = pipe_data->cbData;
+       if (!cbData)
+               return;
+
+       cbData->updateDownloadItem();
+       delete cbData;
+}
+
+DownloadItem::DownloadItem()
+       : m_download_handle(NULL)
+       , m_state(DL_ITEM::IGNORE)
+       , m_errorCode(ERROR::NONE)
+       , m_receivedFileSize(0)
+       , m_fileSize(0)
+       , m_downloadType(DL_TYPE::HTTP_DOWNLOAD)
+{
+}
+
+DownloadItem::DownloadItem(auto_ptr<DownloadRequest> request)
+       : m_aptr_request(request)
+       , m_download_handle(NULL)
+       , m_state(DL_ITEM::IGNORE)
+       , m_errorCode(ERROR::NONE)
+       , m_receivedFileSize(0)
+       , m_fileSize(0)
+       , m_downloadType(DL_TYPE::HTTP_DOWNLOAD)
+{
+       int ret = url_download_create(&m_download_handle);
+       if (ret != URL_DOWNLOAD_ERROR_NONE) {
+               DP_LOGE("Fail to create download handle : [%d]", ret);
+               return;
+       }
+       DP_LOGD("URL download handle : [%p]", m_download_handle);
+       ret = url_download_set_started_cb(m_download_handle, started_cb, static_cast<void*>(this));
+       if (ret != URL_DOWNLOAD_ERROR_NONE) {
+               DP_LOGE("Fail to set started callback : [%d]", ret);
+               return;
+       }
+
+       ret = url_download_set_completed_cb(m_download_handle, completed_cb, static_cast<void*>(this));
+       if (ret != URL_DOWNLOAD_ERROR_NONE) {
+               DP_LOGE("Fail to set completed cb : [%d]", ret);
+               return;
+       }
+
+       ret = url_download_set_paused_cb(m_download_handle, paused_cb, static_cast<void*>(this));
+       if (ret != URL_DOWNLOAD_ERROR_NONE) {
+               DP_LOGE("Fail to set paused cb : [%d]", ret);
+               return;
+       }
+
+       ret = url_download_set_stopped_cb(m_download_handle, stopped_cb, static_cast<void*>(this));
+       if (ret != URL_DOWNLOAD_ERROR_NONE) {
+               DP_LOGE("Fail to set stopped cb : [%d]", ret);
+               return;
+       }
+
+       ret = url_download_set_progress_cb(m_download_handle, progress_cb, static_cast<void*>(this));
+       if (ret != URL_DOWNLOAD_ERROR_NONE) {
+               DP_LOGE("Fail to set progress cb : [%d]", ret);
+               return;
+       }
+}
+
+DownloadItem::~DownloadItem()
+{
+       DP_LOGD_FUNC();
+       if (!m_download_handle)
+               return;
+       url_download_unset_started_cb(m_download_handle);
+       url_download_unset_completed_cb(m_download_handle);
+       url_download_unset_paused_cb(m_download_handle);
+       url_download_unset_stopped_cb(m_download_handle);
+       url_download_unset_progress_cb(m_download_handle);
+       url_download_destroy(m_download_handle);
+}
+
+void DownloadItem::started_cb(url_download_h download, const char *name,
+       const char *mime, void *user_data)
+{
+
+       CbData *cbData = new CbData();
+       cbData->setType(DA_CB::STARTED);
+       cbData->setDownloadHandle(download);
+       cbData->setUserData(user_data);
+       if (name)
+               cbData->setContentName(name);
+       if (mime)
+               cbData->setMimeType(mime);
+
+       pipe_data_t pipe_data;
+       pipe_data.cbData = cbData;
+       ecore_pipe_write(ecore_pipe, &pipe_data, sizeof(pipe_data_t));
+}
+
+void DownloadItem::paused_cb(url_download_h download, void *user_data)
+{
+       CbData *cbData = new CbData();
+       cbData->setType(DA_CB::PAUSED);
+       cbData->setDownloadHandle(download);
+       cbData->setUserData(user_data);
+
+       pipe_data_t pipe_data;
+       pipe_data.cbData = cbData;
+       ecore_pipe_write(ecore_pipe, &pipe_data, sizeof(pipe_data_t));
+}
+
+void DownloadItem::completed_cb(url_download_h download, const char *path,
+       void *user_data)
+{
+       CbData *cbData = new CbData();
+       cbData->setType(DA_CB::COMPLETED);
+       cbData->setDownloadHandle(download);
+       cbData->setUserData(user_data);
+       cbData->setRegisteredFilePath(path);
+
+       pipe_data_t pipe_data;
+       pipe_data.cbData = cbData;
+       ecore_pipe_write(ecore_pipe, &pipe_data, sizeof(pipe_data_t));
+}
+
+void DownloadItem::stopped_cb(url_download_h download, url_download_error_e error,
+       void *user_data)
+{
+       CbData *cbData = new CbData();
+       cbData->setType(DA_CB::STOPPED);
+       cbData->setDownloadHandle(download);
+       cbData->setUserData(user_data);
+       cbData->setErrorCode(error);
+
+       pipe_data_t pipe_data;
+       pipe_data.cbData = cbData;
+       ecore_pipe_write(ecore_pipe, &pipe_data, sizeof(pipe_data_t));
+}
+
+void DownloadItem::progress_cb(url_download_h download, unsigned long long received,
+       unsigned long long total, void *user_data)
+{
+       CbData *cbData = new CbData();
+       cbData->setType(DA_CB::PROGRESS);
+       cbData->setDownloadHandle(download);
+       cbData->setUserData(user_data);
+       cbData->setFileSize(total);
+       cbData->setReceivedFileSize(received);
+// need to tmp path??
+
+       pipe_data_t pipe_data;
+       pipe_data.cbData = cbData;
+       ecore_pipe_write(ecore_pipe, &pipe_data, sizeof(pipe_data_t));
+}
+
+void DownloadItem::start(bool isRetry)
+{
+       int ret = 0;
+       int id = 0;
+       DP_LOGD_FUNC();
+       if (!m_download_handle) {
+               DP_LOGE("handle is NULL");
+               m_state = DL_ITEM::FAILED;
+               m_errorCode = ERROR::ENGINE_FAIL;
+               notify();
+               return;
+       }
+
+       if (!isRetry) {
+               ret = url_download_set_url(m_download_handle,
+                               m_aptr_request->getUrl().c_str());
+               if (ret != URL_DOWNLOAD_ERROR_NONE) {
+                       DP_LOGE("Fail to set url : [%d]", ret);
+                       m_state = DL_ITEM::FAILED;
+                       m_errorCode = ERROR::ENGINE_FAIL;
+                       notify();
+                       return;
+               }
+               if (!m_aptr_request->getCookie().empty()) {
+                       ret = url_download_add_http_header_field(m_download_handle,
+                                       "Cookie", m_aptr_request->getCookie().c_str());
+                       if (ret != URL_DOWNLOAD_ERROR_NONE) {
+                               DP_LOGE("Fail to set cookie : [%d]", ret);
+                               m_state = DL_ITEM::FAILED;
+                               m_errorCode = ERROR::ENGINE_FAIL;
+                               notify();
+                               return;
+                       }
+               }
+       }
+       ret = url_download_start(m_download_handle, &id);
+       DP_LOGD("URL download handle : handle[%p]id[%d]", m_download_handle, id);
+
+       if (ret != URL_DOWNLOAD_ERROR_NONE) {
+               m_state = DL_ITEM::FAILED;
+               m_errorCode = ERROR::ENGINE_FAIL;
+               notify();
+       }
+}
+
+ERROR::CODE DownloadItem::_convert_error(int err)
+{
+       DP_LOGD("download module error[%d]", err);
+
+       switch (err) {
+       /*
+       case URL_DOWNLOAD_ERROR_NONE:
+       case URL_DOWNLOAD_ERROR_INVALID_PARAMETER:
+       case URL_DOWNLOAD_ERROR_OUT_OF_MEMORY:
+       case URL_DOWNLOAD_ERROR_IO_ERROR:
+       case URL_DOWNLOAD_ERROR_FIELD_NOT_FOUND:
+       case URL_DOWNLOAD_ERROR_INVALID_STATE:
+       case URL_DOWNLOAD_ERROR_INVALID_DESTINATION:
+       case URL_DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS:
+*/
+       case URL_DOWNLOAD_ERROR_NETWORK_UNREACHABLE:
+       case URL_DOWNLOAD_ERROR_CONNECTION_TIMED_OUT:
+       case URL_DOWNLOAD_ERROR_CONNECTION_FAILED:
+               return ERROR::NETWORK_FAIL;
+
+       case URL_DOWNLOAD_ERROR_INVALID_URL:
+               return ERROR::INVALID_URL;
+
+       case URL_DOWNLOAD_ERROR_NO_SPACE:
+               return ERROR::NOT_ENOUGH_MEMORY;
+
+//             return ERROR::FAIL_TO_INSTALL;
+       default :
+               return ERROR::UNKNOWN;
+       }
+
+}
+
+void DownloadItem::cancel()
+{
+       DP_LOGD("DownloadItem::cancel");
+       if (m_state == DL_ITEM::CANCELED) {
+               DP_LOGD("It is already canceled");
+               notify();
+               return;
+       }
+       int ret = url_download_stop(m_download_handle);
+       if (ret != URL_DOWNLOAD_ERROR_NONE) {
+               DP_LOGE("Fail to cancel download : handle[%p]  reason[%d]",
+                       m_download_handle, ret);
+               m_state = DL_ITEM::FAILED;
+               m_errorCode = ERROR::ENGINE_FAIL;
+               notify();
+       }
+       return;
+}
+
+void DownloadItem::retry()
+{
+       DP_LOGD_FUNC();
+//     m_download_handle = NULL;
+       m_state = DL_ITEM::IGNORE;
+       m_errorCode = ERROR::NONE;
+       m_receivedFileSize = 0;
+       m_fileSize = 0;
+       m_downloadType = DL_TYPE::HTTP_DOWNLOAD;
+       start(true);
+}
+
+void DownloadItem::suspend()
+{
+       int ret = url_download_pause(m_download_handle);
+       if (ret != URL_DOWNLOAD_ERROR_NONE) {
+               DP_LOGE("Fail to suspend download : handle[%p] err[%d]",
+                       m_download_handle, ret);
+               m_state = DL_ITEM::FAILED;
+               m_errorCode = ERROR::ENGINE_FAIL;
+               notify();
+       }
+}
+
+void DownloadItem::resume()
+{
+       int id = 0;
+       int ret = url_download_start(m_download_handle, &id);
+       if (ret != URL_DOWNLOAD_ERROR_NONE) {
+               DP_LOGE("Fail to resume download : handle[%p] err[%d]",
+                       m_download_handle, ret);
+               m_state = DL_ITEM::FAILED;
+               m_errorCode = ERROR::ENGINE_FAIL;
+               notify();
+       }
+}
diff --git a/src/download-manager-downloadRequest.cpp b/src/download-manager-downloadRequest.cpp
new file mode 100644 (file)
index 0000000..06269b6
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-provier-downloadRequest.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      download request data class
+ */
+#include "download-manager-downloadRequest.h"
+
+/*DownloadRequest::DownloadRequest()
+       : m_url(NULL)
+       , m_cookie(NULL)
+{
+}*/
+
+DownloadRequest::DownloadRequest(string url, string cookie)
+       : m_url(url)
+       , m_cookie(cookie)
+{
+}
+
+DownloadRequest::DownloadRequest(DownloadRequest &rRequest)
+{
+       m_url.assign(rRequest.getUrl());
+       m_cookie.assign(rRequest.getCookie());
+}
+
+DownloadRequest::~DownloadRequest()
+{
+//     DP_LOG_FUNC();
+}
+
+string &DownloadRequest::getUrl()
+{
+       return m_url;
+}
+
+string &DownloadRequest::getCookie()
+{
+       return m_cookie;
+}
+
+bool DownloadRequest::isUrlEmpty()
+{
+       return m_url.empty();
+}
+
+bool DownloadRequest::isCookieEmpty()
+{
+       return m_cookie.empty();
+}
+
+void DownloadRequest::setUrl(string url)
+{
+       m_url.assign(url);
+}
+
+void DownloadRequest::setCookie(string cookie)
+{
+       m_cookie.assign(cookie);
+}
diff --git a/src/download-manager-event.cpp b/src/download-manager-event.cpp
new file mode 100644 (file)
index 0000000..5e710f6
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-event.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      download event class for event flow
+ */
+#include "download-manager-event.h"
+#include "download-manager-common.h"
+
+#include <iostream>
+
+void Subject::attach(Observer *o)
+{
+       _observers.push_back(o);
+}
+
+void Subject::detach(Observer *o)
+{
+       vector<Observer*>::iterator it;
+       for(it = _observers.begin() ; it < _observers.end() ; it++) {
+               if (*it == o) {
+                       _observers.erase(it);
+                       break;
+               }
+       }
+}
+
+void Subject::notify(void)
+{
+       vector<Observer*>::iterator it;
+       Observer *curObserver;
+       it = _observers.begin();
+       while (it < _observers.end()) {
+               curObserver = *it;
+
+               DP_LOGD("[%s] Call Update",curObserver->name().c_str());
+               (*it)->update(this);
+
+               if (curObserver != *it)
+                       continue;
+
+               it++;
+       }
+}
+
+void Observer::update(Subject *s)
+{
+       call();
+}
+
+//Observer::Observer(updateFunction uf, void *data)
+/* For debug */
+Observer::Observer(updateFunction uf, void *data, const char *name)
+       : m_updateFunction(uf)
+       , m_userData(data)
+{
+       observerName = name;
+}
+
+void Observer::set(updateFunction uf, void *data)
+{
+       m_updateFunction = uf;
+       m_userData = data;
+}
+
+void Observer::clear(void)
+{
+       m_updateFunction = 0;
+       m_userData = 0;
+}
+
+void Observer::call(void)
+{
+       if (m_updateFunction)
+               m_updateFunction(m_userData);
+}
diff --git a/src/download-manager-history-db.cpp b/src/download-manager-history-db.cpp
new file mode 100644 (file)
index 0000000..3766584
--- /dev/null
@@ -0,0 +1,422 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-history-db.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      Manager for a download history DB
+ */
+
+#include <sstream>
+#include "download-manager-common.h"
+#include "download-manager-history-db.h"
+
+#define FINALIZE_ON_ERROR( stmt ) { \
+       DP_LOG("SQL error: %d", ret);\
+       if (sqlite3_finalize(stmt) != SQLITE_OK)\
+               DP_LOGE("sqlite3_finalize is failed.");\
+       close();\
+       return false; \
+}
+
+sqlite3 *DownloadHistoryDB::historyDb = NULL;
+
+DownloadHistoryDB::DownloadHistoryDB()
+{
+}
+
+DownloadHistoryDB::~DownloadHistoryDB()
+{
+}
+
+bool DownloadHistoryDB::open()
+{
+       int ret = 0;
+
+       DP_LOGD_FUNC();
+
+       close();
+
+       ret = db_util_open(DBDATADIR"/"HISTORYDB, &historyDb,
+               DB_UTIL_REGISTER_HOOK_METHOD);
+
+       if (ret != SQLITE_OK) {
+               DP_LOGE("open fail");
+               db_util_close(historyDb);
+               historyDb = NULL;
+               return false;
+       }
+
+       return isOpen();
+}
+
+void DownloadHistoryDB::close()
+{
+       DP_LOGD_FUNC();
+       if (historyDb) {
+               db_util_close(historyDb);
+               historyDb = NULL;
+       }
+}
+
+/* FIXME : Hitory entry limitation ?? */
+bool DownloadHistoryDB::addToHistoryDB(Item *item)
+{
+       int ret = 0;
+       sqlite3_stmt *stmt = NULL;
+
+       DP_LOG_FUNC();
+
+       if (!item) {
+               DP_LOGE("Item is NULL");
+               return false;
+       }
+
+       if (item->historyId() < 0) {
+               DP_LOGE("Cannot add to DB. Because historyId is invaild");
+               return false;
+       }
+
+       if (!open()) {
+               DP_LOGE("historyDB is NULL");
+               return false;
+       }
+
+       const string statement = "insert into history (historyid, downloadtype,\
+               contenttype, state, err, name, path, url, cookie, date) \
+               values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+
+       ret = sqlite3_prepare_v2(historyDb, statement.c_str(), -1, &stmt, NULL);
+
+       if (ret != SQLITE_OK)
+               FINALIZE_ON_ERROR(stmt);
+       /* binding values */
+       if (sqlite3_bind_int(stmt, 1, item->historyId()) != SQLITE_OK)
+               DP_LOGE("sqlite3_bind_int is failed.");
+       if (sqlite3_bind_int(stmt, 2, item->downloadType()) != SQLITE_OK)
+               DP_LOGE("sqlite3_bind_int is failed.");
+       if (sqlite3_bind_int(stmt, 3, item->contentType()) != SQLITE_OK)
+               DP_LOGE("sqlite3_bind_int is failed.");
+       if (sqlite3_bind_int(stmt, 4, item->state()) != SQLITE_OK)
+               DP_LOGE("sqlite3_bind_int is failed.");
+       if (sqlite3_bind_int(stmt, 5, item->errorCode()) != SQLITE_OK)
+               DP_LOGE("sqlite3_bind_int is failed.");
+       if (sqlite3_bind_text(stmt, 6, item->title().c_str(), -1, NULL) != SQLITE_OK)
+               DP_LOGE("sqlite3_bind_text is failed.");
+       if (sqlite3_bind_text(
+                       stmt, 7, item->registeredFilePath().c_str(), -1, NULL) != SQLITE_OK)
+               DP_LOGE("sqlite3_bind_text is failed.");
+       if (sqlite3_bind_text(stmt, 8, item->url().c_str(), -1, NULL) != SQLITE_OK)
+               DP_LOGE("sqlite3_bind_text is failed.");
+       if (sqlite3_bind_text(stmt, 9, item->cookie().c_str(), -1, NULL) != SQLITE_OK)
+               DP_LOGE("sqlite3_bind_text is failed.");
+       if (sqlite3_bind_double(stmt, 10, item->finishedTime()) != SQLITE_OK)
+               DP_LOGE("sqlite3_bind_double is failed.");
+       ret = sqlite3_step(stmt);
+
+       DP_LOGD("SQL return: %s", (ret == SQLITE_ROW || ret == SQLITE_OK)?"Success":"Fail");
+
+       close();
+
+       return ret == SQLITE_DONE;
+}
+
+bool DownloadHistoryDB::getCountOfHistory(int *count)
+{
+       int ret = 0;
+       sqlite3_stmt *stmt = NULL;
+
+       DP_LOG_FUNC();
+
+       if (!open()) {
+               DP_LOGE("historyDB is NULL");
+               return false;
+       }
+       ret = sqlite3_prepare_v2(historyDb, "select COUNT(*) from history", -1, &stmt, NULL);
+       if (ret != SQLITE_OK)
+               FINALIZE_ON_ERROR(stmt);
+
+       ret = sqlite3_step(stmt);
+       DP_LOGD("SQL return: %s", (ret == SQLITE_ROW || ret == SQLITE_OK)?"Success":"Fail");
+       if (ret == SQLITE_ROW) {
+               *count = sqlite3_column_int(stmt,0);
+               DP_LOGD("count[%d]",*count);
+       } else {
+               DP_LOGE("SQL query error");
+               *count = 0;
+       }
+
+       if (sqlite3_finalize(stmt) != SQLITE_OK)
+               DP_LOGE("sqlite3_finalize is failed.");
+       close();
+       return true;
+}
+
+bool DownloadHistoryDB::createRemainedItemsFromHistoryDB(int limit, int offset)
+{
+       int ret = 0;
+       stringstream limitStr;
+       stringstream offsetStr;
+       sqlite3_stmt *stmt = NULL;
+       string tmp;
+
+       DP_LOG_FUNC();
+
+       if (!open()) {
+               DP_LOGE("historyDB is NULL");
+               return false;
+       }
+       limitStr << limit;
+       offsetStr << offset;
+
+       tmp.append("select historyid, downloadtype, contenttype, state, err, ");
+       tmp.append("name, path, url, cookie, date from history order by ");
+       tmp.append("date DESC limit ");
+       tmp.append(limitStr.str());
+       tmp.append(" offset ");
+       tmp.append(offsetStr.str());
+       ret = sqlite3_prepare_v2(historyDb, tmp.c_str(), -1, &stmt, NULL);
+       if (ret != SQLITE_OK)
+               FINALIZE_ON_ERROR(stmt);
+
+       for (;;) {
+               ret = sqlite3_step(stmt);
+               if (ret == SQLITE_ROW) {
+                       const char *tempStr = NULL;
+                       string arg;
+                       string url;
+                       string cookie;
+                       Item *item = Item::createHistoryItem();
+                       if (!item) {
+                               DP_LOGE("Fail to create item");
+                               break;
+                       }
+                       item->setHistoryId(sqlite3_column_int(stmt,0));
+                       item->setDownloadType((DL_TYPE::TYPE)sqlite3_column_int(stmt,1));
+                       item->setContentType(sqlite3_column_int(stmt,2));
+                       item->setState((ITEM::STATE)sqlite3_column_int(stmt,3));
+                       item->setErrorCode((ERROR::CODE)sqlite3_column_int(stmt,4));
+                       tempStr = (const char *)(sqlite3_column_text(stmt,5));
+                       if (tempStr)
+                               arg = tempStr;
+                       else
+                               arg = string();
+                       item->setTitle(arg);
+                       tempStr = (const char *)(sqlite3_column_text(stmt,6));
+                       if (tempStr)
+                               arg = tempStr;
+                       else
+                               arg = string();
+                       item->setRegisteredFilePath(arg);
+                       tempStr = (const char *)(sqlite3_column_text(stmt,7));
+                       if (tempStr)
+                               url = tempStr;
+                       else
+                               url = string();
+                       tempStr = (const char *)(sqlite3_column_text(stmt,8));
+                       if (tempStr)
+                               cookie = tempStr;
+                       else
+                               cookie = string();
+                       item->setFinishedTime(sqlite3_column_double(stmt,9));
+                       item->attachHistoryItem();
+                       item->setRetryData(url, cookie);
+               } else
+                       break;
+       }
+       DP_LOGD("SQL error: %d", ret);
+
+       if (sqlite3_finalize(stmt) != SQLITE_OK)
+               DP_LOGE("sqlite3_finalize is failed.");
+
+       close();
+
+       if (ret == SQLITE_DONE || ret == SQLITE_ROW)
+               return true;
+       else
+               return false;
+}
+
+bool DownloadHistoryDB::createItemsFromHistoryDB()
+{
+       int ret = 0;
+       sqlite3_stmt *stmt = NULL;
+       string tmp;
+       stringstream limitStr;
+
+       DP_LOG_FUNC();
+
+       if (!open()) {
+               DP_LOGE("historyDB is NULL");
+               return false;
+       }
+       limitStr << LOAD_HISTORY_COUNT;
+       tmp.append("select historyid, downloadtype, contenttype, state, err, ");
+       tmp.append("name, path, url, cookie, date from history order by ");
+       tmp.append("date DESC limit ");
+       tmp.append(limitStr.str());
+       ret = sqlite3_prepare_v2(historyDb, tmp.c_str(), -1, &stmt, NULL);
+       if (ret != SQLITE_OK)
+               FINALIZE_ON_ERROR(stmt);
+
+       for (;;) {
+               ret = sqlite3_step(stmt);
+               if (ret == SQLITE_ROW) {
+                       const char *tempStr = NULL;
+                       string arg = string();
+                       string url = string();
+                       string cookie = string();
+                       Item *item = Item::createHistoryItem();
+                       if (!item) {
+                               DP_LOGE("Fail to create item");
+                               break;
+                       }
+                       item->setHistoryId(sqlite3_column_int(stmt,0));
+                       item->setDownloadType((DL_TYPE::TYPE)sqlite3_column_int(stmt,1));
+                       item->setContentType(sqlite3_column_int(stmt,2));
+                       item->setState((ITEM::STATE)sqlite3_column_int(stmt,3));
+                       item->setErrorCode((ERROR::CODE)sqlite3_column_int(stmt,4));
+                       tempStr = (const char *)(sqlite3_column_text(stmt,5));
+                       if (tempStr) {
+                               arg = tempStr;
+                               item->setTitle(arg);
+                       }
+                       tempStr = (const char *)(sqlite3_column_text(stmt,6));
+                       if (tempStr)
+                               arg = tempStr;
+                       item->setRegisteredFilePath(arg);
+                       tempStr = (const char *)(sqlite3_column_text(stmt,7));
+                       if (tempStr)
+                               url = tempStr;
+                       tempStr = (const char *)(sqlite3_column_text(stmt,8));
+                       if (tempStr)
+                               cookie = tempStr;
+                       item->setFinishedTime(sqlite3_column_double(stmt,9));
+                       item->attachHistoryItem();
+                       item->setRetryData(url, cookie);
+               } else
+                       break;
+       }
+       DP_LOGD("SQL error: %d", ret);
+
+       if (sqlite3_finalize(stmt) != SQLITE_OK)
+               DP_LOGE("sqlite3_finalize is failed.");
+       close();
+
+       if (ret == SQLITE_DONE || ret == SQLITE_ROW)
+               return true;
+       else
+               return false;
+}
+
+bool DownloadHistoryDB::deleteItem(unsigned int historyId)
+{
+       int ret = 0;
+       sqlite3_stmt *stmt = NULL;
+
+       DP_LOG_FUNC();
+
+       if (!open()) {
+               DP_LOGE("historyDB is NULL");
+               return false;
+       }
+
+       ret = sqlite3_prepare_v2(historyDb, "delete from history where historyid=?",
+               -1, &stmt, NULL);
+
+       if (ret != SQLITE_OK)
+               FINALIZE_ON_ERROR(stmt);
+       if (sqlite3_bind_int(stmt, 1, historyId) != SQLITE_OK)
+               DP_LOGE("sqlite3_bind_int is failed.");
+       ret = sqlite3_step(stmt);
+       if (ret != SQLITE_OK && ret != SQLITE_DONE)
+               FINALIZE_ON_ERROR(stmt);
+
+       if (sqlite3_finalize(stmt) != SQLITE_OK)
+               DP_LOGE("sqlite3_finalize is failed.");
+       close();
+       return true;
+}
+
+bool DownloadHistoryDB::deleteMultipleItem(queue <unsigned int> &q)
+{
+       int ret = 0;
+       unsigned int historyId = -1;
+       sqlite3_stmt *stmt = NULL;
+       char *errmsg = NULL;
+
+       DP_LOG_FUNC();
+
+       if (!open()) {
+               DP_LOGE("historyDB is NULL");
+               return false;
+       }
+       ret = sqlite3_exec(historyDb, "PRAGMA synchronous=OFF;\
+               PRAGMA count_changes=OFF; PRAGMA temp_store=memory;",
+               NULL, NULL, &errmsg);
+       if (SQLITE_OK != ret) {
+               sqlite3_free(errmsg);
+               close();
+               return false;
+       }
+
+       DP_LOGD("queue size[%d]",q.size());
+       while (!q.empty()) {
+               ret = sqlite3_prepare_v2(historyDb, "delete from history where historyid=?",
+                       -1, &stmt, NULL);
+               if (ret != SQLITE_OK)
+                       FINALIZE_ON_ERROR(stmt);
+               historyId = q.front();
+               q.pop();
+               if (sqlite3_bind_int(stmt, 1, historyId) != SQLITE_OK)
+                       DP_LOGE("sqlite3_bind_int is failed.");
+               ret = sqlite3_step(stmt);
+               if (ret != SQLITE_OK && ret != SQLITE_DONE)
+                       FINALIZE_ON_ERROR(stmt);
+       }
+
+       if (sqlite3_finalize(stmt) != SQLITE_OK)
+               DP_LOGE("sqlite3_finalize is failed.");
+       close();
+       return true;
+}
+
+bool DownloadHistoryDB::clearData(void)
+{
+       int ret = 0;
+       sqlite3_stmt *stmt = NULL;
+
+       DP_LOG_FUNC();
+
+       if (!open()) {
+               DP_LOGE("historyDB is NULL");
+               return false;
+       }
+
+       ret = sqlite3_prepare_v2(historyDb, "delete from history", -1, &stmt, NULL);
+       if (ret != SQLITE_OK)
+               FINALIZE_ON_ERROR(stmt);
+
+       ret = sqlite3_step(stmt);
+       if (ret != SQLITE_DONE)
+               FINALIZE_ON_ERROR(stmt);
+
+       if (sqlite3_finalize(stmt) != SQLITE_OK)
+               DP_LOGE("sqlite3_finalize is failed.");
+       close();
+       return true;
+}
+
diff --git a/src/download-manager-item.cpp b/src/download-manager-item.cpp
new file mode 100644 (file)
index 0000000..912a499
--- /dev/null
@@ -0,0 +1,559 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-item.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      item class for saving download data
+ */
+
+#include <iostream>
+#include <time.h>
+#include "download-manager-item.h"
+#include "download-manager-common.h"
+#include "download-manager-items.h"
+#include "download-manager-viewItem.h"
+#include "download-manager-history-db.h"
+#include "download-manager-network.h"
+
+Item::Item()
+       : m_state(ITEM::IDLE)
+       , m_errorCode(ERROR::NONE)
+       , m_historyId(-1)
+       , m_contentType(DP_CONTENT_UNKOWN)
+       , m_finishedTime(0)
+       , m_downloadType(DL_TYPE::TYPE_NONE)
+       , m_gotFirstData(false)
+{
+// FIXME Later : init private members
+}
+
+Item::Item(DownloadRequest &rRequest)
+       : m_state(ITEM::IDLE)
+       , m_errorCode(ERROR::NONE)
+       , m_historyId(-1)
+       , m_contentType(DP_CONTENT_UNKOWN)
+       , m_finishedTime(0)
+       , m_downloadType(DL_TYPE::TYPE_NONE)
+       , m_gotFirstData(false)
+{
+       m_title = S_("IDS_COM_BODY_NO_NAME");
+       m_iconPath = DP_UNKNOWN_ICON_PATH;
+       m_aptr_request = auto_ptr<DownloadRequest>(new DownloadRequest(rRequest));      // FIXME ???
+}
+
+Item::~Item()
+{
+       DP_LOGD_FUNC();
+}
+
+void Item::create(DownloadRequest &rRequest)
+{
+//     DP_LOGD_FUNC();
+
+       Item *newItem = new Item(rRequest);
+
+       Items &items = Items::getInstance();
+       items.attachItem(newItem);
+
+       ViewItem::create(newItem);
+       DP_LOGD("newItem[%p]",newItem);
+
+       newItem->download();
+}
+
+Item *Item::createHistoryItem()
+{
+       string url = string();
+       string cookie = string();
+       DownloadRequest request(url,cookie);
+       Item *newItem = new Item(request);
+//     DP_LOGD_FUNC();
+
+       DP_LOGD("new History Item[%p]",newItem);
+
+       return newItem;
+}
+
+void Item::attachHistoryItem()
+{
+       Items &items = Items::getInstance();
+
+       DP_LOGD("attach History Item[%p]",this);
+       items.attachItem(this);
+       ViewItem::create(this);
+       extractIconPath();
+}
+
+void Item::destroy()
+{
+//     DP_LOG_FUNC();
+       // FIXME prohibit to destroy if downloading
+       if (!isFinished()) {
+               DP_LOGE("Cannot delete this item. State[%d]",m_state);
+               return;
+       }
+       DP_LOGD("Item::destroy() notify()");
+
+       setState(ITEM::DESTROY);
+       notify();
+//     DP_LOG("Item::destroy() notify()... END");
+       m_aptr_downloadItem->deSubscribe(m_aptr_downloadObserver.get());
+       if (m_aptr_downloadObserver.get())
+               m_aptr_downloadObserver->clear();
+       else
+               DP_LOGE("download observer pointer is NULL");
+       /* When deleting item after download is failed */
+       if (m_aptr_netEventObserver.get()) {
+               NetMgr &netMgrInstance = NetMgr::getInstance();
+               netMgrInstance.deSubscribe(m_aptr_netEventObserver.get());
+       }
+       Items::getInstance().detachItem(this);
+}
+
+void Item::deleteFromDB()
+{
+       DownloadHistoryDB::deleteItem(m_historyId);
+}
+
+void Item::download()
+{
+       NetMgr &netMgrInstance = NetMgr::getInstance();
+
+//     DP_LOGD_FUNC();
+
+       setState(ITEM::REQUESTING);
+
+       createSubscribeData();
+
+       netMgrInstance.subscribe(m_aptr_netEventObserver.get());
+
+       m_aptr_downloadItem->start(false);
+
+       DP_LOG("Item::download() notify()");
+       notify();
+}
+
+void Item::createSubscribeData() // autoptr's variable of this class.
+{
+       m_aptr_downloadObserver = auto_ptr<Observer>(
+               new Observer(updateCBForDownloadObserver, this, "downloadItemObserver"));
+       m_aptr_netEventObserver = auto_ptr<Observer>(
+               new Observer(netEventCBObserver, this, "netMgrObserver"));
+       m_aptr_downloadItem = auto_ptr<DownloadItem>(new DownloadItem(m_aptr_request));
+       if (!m_aptr_downloadItem.get()) {
+               DP_LOGE("Fail to create download item");
+               return;
+       }
+       m_aptr_downloadItem->subscribe(m_aptr_downloadObserver.get());
+}
+
+void Item::startUpdate(void)
+{
+       if (m_gotFirstData) {
+               setState(ITEM::DOWNLOADING);
+               if (!registeredFilePath().empty())
+                       /* need to parse title again, because installed path can be changed */
+                       extractTitle();
+               return;
+       }
+
+       DP_LOGD_FUNC();
+
+       if (!m_aptr_downloadItem.get()) {
+               DP_LOGE("Fail to get download item");
+               return;
+       }
+       m_gotFirstData = true;
+//     setState(ITEM::DOWNLOADING);
+       setState(ITEM::RECEIVING_DOWNLOAD_INFO);
+
+       extractTitle();
+       DownloadUtil &util = DownloadUtil::getInstance();
+       m_contentType = util.getContentType(
+               m_aptr_downloadItem->mimeType().c_str(), filePath().c_str());
+       extractIconPath();
+}
+
+void Item::updateFromDownloadItem(void)
+{
+//     DP_LOGD_FUNC();
+       DownloadUtil &util = DownloadUtil::getInstance();
+
+       switch (m_aptr_downloadItem->state()) {
+       case DL_ITEM::STARTED:
+               break;
+       case DL_ITEM::UPDATING:
+               startUpdate();
+               break;
+       case DL_ITEM::COMPLETE_DOWNLOAD:
+               setState(ITEM::REGISTERING_TO_SYSTEM);
+               break;
+       case DL_ITEM::SUSPENDED:
+               setState(ITEM::SUSPENDED);
+               m_aptr_downloadItem->resume();
+               break;
+       case DL_ITEM::RESUMED:
+               //setState(ITEM::RESUMED);
+               break;
+       case DL_ITEM::FINISHED:
+               setState(ITEM::FINISH_DOWNLOAD);
+               /* need to parse title again, because installed path can be changed */
+               extractTitle();
+               handleFinishedItem();
+               util.registerContent(registeredFilePath());
+               break;
+       case DL_ITEM::CANCELED:
+               setState(ITEM::CANCEL);
+               handleFinishedItem();
+               break;
+       case DL_ITEM::FAILED:
+               setState(ITEM::FAIL_TO_DOWNLOAD);
+               setErrorCode(m_aptr_downloadItem->errorCode());
+               handleFinishedItem();
+               break;
+       default:
+               break;
+       }
+
+       DP_LOGD("Item[%p]::updateFromDownloadItem() notify() dl_state[%d]state[%d]", this, m_aptr_downloadItem->state(), state());
+       notify();
+}
+void Item::handleFinishedItem()
+{
+       createHistoryId();
+       m_finishedTime = time(NULL);
+       DownloadHistoryDB::addToHistoryDB(this);
+       /* If download is finished, it is not need to get network event */
+       if (m_aptr_netEventObserver.get()) {
+               NetMgr &netMgrInstance = NetMgr::getInstance();
+               netMgrInstance.deSubscribe(m_aptr_netEventObserver.get());
+       }
+}
+
+const char *Item::getErrorMessage(void)
+{
+       switch (m_errorCode) {
+       case ERROR::NETWORK_FAIL:
+               return S_("IDS_COM_POP_CONNECTION_FAILED");
+
+       case ERROR::INVALID_URL:
+               return S_("IDS_COM_POP_INVALID_URL");
+
+       case ERROR::NOT_ENOUGH_MEMORY:
+               return S_("IDS_COM_POP_NOT_ENOUGH_MEMORY");
+
+       case ERROR::FAIL_TO_INSTALL:
+               return S_("IDS_COM_POP_SAVING_FAILED");
+       case ERROR::UNKNOWN:
+       default:
+               return S_("IDS_COM_POP_FAILED") ;
+       }
+}
+
+void Item::extractTitle(void)
+{
+       if (!m_aptr_downloadItem.get()) {
+               DP_LOGE("Fail to get download item");
+               return;
+       }
+       size_t found = 0;
+       string path;
+       if (!registeredFilePath().empty()) {
+               path = registeredFilePath();
+               found = path.find_last_of("/");
+               if (found != string::npos)
+                       m_title = path.substr(found+1);
+       } else if (!contentName().empty()){
+               m_title = contentName();
+       }
+       DP_LOGD("title [%s] contentName [%s]", m_title.c_str(),contentName().c_str());
+}
+
+void Item::extractIconPath()
+{
+       // FIXME Later : change 2 dimension array??
+       switch(m_contentType) {
+       case DP_CONTENT_IMAGE :
+               m_iconPath = DP_IMAGE_ICON_PATH;
+               break;
+       case DP_CONTENT_VIDEO :
+               m_iconPath = DP_VIDEO_ICON_PATH;
+               break;
+       case DP_CONTENT_MUSIC:
+               m_iconPath = DP_MUSIC_ICON_PATH;
+               break;
+       case DP_CONTENT_PDF:
+               m_iconPath = DP_PDF_ICON_PATH;
+               break;
+       case DP_CONTENT_WORD:
+               m_iconPath = DP_WORD_ICON_PATH;
+               break;
+       case DP_CONTENT_PPT:
+               m_iconPath = DP_PPT_ICON_PATH;
+               break;
+       case DP_CONTENT_EXCEL:
+               m_iconPath = DP_EXCEL_ICON_PATH;
+               break;
+       case DP_CONTENT_HTML:
+               m_iconPath = DP_HTML_ICON_PATH;
+               break;
+       case DP_CONTENT_TEXT:
+               m_iconPath = DP_TEXT_ICON_PATH;
+               break;
+       case DP_CONTENT_RINGTONE:
+               m_iconPath = DP_RINGTONE_ICON_PATH;
+               break;
+       case DP_CONTENT_DRM:
+               m_iconPath = DP_DRM_ICON_PATH;
+               break;
+       case DP_CONTENT_JAVA:
+               m_iconPath = DP_JAVA_ICON_PATH;
+               break;
+       case DP_CONTENT_UNKOWN:
+       default:
+               m_iconPath = DP_UNKNOWN_ICON_PATH;
+               break;
+       }
+}
+
+void Item::updateCBForDownloadObserver(void *data)
+{
+       DP_LOGD_FUNC();
+       if (data)
+               static_cast<Item*>(data)->updateFromDownloadItem();
+}
+
+void Item::netEventCBObserver(void *data)
+{
+       /* It is only considerd that there is one network event which is suspend now.
+        * If other network evnet is added,
+        * it is needed to add function accroding to what kinds of network event is
+       **/
+       DP_LOG_FUNC();
+       if (data)
+               static_cast<Item*>(data)->suspend();
+}
+
+bool Item::play()
+{
+       return m_fileOpener.openFile(registeredFilePath(), m_contentType);
+}
+
+/* Test code */
+const char *Item::stateStr(void)
+{
+       switch((int)state()) {
+       case ITEM::IDLE:
+               return "IDLE";
+       case ITEM::REQUESTING:
+               return "REQUESTING";
+       case ITEM::PREPARE_TO_RETRY:
+               return "PREPARE_TO_RETRY";
+       case ITEM::RECEIVING_DOWNLOAD_INFO:
+               return "RECEIVING_DOWNLOAD_INFO";
+       case ITEM::DOWNLOADING:
+               return "DOWNLOADING";
+       case ITEM::REGISTERING_TO_SYSTEM:
+               return "REGISTERING_TO_SYSTEM";
+       case ITEM::SUSPENDED:
+               return "SUSPENDED";
+       case ITEM::FINISH_DOWNLOAD:
+               return "FINISH_DOWNLOAD";
+       case ITEM::FAIL_TO_DOWNLOAD:
+               return "FAIL_TO_DOWNLOAD";
+       case ITEM::CANCEL:
+               return "CANCEL";
+       case ITEM::PLAY:
+               return "PLAY";
+       case ITEM::DESTROY:
+               return "DESTROY";
+       }
+       return "Unknown State";
+}
+
+DL_TYPE::TYPE Item::downloadType()
+{
+       if (m_downloadType == DL_TYPE::TYPE_NONE) {
+               if (!m_aptr_downloadItem.get()) {
+                       DP_LOGE("Fail to get download item");
+                       return DL_TYPE::TYPE_NONE;
+               }
+               m_downloadType = m_aptr_downloadItem->downloadType();
+       }
+       return m_downloadType;
+}
+
+string &Item::registeredFilePath()
+{
+       if (m_registeredFilePath.empty()) {
+               if (!m_aptr_downloadItem.get()) {
+                       DP_LOGE("Fail to get download item");
+                       return m_emptyString;
+               }
+               m_registeredFilePath = m_aptr_downloadItem->registeredFilePath();
+       }
+       return m_registeredFilePath;
+}
+
+string &Item::url()
+{
+       if (m_url.empty()) {
+               if (!m_aptr_downloadItem.get()) {
+                       DP_LOGE("Fail to get download item");
+                       return m_emptyString;
+               }
+               m_url = m_aptr_downloadItem->url();
+       }
+       return m_url;
+}
+
+string &Item::cookie()
+{
+       if (m_cookie.empty()) {
+               if (!m_aptr_downloadItem.get()) {
+                       DP_LOGE("Fail to get download item");
+                       return m_emptyString;
+               }
+               m_cookie = m_aptr_downloadItem->cookie();
+       }
+       return m_cookie;
+}
+
+
+void Item::createHistoryId()
+{
+       int count = 0;
+       unsigned tempId = time(NULL);
+       while (isExistedHistoryId(tempId)) {
+               srand((unsigned)(time(NULL)));
+               tempId = rand();
+               count++;
+               if (count > 100) {
+                       DP_LOGE("Fail to create unique ID");
+                       tempId = -1;
+                       break;
+               }
+               DP_LOGD("random historyId[%ld]", m_historyId);
+       }
+       m_historyId = tempId;
+}
+
+bool Item::isExistedHistoryId(unsigned int id)
+{
+       Items &items = Items::getInstance();
+       return items.isExistedHistoryId(id);
+}
+
+void Item::setRetryData(string &url, string &cookie)
+{
+
+       m_url = url;
+       m_cookie = cookie;
+       m_aptr_request->setUrl(url);
+       m_aptr_request->setCookie(cookie);
+
+       createSubscribeData();
+
+}
+
+bool Item::retry()
+{
+       DP_LOG_FUNC();
+       if (m_aptr_downloadItem.get()) {
+               NetMgr &netMgrInstance = NetMgr::getInstance();
+               setState(ITEM::PREPARE_TO_RETRY);
+               notify();
+               DownloadHistoryDB::deleteItem(m_historyId);
+               netMgrInstance.subscribe(m_aptr_netEventObserver.get());
+               m_historyId = -1;
+               m_aptr_downloadItem->retry();
+               return true;
+       } else {
+               m_state = ITEM::FAIL_TO_DOWNLOAD;
+               return false;
+       }
+}
+
+void Item::clearForRetry()
+{
+       m_state = ITEM::IDLE;
+       m_errorCode = ERROR::NONE;
+       m_contentType = DP_CONTENT_UNKOWN;
+       m_finishedTime = 0;
+       m_downloadType = DL_TYPE::TYPE_NONE;
+       m_gotFirstData = false;
+}
+
+bool Item::isFinished()
+{
+       bool ret = false;
+       switch (m_state) {
+       case ITEM::FINISH_DOWNLOAD:
+       case ITEM::FAIL_TO_DOWNLOAD:
+       case ITEM::CANCEL:
+       case ITEM::PLAY:
+       case ITEM::DESTROY:
+               ret = true;
+               break;
+       default:
+               ret = false;
+               break;
+       }
+       return ret;
+}
+
+bool Item::isFinishedWithErr()
+{
+       bool ret = false;
+       switch (m_state) {
+       case ITEM::FAIL_TO_DOWNLOAD:
+       case ITEM::CANCEL:
+               ret = true;
+               break;
+       default:
+               ret = false;
+               break;
+       }
+       return ret;
+}
+
+bool Item::isPreparingDownload()
+{
+       bool ret = false;
+       switch (m_state) {
+       case ITEM::IDLE:
+       case ITEM::REQUESTING:
+       case ITEM::PREPARE_TO_RETRY:
+               ret = true;
+               break;
+       default:
+               ret = false;
+               break;
+       }
+       return ret;
+
+}
+
+bool Item::isCompletedDownload()
+{
+       if (isPreparingDownload() ||
+                       m_state == ITEM::DOWNLOADING)
+               return false;
+       else
+               return true;
+}
+
diff --git a/src/download-manager-items.cpp b/src/download-manager-items.cpp
new file mode 100644 (file)
index 0000000..4e11734
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-items.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      Interface API with item list
+ */
+#include "download-manager-items.h"
+
+void Items::attachItem(Item *item)
+{
+       m_items.push_back(item);
+}
+
+void Items::detachItem(Item *item)
+{
+       vector<Item *>::iterator it;
+       for (it = m_items.begin() ; it < m_items.end() ; it++) {
+               if (*it == item) {
+                       m_items.erase(it);
+                       delete item;
+               }
+       }
+}
+
+bool Items::isExistedHistoryId(unsigned int id)
+{
+       vector <Item *>::iterator it;
+       for (it = m_items.begin(); it < m_items.end(); it++) {
+               if ((*it)->historyId() == id ) {
+                       DP_LOGD("historyId[%ld],title[%s]",
+                               (*it)->historyId(), (*it)->title().c_str());
+                       return true;
+               }
+       }
+       return false;
+}
+
diff --git a/src/download-manager-network.cpp b/src/download-manager-network.cpp
new file mode 100644 (file)
index 0000000..859f7b2
--- /dev/null
@@ -0,0 +1,278 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+/**
+ * @file       download-manager-network.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      Download netowkr manager
+ */
+
+#include <stdlib.h>
+#include "download-manager-common.h"
+#include "download-manager-network.h"
+
+enum {
+       NET_INACTIVE = 0,
+       NET_WIFI_ACTIVE,
+       NET_CELLULAR_ACTIVE
+};
+
+NetMgr::NetMgr()
+       :m_handle(NULL)
+{
+}
+
+NetMgr::~NetMgr()
+{
+}
+
+void NetMgr::initNetwork()
+{
+       if (connection_create(&m_handle) < 0) {
+               DP_LOGE("Fail to create network handle");
+               return;
+       }
+
+       if (connection_set_type_changed_cb(m_handle, netTypeChangedCB, NULL)
+                       < 0) {
+               DP_LOGE("Fail to register network state changed cb");
+               return;
+       }
+       if (connection_set_ip_address_changed_cb(m_handle, netConfigChangedCB, NULL)
+                       < 0) {
+               DP_LOGE("Fail to register ip address changed cb");
+               return;
+       }
+}
+
+void NetMgr::deinitNetwork()
+{
+       if (connection_unset_type_changed_cb(m_handle) < 0) {
+               DP_LOGE("Fail to unregister network state changed cb");
+       }
+       if (connection_unset_ip_address_changed_cb(m_handle) < 0) {
+               DP_LOGE("Fail to unregister ip address changed cb");
+       }
+       if (connection_destroy(m_handle) < 0) {
+               DP_LOGE("Fail to destroy network handle");
+       }
+}
+
+int NetMgr::getConnectionState()
+{
+       connection_type_e type = CONNECTION_TYPE_DISCONNECTED;
+       int ret = 0;
+
+       if (!m_handle) {
+               DP_LOGE("handle is NULL");
+               return NET_INACTIVE;
+       }
+       if (connection_get_type(m_handle, &type) < 0) {
+               DP_LOGE(" Fail to get network status");
+               return NET_INACTIVE;
+       }
+
+       switch (type) {
+       case CONNECTION_TYPE_DISCONNECTED:
+               DP_LOG("CONNECTION_NETWORK_STATE_DISCONNECTED");
+               ret = NET_INACTIVE;
+               break;
+       case CONNECTION_TYPE_WIFI:
+               DP_LOG("CONNECTION_NETWORK_STATE_WIFI");
+               ret = getCellularStatus();
+               break;
+       case CONNECTION_TYPE_CELLULAR:
+               DP_LOG("CONNECTION_NETWORK_STATE_CELLULAR");
+               ret = getWifiStatus();
+               break;
+       default:
+               DP_LOGE("Cannot enter here");
+               ret = NET_INACTIVE;
+               break;
+       }
+       return ret;
+}
+
+int NetMgr::getCellularStatus()
+{
+       connection_cellular_state_e status = CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE;
+       int ret = 0;
+
+       if (!m_handle) {
+               DP_LOGE("handle is NULL");
+               return NET_INACTIVE;
+       }
+
+       if (connection_get_cellular_state(m_handle, &status) < 0) {
+               DP_LOGE(" Fail to get cellular status");
+               return NET_INACTIVE;
+       }
+
+       switch(status) {
+       case CONNECTION_CELLULAR_STATE_AVAILABLE:
+               DP_LOG("CONNECTION_CELLULAR_STATE_AVAILABLE");
+               ret = NET_CELLULAR_ACTIVE;
+               break;
+       case CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE:
+               DP_LOG("CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE");
+               ret = NET_INACTIVE;
+               break;
+       case CONNECTION_CELLULAR_STATE_FLIGHT_MODE:
+               DP_LOG("CONNECTION_CELLULAR_STATE_FLIGHT_MODE");
+               ret = NET_INACTIVE;
+               break;
+       case CONNECTION_CELLULAR_STATE_ROAMING_OFF:
+               DP_LOG("CONNECTION_CELLULAR_STATE_ROAMING_OFF");
+               ret = NET_INACTIVE;
+               break;
+       case CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE:
+               DP_LOG("CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE");
+               ret = NET_INACTIVE;
+               break;
+       default:
+               DP_LOGE("Cannot enter here");
+               ret = NET_INACTIVE;
+               break;
+       }
+       return ret;
+
+}
+
+int NetMgr::getWifiStatus()
+{
+       connection_wifi_state_e status = CONNECTION_WIFI_STATE_DEACTIVATED;
+       int ret = 0;
+
+       if (!m_handle) {
+               DP_LOGE("handle is NULL");
+               return NET_INACTIVE;
+       }
+
+       if (connection_get_wifi_state(m_handle, &status) < 0) {
+               DP_LOGE(" Fail to get wifi status");
+               return NET_INACTIVE;
+       }
+
+       switch(status) {
+       case CONNECTION_WIFI_STATE_CONNECTED:
+               DP_LOG("CONNECTION_WIFI_STATE_CONNECTED");
+               ret = NET_WIFI_ACTIVE;
+               break;
+       case CONNECTION_WIFI_STATE_DISCONNECTED:
+               DP_LOG("CONNECTION_WIFI_STATE_DISCONNECTED");
+               ret = NET_INACTIVE;
+               break;
+       case CONNECTION_WIFI_STATE_DEACTIVATED:
+               DP_LOG("CONNECTION_WIFI_STATE_DEACTIVATED");
+               ret = NET_INACTIVE;
+               break;
+       default:
+               DP_LOGE("Cannot enter here");
+               ret = NET_INACTIVE;
+               break;
+       }
+       return ret;
+}
+
+void NetMgr::netTypeChanged()
+{
+       int changedStatus = NET_INACTIVE;
+       changedStatus = getConnectionState();
+       DP_LOG("Previous[%d] Changed[%d]", m_netStatus, changedStatus);
+       if (m_netStatus != changedStatus) {
+               if (changedStatus == NET_INACTIVE)
+                       DP_LOG("Netowrk is disconnected");
+               else
+                       DP_LOG("Network is connected");
+               m_netStatus = changedStatus;
+       } else {
+               DP_LOG("Network berer type is changed. ex.3G->WIFI");
+       }
+}
+
+/* This routine should be operated in case of downloading state.
+ * After the download is finished, network event handler should be removed.
+ */
+void NetMgr::netConfigChanged(string ipAddr)
+{
+
+       DP_LOG_FUNC();
+
+       if (ipAddr.length() > 1) {/* network is connected */
+               getProxy();
+               getIPAddress();
+               /* This notify is only for suspend event.
+                * If othere network event is added, it is needed to save event types
+                * and get function for it
+               **/
+               notify();
+       } else {
+               DP_LOGE("Network connection is disconnected");
+       }
+}
+
+void NetMgr::getProxy()
+{
+       char *proxy = NULL;
+       connection_address_family_e family = CONNECTION_ADDRESS_FAMILY_IPV4;
+
+       if (!m_handle) {
+               DP_LOGE("handle is NULL");
+               return;
+       }
+       if (connection_get_proxy(m_handle, family, &proxy) < 0) {
+               DP_LOGE("Fail to get ip address");
+               return;
+       }
+       if (proxy) {
+               DP_LOG("===== Proxy address[%s] =====", proxy);
+               free(proxy);
+               proxy = NULL;
+       }
+}
+
+void NetMgr::getIPAddress()
+{
+       char *ipAddr = NULL;
+       connection_address_family_e family = CONNECTION_ADDRESS_FAMILY_IPV4;
+       if (!m_handle) {
+               DP_LOGE("handle is NULL");
+               return;
+       }
+       if (connection_get_ip_address(m_handle, family, &ipAddr) < 0) {
+               DP_LOGE("Fail to get ip address");
+               return;
+       }
+       if (ipAddr) {
+               DP_LOG("===== IP address[%s] =====", ipAddr);
+               free(ipAddr);
+               ipAddr= NULL;
+       }
+}
+
+void NetMgr::netTypeChangedCB(connection_type_e state, void *data)
+{
+       NetMgr inst = NetMgr::getInstance();
+       inst.netTypeChanged();
+}
+
+void NetMgr::netConfigChangedCB(const char *ip, const char *ipv6,
+               void *data)
+{
+       string ipAddr = ip;
+       NetMgr inst = NetMgr::getInstance();
+       inst.netConfigChanged(ipAddr);
+}
+
diff --git a/src/download-manager-util.cpp b/src/download-manager-util.cpp
new file mode 100644 (file)
index 0000000..1b09d7e
--- /dev/null
@@ -0,0 +1,240 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/*
+ * @file       download-manager-util.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief   Utility APIs and interface with content player
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include "aul.h"
+#include "xdgmime.h"
+#include "app_service.h"
+#include "media_content.h"
+#include "media_info.h"
+
+#include "download-manager-util.h"
+
+struct MimeTableType
+{
+       const char *mime;
+       int contentType;
+};
+
+#define MAX_MIME_TABLE_NUM 22
+const char *ambiguousMIMETypeList[] = {
+               "text/plain",
+               "application/octet-stream"
+};
+
+struct MimeTableType MimeTable[]={
+               // PDF
+               {"application/pdf",DP_CONTENT_PDF},
+               // word
+               {"application/msword",DP_CONTENT_WORD},
+               {"application/vnd.openxmlformats-officedocument.wordprocessingml.document",DP_CONTENT_WORD},
+               // ppt
+               {"application/vnd.ms-powerpoint",DP_CONTENT_PPT},
+               {"application/vnd.openxmlformats-officedocument.presentationml.presentation",DP_CONTENT_PPT},
+               // excel
+               {"application/vnd.ms-excel",DP_CONTENT_EXCEL},
+               {"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",DP_CONTENT_EXCEL},
+               // html
+               {"text/html",DP_CONTENT_HTML},
+               // txt
+               {"text/txt",DP_CONTENT_TEXT},
+               {"text/palin",DP_CONTENT_TEXT},
+               // ringtone
+               {"text/x-iMelody",DP_CONTENT_RINGTONE},//10
+               {"application/x-smaf",DP_CONTENT_RINGTONE},
+               {"audio/midi",DP_CONTENT_RINGTONE},
+               {"audio/AMR",DP_CONTENT_RINGTONE},
+               {"audio/AMR-WB",DP_CONTENT_RINGTONE},
+               {"audio/x-xmf",DP_CONTENT_RINGTONE},
+               // DRM
+               {"application/vnd.oma.drm.content",DP_CONTENT_DRM},
+               {"application/vnd.oma.drm.message",DP_CONTENT_DRM},
+               // JAVA
+               {"application/x-java-archive",DP_CONTENT_JAVA},
+               {"application/java-archive",DP_CONTENT_JAVA},
+               // SVG
+               {"image/svg+xml",DP_CONTENT_SVG}, //20
+               // FLASH
+               {"application/x-shockwave-flash",DP_CONTENT_FLASH}
+};
+
+bool FileOpener::openFile(string &path, int contentType)
+{
+       service_h handle = NULL;
+       string filePath;
+       DP_LOG_FUNC();
+
+       if (path.empty())
+               return false;
+
+       DP_LOG("path [%s]", path.c_str());
+       if (service_create(&handle) < 0) {
+               DP_LOGE("Fail to create service handle");
+               return false;
+       }
+
+       if (!handle) {
+               DP_LOGE("service handle is null");
+               return false;
+       }
+
+       if (service_set_operation(handle, SERVICE_OPERATION_VIEW) < 0) {
+               DP_LOGE("Fail to set service operation");
+               service_destroy(handle);
+               return false;
+       }
+
+       if (contentType == DP_CONTENT_HTML) {
+               filePath = "file://";
+               filePath.append(path.c_str());
+       } else {
+               filePath = path;
+       }
+       if (service_set_uri(handle, filePath.c_str()) < 0) {
+               DP_LOGE("Fail to set uri");
+               service_destroy(handle);
+               return false;
+       }
+
+       if (service_send_launch_request(handle, NULL, NULL) < 0) {
+               DP_LOGE("Fail to launch service");
+               service_destroy(handle);
+               return false;
+       }
+
+       service_destroy(handle);
+
+       return true;
+}
+
+DownloadUtil::DownloadUtil()
+{
+}
+
+int DownloadUtil::getContentType(const char *mime, const char *filePath)
+{
+       int i = 0;
+       int type = DP_CONTENT_UNKOWN;
+       int ret = 0;
+       char tempMime[MAX_FILE_PATH_LEN] = {0,};
+       DP_LOGD_FUNC();
+       if (mime == NULL || strlen(mime) < 1)
+               return DP_CONTENT_UNKOWN;
+
+       DP_LOG("mime[%s]",mime);
+       strncpy(tempMime, mime, MAX_FILE_PATH_LEN-1);
+       if (isAmbiguousMIMEType(mime)) {
+               if (filePath) {
+                       memset(tempMime, 0x00, MAX_FILE_PATH_LEN);
+                       ret = aul_get_mime_from_file(filePath,tempMime,sizeof(tempMime));
+                       if (ret < AUL_R_OK )
+                               strncpy(tempMime, mime, MAX_FILE_PATH_LEN-1);
+                       else
+                               DP_LOG("mime from extension name[%s]",tempMime);
+               }
+       }
+
+       /* Search a content type from mime table. */
+       for (i = 0; i < MAX_MIME_TABLE_NUM; i++)
+       {
+               //DP_LOG("TableMime[%d][%s]",i,MimeTable[i].mime);
+               if (strncmp(MimeTable[i].mime, tempMime, strlen(tempMime)) == 0){
+                       type = MimeTable[i].contentType;
+                       break;
+               }
+       }
+       /* If there is no mime at mime table, check the category with the first
+        *   domain of mime string
+        * ex) video/... => video type */
+       if (type == DP_CONTENT_UNKOWN)
+       {
+               const char *unaliasedMime = NULL;
+               /* unaliased_mimetype means representative mime among similar types */
+               unaliasedMime = xdg_mime_unalias_mime_type(tempMime);
+
+               if (unaliasedMime != NULL) {
+                       DP_LOG("unaliased mime type[%s]\n",unaliasedMime);
+                       if (strstr(unaliasedMime,"video/") != NULL)
+                               type = DP_CONTENT_VIDEO;
+                       else if (strstr(unaliasedMime,"audio/") != NULL)
+                               type = DP_CONTENT_MUSIC;
+                       else if (strstr(unaliasedMime,"image/") != NULL)
+                               type = DP_CONTENT_IMAGE;
+               }
+       }
+       DP_LOG("type[%d]\n",type);
+       return type;
+}
+
+bool DownloadUtil::isAmbiguousMIMEType(const char *mimeType)
+{
+
+       if (!mimeType)
+               return false;
+
+       int index = 0;
+       int listSize = sizeof(ambiguousMIMETypeList) / sizeof(const char *);
+       for (index = 0; index < listSize; index++) {
+               if (0 == strncmp(mimeType, ambiguousMIMETypeList[index],
+                               strlen(ambiguousMIMETypeList[index]))) {
+                       DP_LOG("It is ambiguous! [%s]", ambiguousMIMETypeList[index]);
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+void DownloadUtil::registerContent(string filePath)
+{
+       int ret = -1;
+       media_info_h info = NULL;
+
+       if (filePath.empty()) {
+               DP_LOGE("file path is NULL");
+               return;
+       }
+
+       DP_LOG("Register file [%s]", filePath.c_str());
+
+       ret = media_content_connect();
+       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+               DP_LOGE("Fail to connect media db");
+               return;
+       }
+
+       ret = media_info_insert_to_db(filePath.c_str(), &info);
+       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+               DP_LOGE("Fail to insert media db [%d]", ret);
+               media_content_disconnect();
+               return;
+       }
+
+       ret = media_content_disconnect();
+       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+               DP_LOGE("Fail to connect media db");
+       }
+       return;
+}
+
diff --git a/src/download-manager-view.cpp b/src/download-manager-view.cpp
new file mode 100644 (file)
index 0000000..b91e12a
--- /dev/null
@@ -0,0 +1,1256 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-view.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      UI manager class for download list view and delete view
+ */
+#include <sstream>
+#include <queue>
+#include "download-manager-view.h"
+#include "download-manager-history-db.h"
+#include "download-manager-downloadItem.h"
+
+static void destroy_window_cb(void *data, Evas_Object *obj, void *event);
+
+enum {
+       DOWNLOAD_NOTIFY_SELECTED,
+       DOWNLOAD_NOTIFY_DELETED
+};
+
+DownloadView::DownloadView(void)
+       : eoWindow(NULL)
+       , eoBackground(NULL)
+       , eoLayout(NULL)
+       , eoNaviBar(NULL)
+       , eoNaviBarItem(NULL)
+       , eoBackBtn(NULL)
+       , eoControlBar(NULL)
+       , eoCbItemDelete(NULL)
+       , eoCbItemCancel(NULL)
+       , eoCbItemEmpty(NULL)
+       , eoBoxLayout(NULL)
+       , eoBox(NULL)
+       , eoDldList(NULL)
+       , eoPopup(NULL)
+       , eoSelectAllLayout(NULL)
+       , eoAllCheckedBox(NULL)
+       , eoNotifyInfo(NULL)
+       , eoNotifyInfoLayout(NULL)
+       , m_allChecked(EINA_FALSE)
+#ifndef _TIZEN_PUBLIC
+       , m_sweepedItem(NULL)
+#endif
+       , m_viewItemCount(0)
+{
+// FIXME Later : init private members
+       DownloadEngine &engine = DownloadEngine::getInstance();
+       engine.initEngine();
+       DateUtil &inst = DateUtil::getInstance();
+       inst.updateLocale();
+       dldGenlistGroupStyle.item_style = "grouptitle";
+       dldGenlistGroupStyle.func.text_get = getGenlistGroupLabelCB;
+       dldGenlistGroupStyle.func.content_get = NULL;
+       dldGenlistGroupStyle.func.state_get = NULL;
+       dldGenlistGroupStyle.func.del = NULL;
+
+       m_today.setType(DATETIME::DATE_TYPE_TODAY);
+       m_yesterday.setType(DATETIME::DATE_TYPE_YESTERDAY);
+       m_previousDay.setType(DATETIME::DATE_TYPE_PREVIOUS);
+}
+
+DownloadView::~DownloadView()
+{
+       DP_LOG_FUNC();
+//     DownloadEngine &engine = DownloadEngine::getInstance();
+//     engine.deinitEngine();
+}
+
+Evas_Object *DownloadView::create(void)
+{
+       Evas_Object *window = NULL;
+       window = createWindow(PACKAGE);
+       if (!window)
+               return NULL;
+
+       createBackground(window);
+       createLayout(window);
+       setIndicator(window);
+       createView();
+
+       return window;
+}
+
+void DownloadView::destroy()
+{
+       DownloadEngine &engine = DownloadEngine::getInstance();
+       engine.deinitEngine();
+}
+
+void DownloadView::show()
+{
+       DP_LOG_FUNC();
+#ifdef _SILENT_LAUNCH
+       evas_object_show(eoWindow);
+#endif
+       elm_win_raise(eoWindow);
+       handleUpdateDateGroupType(NULL);
+}
+
+void DownloadView::hide()
+{
+       DP_LOG_FUNC();
+       removePopup();
+#ifndef _TIZEN_PUBLIC
+       cancelSweepEvent();
+#endif
+       destroyNotifyInfo();
+       if (isGenlistEditMode()) {
+               hideGenlistEditMode();
+       }
+#ifdef _SILENT_LAUNCH
+       evas_object_hide(eoWindow);
+#endif
+       elm_win_lower(eoWindow);
+}
+
+void DownloadView::activateWindow()
+{
+       if (!eoWindow)
+               create();
+
+       show();
+}
+
+#ifndef _TIZEN_PUBLIC
+void DownloadView::rotateWindow(int angle)
+{
+       if (angle >= 0)
+               elm_win_rotation_with_resize_set(eoWindow, angle);
+}
+#endif
+
+void DownloadView::showViewItem(int id, const char *title)
+{
+       DP_LOG_FUNC();
+}
+
+/* This is called by AUL view mode */
+void DownloadView::playContent(int id, const char *title)
+{
+       DP_LOG_FUNC();
+}
+
+void DownloadView::setIndicator(Evas_Object *window)
+{
+       elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
+}
+
+Evas_Object *DownloadView::createWindow(const char *windowName)
+{
+       eoWindow = elm_win_add(NULL, windowName, ELM_WIN_BASIC);
+       if (eoWindow) {
+               elm_win_title_set(eoWindow, __("IDS_BR_HEADER_DOWNLOAD_MANAGER"));
+               elm_win_borderless_set(eoWindow, EINA_TRUE);
+               elm_win_conformant_set(eoWindow, 1);
+               evas_object_smart_callback_add(eoWindow, "delete,request",
+                               destroy_window_cb,      static_cast<void*>(this));
+       }
+       return eoWindow;
+}
+
+Evas_Object *DownloadView::createBackground(Evas_Object *window)
+{
+       if (!window)
+               return NULL;
+
+       eoBackground = elm_bg_add(window);
+       if (eoBackground) {
+               evas_object_size_hint_weight_set(eoBackground, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               elm_win_resize_object_add(window, eoBackground);
+               evas_object_show(eoBackground);
+       } else {
+               DP_LOGE("Fail to create bg object");
+       }
+       return eoBackground;
+}
+
+Evas_Object *DownloadView::createLayout(Evas_Object *parent)
+{
+       if (!parent) {
+               DP_LOGE("Invalid Paramter");
+               return NULL;
+       }
+
+       eoLayout = elm_layout_add(parent);
+       if (eoLayout) {
+               if (!elm_layout_theme_set(eoLayout, "layout", "application", "default" ))
+                       DP_LOGE("Fail to set elm_layout_theme_set");
+
+               evas_object_size_hint_weight_set(eoLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               elm_win_resize_object_add(parent, eoLayout);
+
+               edje_object_signal_emit(elm_layout_edje_get(eoLayout), "elm,state,show,indicator", "elm");
+               evas_object_show(eoLayout);
+       } else {
+               DP_LOGE("Fail to create layout");
+       }
+       return eoLayout;
+}
+
+void DownloadView::createView()
+{
+       DP_LOG_FUNC();
+       createNaviBar();
+       createList();
+       if (m_viewItemCount < 1)
+               showEmptyView();
+}
+
+void DownloadView::createNaviBar()
+{
+       DP_LOGD_FUNC();
+       eoNaviBar = elm_naviframe_add(eoLayout);
+       elm_object_part_content_set(eoLayout, "elm.swallow.content", eoNaviBar);
+       createBackBtn();
+       createBox();
+       eoNaviBarItem = elm_naviframe_item_push(eoNaviBar,
+               __("IDS_BR_HEADER_DOWNLOAD_MANAGER"),eoBackBtn, NULL, eoBoxLayout, NULL);
+       createControlBar();
+       evas_object_show(eoNaviBar);
+}
+
+void DownloadView::createBackBtn()
+{
+       DP_LOGD_FUNC();
+       eoBackBtn = elm_button_add(eoNaviBar);
+       elm_object_style_set(eoBackBtn, "naviframe/end_btn/default");
+       evas_object_smart_callback_add(eoBackBtn, "clicked", backBtnCB,NULL);
+       evas_object_show(eoBackBtn);
+}
+
+void DownloadView::createControlBar()
+{
+       DP_LOGD_FUNC();
+
+       eoControlBar = elm_toolbar_add(eoNaviBar);
+       if (eoControlBar == NULL)
+               return;
+       elm_toolbar_shrink_mode_set(eoControlBar, ELM_TOOLBAR_SHRINK_EXPAND);
+       eoCbItemDelete = elm_toolbar_item_append(eoControlBar, NULL,
+               S_("IDS_COM_OPT_DELETE"), cbItemDeleteCB, eoNaviBar);
+       eoCbItemEmpty = elm_toolbar_item_append(eoControlBar, NULL, NULL, NULL, NULL);
+       elm_object_item_part_content_set(eoNaviBarItem, "controlbar",
+               eoControlBar);
+       elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
+       elm_object_item_disabled_set(eoCbItemEmpty, EINA_TRUE);
+       evas_object_show(eoControlBar);
+}
+
+void DownloadView::createBox()
+{
+       DP_LOGD_FUNC();
+       eoBoxLayout = elm_layout_add(eoNaviBar);
+       elm_layout_theme_set(eoBoxLayout, "layout", "application", "noindicator");
+       evas_object_size_hint_weight_set(eoBoxLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       eoBox = elm_box_add(eoBoxLayout);
+       elm_object_part_content_set(eoBoxLayout, "elm.swallow.content", eoBox );
+
+       evas_object_show(eoBox);
+       evas_object_show(eoBoxLayout);
+}
+
+void DownloadView::createList()
+{
+       //DP_LOGD_FUNC();
+       eoDldList = elm_genlist_add(eoBoxLayout);
+       DP_LOGD("create::eoDldList[%p]",eoDldList);
+/* When using ELM_LIST_LIMIT, the window size is broken at the landscape mode */
+       evas_object_size_hint_weight_set(eoDldList, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(eoDldList, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       elm_genlist_homogeneous_set(eoDldList, EINA_TRUE);
+       elm_genlist_block_count_set(eoDldList,8);
+
+#ifndef _TIZEN_PUBLIC
+       evas_object_smart_callback_add(eoDldList, "drag,start,right", sweepRightCB, NULL);
+       evas_object_smart_callback_add(eoDldList, "drag,start,left", sweepLeftCB, NULL);
+#endif
+       elm_box_pack_end(eoBox, eoDldList);
+       evas_object_show(eoDldList);
+}
+
+void destroy_window_cb(void *data, Evas_Object *obj, void *event)
+{
+       DP_LOG_FUNC();
+       elm_exit();
+}
+
+void DownloadView::changedRegion()
+{
+       DateUtil &inst = DateUtil::getInstance();
+       inst.updateLocale();
+       elm_genlist_realized_items_update(eoDldList);
+}
+
+void DownloadView::attachViewItem(ViewItem *viewItem)
+{
+       DP_LOG_FUNC();
+       if (m_viewItemCount < 1) {
+               hideEmptyView();
+               createList();
+       }
+       if (viewItem) {
+               addViewItemToGenlist(viewItem);
+               m_viewItemCount++;
+       }
+}
+
+void DownloadView::detachViewItem(ViewItem *viewItem)
+{
+       DP_LOG("delete viewItem[%p]",viewItem);
+       if (viewItem) {
+               delete viewItem;
+               m_viewItemCount--;
+       }
+       if (!isGenlistEditMode() &&
+                       (m_viewItemCount < 1))
+               showEmptyView();
+}
+
+void DownloadView::update()
+{
+       Elm_Object_Item *it = NULL;
+       DP_LOG_FUNC();
+       if (!eoDldList) {
+               DP_LOGE("download list is NULL");
+               return;
+       }
+       it = elm_genlist_first_item_get(eoDldList);
+       while (it) {
+               DP_LOGD("glItem[%p]",it);
+               elm_genlist_item_update(it);
+               it = elm_genlist_item_next_get(it);
+       }
+}
+
+void DownloadView::update(ViewItem *viewItem)
+{
+       if (!viewItem)
+               return;
+
+       DP_LOG("DownloadView::update viewItem [%p]", viewItem);
+       elm_genlist_item_update(viewItem->genlistItem());
+}
+
+void DownloadView::update(Elm_Object_Item *glItem)
+{
+       if (!glItem)
+               return;
+
+       DP_LOG("DownloadView::update glItem [%p]", glItem);
+       elm_genlist_item_update(glItem);
+}
+
+#ifndef _TIZEN_PUBLIC
+ViewItem *DownloadView::findViewItemForGenlistItem(Elm_Object_Item *glItem)
+{
+       Elm_Object_Item *it = NULL;
+       ViewItem *viewItem = NULL;
+       if (!eoDldList) {
+               DP_LOGE("download list is NULL");
+               return NULL;
+       }
+       it = elm_genlist_first_item_get(eoDldList);
+       while (it) {
+               /* don't search group item */
+               if (elm_genlist_item_select_mode_get(it) !=
+                               ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY && it == glItem) {
+                       viewItem = (ViewItem *)elm_object_item_data_get(it);
+                       break;
+               }
+               it = elm_genlist_item_next_get(it);
+       }
+
+       return viewItem;
+}
+#endif
+
+void DownloadView::addViewItemToGenlist(ViewItem *viewItem)
+{
+       DP_LOG_FUNC();
+       handleUpdateDateGroupType(viewItem);
+       createGenlistItem(viewItem);
+}
+
+void DownloadView::createGenlistItem(ViewItem *viewItem)
+{
+       Elm_Object_Item *glItem = NULL;
+       Elm_Object_Item *glGroupItem = NULL;
+       /* EAPI Elm_Object_Item *elm_genlist_item_prepend(
+        *      Evas_Object *obj,
+        *      const Elm_Genlist_Item_Class *itc,
+        *      const void *data,
+        *      Elm_Object_Item *parent,
+        *      Elm_Genlist_Item_Type flags,
+        *      Evas_Smart_Cb func,
+        *      const void *func_data) EINA_ARG_NONNULL(1); */
+       glGroupItem = getGenlistGroupItem(viewItem->dateGroupType());
+       DP_LOGD("group item[%p]",glGroupItem);
+       if (!glGroupItem) {
+               DateGroup *dateGrpObj = getDateGroupObj(viewItem->dateGroupType());
+               if (!viewItem->isFinished()) {
+                       glGroupItem = elm_genlist_item_prepend(
+                               eoDldList,
+                               &dldGenlistGroupStyle,
+                               static_cast<const void*>(dateGrpObj),
+                               NULL,
+                               ELM_GENLIST_ITEM_GROUP,
+                               NULL,
+                               NULL);
+               } else {
+                       /* Download History Item */
+                       glGroupItem = elm_genlist_item_append(
+                               eoDldList,
+                               &dldGenlistGroupStyle,
+                               static_cast<const void*>(dateGrpObj),
+                               NULL,
+                               ELM_GENLIST_ITEM_GROUP,
+                               NULL,
+                               NULL);
+               }
+               if (!glGroupItem)
+                       DP_LOGE("Fail to add a genlist group item");
+               else
+                       elm_genlist_item_select_mode_set(glGroupItem,
+                               ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+               setGenlistGroupItem(viewItem->dateGroupType(), glGroupItem);
+       }
+       increaseGenlistGroupCount(viewItem->dateGroupType());
+       if (!viewItem->isFinished()) {
+               glItem = elm_genlist_item_insert_after(
+                       eoDldList,
+                       viewItem->elmGenlistStyle(),
+                       static_cast<const void*>(viewItem),
+                       glGroupItem,
+                       glGroupItem,
+                       ELM_GENLIST_ITEM_NONE,
+                       genlistClickCB,
+                       static_cast<const void*>(viewItem));
+       } else {
+               /* Download History Item */
+               glItem = elm_genlist_item_append(
+                       eoDldList,
+                       viewItem->elmGenlistStyle(),
+                       static_cast<const void*>(viewItem),
+                       glGroupItem,
+                       ELM_GENLIST_ITEM_NONE,
+                       genlistClickCB,
+                       static_cast<const void*>(viewItem));
+       }
+       if (!glItem)
+               DP_LOGE("Fail to add a genlist item");
+
+       DP_LOGD("genlist groupItem[%p] item[%p] viewItem[%p]", glGroupItem, glItem, viewItem);
+       viewItem->setGenlistItem(glItem);
+       /* Move scrollbar to top.
+        * When groupItem means today group in case of addtion of download link item
+       **/
+       if (!viewItem->isFinished())
+               elm_genlist_item_show(glGroupItem, ELM_GENLIST_ITEM_SCROLLTO_TOP);
+}
+
+void DownloadView::showEmptyView()
+{
+       DP_LOGD_FUNC();
+       if (!eoEmptyNoContent) {
+               eoEmptyNoContent = elm_layout_add(eoLayout);
+               elm_layout_theme_set(eoEmptyNoContent, "layout", "nocontents", "text");
+               evas_object_size_hint_weight_set(eoEmptyNoContent, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               evas_object_size_hint_align_set(eoEmptyNoContent, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               elm_object_part_text_set(eoEmptyNoContent, "elm.text",
+                       __("IDS_DL_BODY_NO_DOWNLOADS"));
+               evas_object_size_hint_weight_set (eoEmptyNoContent,
+                       EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+               if (eoDldList) {
+                       elm_box_unpack(eoBox,eoDldList);
+                       /* Detection code */
+                       DP_LOGD("del::eoDldList[%p]",eoDldList);
+                       evas_object_del(eoDldList);
+                       eoDldList = NULL;
+               }
+               elm_box_pack_start(eoBox, eoEmptyNoContent);
+       }
+       evas_object_show(eoEmptyNoContent);
+       elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
+}
+
+void DownloadView::hideEmptyView()
+{
+       DP_LOGD_FUNC();
+       if(eoEmptyNoContent) {
+               elm_box_unpack(eoBox, eoEmptyNoContent);
+               evas_object_del(eoEmptyNoContent);
+               eoEmptyNoContent = NULL;
+       }
+       elm_object_item_disabled_set(eoCbItemDelete, EINA_FALSE);
+}
+
+bool DownloadView::isGenlistEditMode()
+{
+       return (bool)elm_genlist_decorate_mode_get(eoDldList);
+}
+
+#ifndef _TIZEN_PUBLIC
+void DownloadView::cancelSweepEvent()
+{
+       DP_LOGD_FUNC();
+       if (m_sweepedItem) {
+               m_sweepedItem->sweepLeft();
+               m_sweepedItem = NULL;
+       }
+}
+#endif
+
+void DownloadView::createSelectAllLayout()
+{
+       eoSelectAllLayout = elm_layout_add(eoBox);
+       elm_layout_theme_set(eoSelectAllLayout, "genlist", "item",
+               "select_all/default");
+       evas_object_size_hint_weight_set(eoSelectAllLayout, EVAS_HINT_EXPAND,
+               EVAS_HINT_FILL);
+       evas_object_size_hint_align_set(eoSelectAllLayout, EVAS_HINT_FILL,
+               EVAS_HINT_FILL);
+       evas_object_event_callback_add(eoSelectAllLayout, EVAS_CALLBACK_MOUSE_DOWN,
+               selectAllClickedCB, NULL);
+       eoAllCheckedBox = elm_check_add(eoSelectAllLayout);
+       elm_check_state_pointer_set(eoAllCheckedBox, &m_allChecked);
+       evas_object_smart_callback_add(eoAllCheckedBox, "changed",
+               selectAllChangedCB, NULL);
+       evas_object_propagate_events_set(eoAllCheckedBox, EINA_FALSE);
+       elm_object_part_content_set(eoSelectAllLayout, "elm.icon", eoAllCheckedBox);
+       elm_object_text_set(eoSelectAllLayout, S_("IDS_COM_BODY_SELECT_ALL"));
+       elm_box_pack_start(eoBox, eoSelectAllLayout);
+       evas_object_show(eoSelectAllLayout);
+       m_allChecked = EINA_FALSE;
+}
+
+void DownloadView::changeAllCheckedValue()
+{
+       m_allChecked = !m_allChecked;
+       elm_check_state_pointer_set(eoAllCheckedBox, &m_allChecked);
+       handleChangedAllCheckedState();
+}
+
+void DownloadView::destroyCheckedItem()
+{
+       Eina_List *list = NULL;
+       Elm_Object_Item *it = NULL;
+       ViewItem *item = NULL;
+       int checkedCount = 0;
+       queue <unsigned int> deleteQueue;
+
+       DP_LOGD_FUNC();
+
+       it = elm_genlist_first_item_get(eoDldList);
+
+       while (it) {
+               item = (ViewItem *)elm_object_item_data_get(it);
+               /* elm_genlist_item_select_mode_get is needed to check group item */
+               if (elm_genlist_item_select_mode_get(it) !=
+                               ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY &&
+                               item && item->checkedValue()) {
+                       list = eina_list_append(list, it);
+               }
+               it = elm_genlist_item_next_get(it);
+       }
+
+       if (!list) {
+               DP_LOGD("There is no delete item");
+               return;
+       }
+
+       checkedCount = eina_list_count(list);
+       if (checkedCount < 1)
+               return;
+       DP_LOGD("checkedCount[%d]", checkedCount);
+
+       for (int i = 0; i < checkedCount; i++)
+       {
+               it = (Elm_Object_Item *)eina_list_data_get(list);
+               if (it)
+                       item = (ViewItem *)elm_object_item_data_get(it);
+               else
+                       DP_LOGE("genlist item is null");
+               list = eina_list_next(list);
+               if (item) {
+                       deleteQueue.push(item->historyId());
+                       item->destroy();
+               } else {
+                       DP_LOGE("viewItem is null");
+               }
+       }
+       if (list)
+               eina_list_free(list);
+
+       DownloadHistoryDB::deleteMultipleItem(deleteQueue);
+       showNotifyInfo(DOWNLOAD_NOTIFY_DELETED, checkedCount);
+       hideGenlistEditMode();
+}
+
+void DownloadView::showGenlistEditMode()
+{
+       DP_LOG_FUNC();
+#ifndef _TIZEN_PUBLIC
+       cancelSweepEvent();
+#endif
+       /* Initialize notify info widget */
+       destroyNotifyInfo();
+       elm_object_item_text_set(eoNaviBarItem, S_("IDS_COM_OPT_DELETE"));
+       /* Change layoutbackground color to edit mode color */
+       elm_object_style_set(eoBackground, "edit_mode");
+       /* Disable the back button of control bar */
+       elm_object_item_part_content_unset(eoNaviBarItem, "prev_btn");
+       destroyEvasObj(eoBackBtn);
+
+       if (eoCbItemEmpty)
+               elm_object_item_del(eoCbItemEmpty);
+       eoCbItemCancel = elm_toolbar_item_append(eoControlBar, NULL,
+               S_("IDS_COM_SK_CANCEL"), cbItemCancelCB, eoNaviBar);
+
+       /* Append 'Select All' layout */
+       createSelectAllLayout();
+       /* Set reorder end edit mode */
+       elm_genlist_reorder_mode_set(eoDldList, EINA_TRUE);
+       elm_genlist_decorate_mode_set(eoDldList, EINA_TRUE);
+       /* This means even if the ouside of checked box is selected,
+          it is same to click a check box. */
+       elm_genlist_select_mode_set(eoDldList, ELM_OBJECT_SELECT_MODE_ALWAYS);
+
+       Elm_Object_Item *it = NULL;
+       ViewItem *viewItem = NULL;
+       it = elm_genlist_first_item_get(eoDldList);
+       while (it) {
+               viewItem = (ViewItem *)elm_object_item_data_get(it);
+               if (elm_genlist_item_select_mode_get(it) !=
+                               ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY &&
+                               viewItem && !(viewItem->isFinished()))
+                       elm_object_item_disabled_set(it, EINA_TRUE);
+               it = elm_genlist_item_next_get(it);
+       }
+       elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
+}
+
+void DownloadView::hideGenlistEditMode()
+{
+       DP_LOG_FUNC();
+
+       elm_object_item_text_set(eoNaviBarItem, __("IDS_BR_HEADER_DOWNLOAD_MANAGER"));
+       elm_object_style_set(eoBackground, "default");
+
+       /* Recreate back button */
+       createBackBtn();
+       elm_object_item_part_content_set(eoNaviBarItem, "prev_btn", eoBackBtn);
+
+       if (eoCbItemCancel) {
+               elm_object_item_del(eoCbItemCancel);
+               eoCbItemCancel = NULL;
+       }
+       eoCbItemEmpty = elm_toolbar_item_append(eoControlBar, NULL, NULL, NULL, NULL);
+       elm_object_item_disabled_set(eoCbItemEmpty, EINA_TRUE);
+
+       elm_box_unpack(eoBox, eoSelectAllLayout);
+
+       destroyEvasObj(eoAllCheckedBox);
+       destroyEvasObj(eoSelectAllLayout);
+
+       elm_genlist_reorder_mode_set(eoDldList, EINA_FALSE);
+       elm_genlist_decorate_mode_set(eoDldList, EINA_FALSE);
+       elm_genlist_select_mode_set(eoDldList, ELM_OBJECT_SELECT_MODE_DEFAULT);
+
+       Elm_Object_Item *it = NULL;
+       ViewItem *viewItem = NULL;
+       it = elm_genlist_first_item_get(eoDldList);
+       while (it) {
+               viewItem = (ViewItem *)elm_object_item_data_get(it);
+               if (elm_genlist_item_select_mode_get(it) !=
+                               ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY && viewItem) {
+                       if (elm_object_item_disabled_get(it))
+                               elm_object_item_disabled_set(it, EINA_FALSE);
+                       viewItem->setCheckedValue(EINA_FALSE);
+                       viewItem->setCheckedBtn(NULL);
+               }
+               it = elm_genlist_item_next_get(it);
+       }
+
+       m_allChecked = EINA_FALSE;
+
+       if (m_viewItemCount < 1) {
+               elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
+               showEmptyView();
+       } else
+               elm_object_item_disabled_set(eoCbItemDelete, EINA_FALSE);
+}
+
+void DownloadView::handleChangedAllCheckedState()
+{
+       int checkedCount = 0;
+       Elm_Object_Item *it = NULL;
+       ViewItem *viewItem = NULL;
+       it = elm_genlist_first_item_get(eoDldList);
+       while (it) {
+               viewItem = (ViewItem *)elm_object_item_data_get(it);
+               if (elm_genlist_item_select_mode_get(it) !=
+                       ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY && viewItem) {
+                       if (viewItem->isFinished()) {
+                               viewItem->setCheckedValue(m_allChecked);
+                               viewItem->updateCheckedBtn();
+                               checkedCount++;
+                       }
+               }
+               it = elm_genlist_item_next_get(it);
+       }
+
+       if (m_allChecked && checkedCount > 0) {
+               elm_object_item_disabled_set(eoCbItemDelete, EINA_FALSE);
+               showNotifyInfo(DOWNLOAD_NOTIFY_SELECTED, checkedCount);
+       } else {
+               elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
+               showNotifyInfo(DOWNLOAD_NOTIFY_SELECTED, 0);
+       }
+}
+
+void DownloadView::handleCheckedState()
+{
+       int checkedCount = 0;
+       int deleteAbleTotalCount = 0;
+
+       DP_LOGD_FUNC();
+
+       Elm_Object_Item *it = NULL;
+       ViewItem *viewItem = NULL;
+       it = elm_genlist_first_item_get(eoDldList);
+       while (it) {
+               viewItem = (ViewItem *)elm_object_item_data_get(it);
+               if (elm_genlist_item_select_mode_get(it) !=
+                       ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY && viewItem) {
+                       if (viewItem->checkedValue())
+                               checkedCount++;
+                       if (viewItem->isFinished())
+                               deleteAbleTotalCount++;
+               }
+               it = elm_genlist_item_next_get(it);
+       }
+
+       if (checkedCount == deleteAbleTotalCount)
+               m_allChecked = EINA_TRUE;
+       else
+               m_allChecked = EINA_FALSE;
+       elm_check_state_pointer_set(eoAllCheckedBox, &m_allChecked);
+
+       if (checkedCount == 0) {
+               elm_object_item_disabled_set(eoCbItemDelete, EINA_TRUE);
+               destroyNotifyInfo();
+       } else
+               elm_object_item_disabled_set(eoCbItemDelete, EINA_FALSE);
+       showNotifyInfo(DOWNLOAD_NOTIFY_SELECTED, checkedCount);
+}
+void DownloadView::createNotifyInfo()
+{
+       DP_LOGD_FUNC();
+       eoNotifyInfo = elm_notify_add(eoBoxLayout);
+       elm_notify_orient_set(eoNotifyInfo, ELM_NOTIFY_ORIENT_BOTTOM);
+       evas_object_size_hint_weight_set(eoNotifyInfo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(eoNotifyInfo, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_event_callback_add(eoNotifyInfo, EVAS_CALLBACK_SHOW, showNotifyInfoCB, eoLayout);
+       evas_object_event_callback_add(eoNotifyInfo, EVAS_CALLBACK_HIDE, hideNotifyInfoCB, eoLayout);
+       eoNotifyInfoLayout = elm_layout_add(eoNotifyInfo);
+       elm_object_content_set(eoNotifyInfo, eoNotifyInfoLayout);
+}
+
+void DownloadView::showNotifyInfo(int type, int selectedCount)
+{
+#ifndef _TIZEN_PUBLIC
+       int angle = 0;
+#endif
+       string buf;
+       DP_LOGD_FUNC();
+
+#ifndef _TIZEN_PUBLIC
+       angle = elm_win_rotation_get(eoWindow);
+#endif
+
+       if (selectedCount == 0) {
+               destroyNotifyInfo();
+               return;
+       }
+
+       if (!eoNotifyInfo)
+               createNotifyInfo();
+
+#ifndef _TIZEN_PUBLIC
+       if (angle == 0 || angle == 180)
+               elm_layout_theme_set(eoNotifyInfoLayout, "standard", "selectioninfo",
+                       "vertical/bottom_12");
+       else
+               elm_layout_theme_set(eoNotifyInfoLayout, "standard", "selectioninfo",
+                       "horizontal/bottom_12");
+#else
+       elm_layout_theme_set(eoNotifyInfoLayout, "standard", "selectioninfo",
+               "vertical/bottom_12");
+#endif
+       buf.append(" ");
+       if (type == DOWNLOAD_NOTIFY_SELECTED) {
+               stringstream countStr;
+               countStr << selectedCount;
+               buf = S_("IDS_COM_BODY_SELECTED");
+               buf.append(" (");
+               buf.append(countStr.str());
+               buf.append(")");
+       } else if (type == DOWNLOAD_NOTIFY_DELETED) {
+               buf = S_("IDS_COM_POP_DELETED");
+               elm_notify_timeout_set(eoNotifyInfo, 3);
+       }
+       edje_object_part_text_set(_EDJ(eoNotifyInfoLayout), "elm.text", buf.c_str());
+       evas_object_show(eoNotifyInfo);
+}
+
+void DownloadView::destroyNotifyInfo()
+{
+       DP_LOGD_FUNC();
+       destroyEvasObj(eoNotifyInfoLayout);
+       destroyEvasObj(eoNotifyInfo);
+       eoNotifyInfoLayout = NULL;
+       eoNotifyInfo = NULL;
+}
+
+/* Static callback function */
+void DownloadView::showNotifyInfoCB(void *data, Evas *evas, Evas_Object *obj,
+       void *event)
+{
+       Evas_Object *layout = (Evas_Object *)data;
+       if (!data) {
+               DP_LOGE("data is NULL");
+               return;
+       }
+       edje_object_signal_emit(_EDJ(layout), "elm,layout,content,bottom_padding",
+               "layout");
+}
+
+void DownloadView::hideNotifyInfoCB(void *data, Evas *evas, Evas_Object *obj,
+       void *event)
+{
+       Evas_Object *layout = (Evas_Object *)data;
+       if (!data) {
+               DP_LOGE("data is NULL");
+               return;
+       }
+       edje_object_signal_emit(_EDJ(layout), "elm,layout,content,default", "layout");
+}
+
+void DownloadView::selectAllClickedCB(void *data, Evas *evas, Evas_Object *obj,
+       void *event_info)
+{
+       DownloadView &view = DownloadView::getInstance();
+       DP_LOGD_FUNC();
+       view.changeAllCheckedValue();
+}
+
+void DownloadView::selectAllChangedCB(void *data, Evas_Object *obj,
+       void *event_info)
+{
+       DownloadView &view = DownloadView::getInstance();
+       DP_LOGD_FUNC();
+       view.handleChangedAllCheckedState();
+}
+
+#ifndef _TIZEN_PUBLIC
+void DownloadView::sweepRightCB(void *data, Evas_Object *obj, void *event_info)
+{
+       DownloadView& view = DownloadView::getInstance();
+       DP_LOGD_FUNC();
+       if (!obj || !event_info) {
+               DP_LOGE("obj or event_info is NULL");
+               return;
+       }
+       if (!elm_genlist_decorate_mode_get(obj)) {
+               Elm_Object_Item *glItem = (Elm_Object_Item *)event_info;
+               ViewItem *viewItem = view.findViewItemForGenlistItem(glItem);
+               if (viewItem) {
+                       if (viewItem->isFinished()) {
+                               if (view.sweepedItem())
+                                       view.sweepedItem()->sweepLeft();
+                               viewItem->sweepRight();
+                               view.setSweepedItem(viewItem);
+                       }
+               } else {
+                       DP_LOGE("Fail to find view item at sweep mode");
+               }
+       } else
+               DP_LOGD("Unable to sweep right");
+}
+
+void DownloadView::sweepLeftCB(void *data, Evas_Object *obj, void *event_info)
+{
+       DownloadView& view = DownloadView::getInstance();
+       DP_LOGD_FUNC();
+       if (!obj || !event_info) {
+               DP_LOGE("obj or event_info is NULL");
+               return;
+       }
+
+       if (!elm_genlist_decorate_mode_get(obj)) {
+               Elm_Object_Item *glItem = (Elm_Object_Item *)event_info;
+               ViewItem *viewItem = view.findViewItemForGenlistItem(glItem);
+               if (viewItem) {
+                       if (viewItem->isFinished()) {
+                               viewItem->sweepLeft();
+                               view.setSweepedItem(NULL);
+                       }
+               } else {
+                       DP_LOGE("Fail to find view item at sweep mode");
+               }
+       } else
+               DP_LOGD("Unable to sweep left");
+}
+#endif
+
+void DownloadView::backBtnCB(void *data, Evas_Object *obj, void *event_info)
+{
+       DownloadView& view = DownloadView::getInstance();
+       view.hide();
+}
+
+void DownloadView::cbItemDeleteCB(void *data, Evas_Object *obj, void *event_info)
+{
+
+       DownloadView& view = DownloadView::getInstance();
+       if (!view.isGenlistEditMode())
+               view.showGenlistEditMode();
+       else
+               view.destroyCheckedItem();
+}
+
+void DownloadView::cbItemCancelCB(void *data, Evas_Object *obj, void *event_info)
+{
+       DownloadView& view = DownloadView::getInstance();
+       view.destroyNotifyInfo();
+       view.hideGenlistEditMode();
+}
+
+void DownloadView::genlistClickCB(void *data, Evas_Object *obj, void *event_info)
+{
+       ViewItem *item = reinterpret_cast<ViewItem *>(data);
+       DP_LOGD_FUNC();
+       if (!data) {
+               DP_LOGE("data is NULL");
+               return;
+       }
+       item->clickedGenlistItem();
+}
+
+void DownloadView::cancelClickCB(void *data, Evas_Object *obj, void *event_info)
+{
+       ViewItem *item = NULL;
+
+       DP_LOGD_FUNC();
+
+       if (!data) {
+               DP_LOGE("data is NULL");
+               return;
+       }
+       item = reinterpret_cast<ViewItem *>(data);
+       item->requestCancel();
+
+}
+
+void DownloadView::showErrPopup(string &desc)
+{
+       removePopup();
+
+       eoPopup = elm_popup_add(eoWindow);
+       evas_object_size_hint_weight_set(eoPopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_text_set(eoPopup, desc.c_str());
+       elm_popup_timeout_set(eoPopup, 2);
+       evas_object_smart_callback_add(eoPopup, "response", errPopupResponseCB, NULL);
+       evas_object_show(eoPopup);
+}
+
+void DownloadView::errPopupResponseCB(void *data, Evas_Object *obj, void *event_info)
+{
+       DP_LOGD_FUNC();
+       DownloadView& view = DownloadView::getInstance();
+       view.removePopup();
+}
+
+void DownloadView::removePopup()
+{
+       DP_LOGD_FUNC();
+       destroyEvasObj(eoPopup);
+}
+
+DateGroup *DownloadView::getDateGroupObj(int type)
+{
+       DateGroup *obj = NULL;
+       switch (type) {
+       case DATETIME::DATE_TYPE_LATER:
+       case DATETIME::DATE_TYPE_TODAY:
+               obj = &m_today;
+               break;
+       case DATETIME::DATE_TYPE_YESTERDAY:
+               obj = &m_yesterday;
+               break;
+       case DATETIME::DATE_TYPE_PREVIOUS:
+               obj = &m_previousDay;
+               break;
+       default:
+               obj = NULL;
+               DP_LOGE("Cannot enter here");
+               break;
+       }
+       return obj;
+}
+
+Elm_Object_Item *DownloadView::getGenlistGroupItem(int type)
+{
+       DateGroup *obj = getDateGroupObj(type);
+       if (!obj)
+               return NULL;
+       return obj->glGroupItem();
+}
+
+void DownloadView::setGenlistGroupItem(int type, Elm_Object_Item *item)
+{
+       DateGroup *obj = getDateGroupObj(type);
+       if (!obj)
+               return;
+       obj->setGlGroupItem(item);
+}
+
+void DownloadView::increaseGenlistGroupCount(int type)
+{
+       DateGroup *obj = getDateGroupObj(type);
+       if (!obj)
+               return;
+       if (type == DATETIME::DATE_TYPE_TODAY || type == DATETIME::DATE_TYPE_LATER) {
+               if (m_today.getCount() < 1) {
+                       DateUtil &inst = DateUtil::getInstance();
+                       inst.setTodayStandardTime();
+               }
+       }
+       obj->increaseCount();
+       DP_LOGD("increased count[%d]",obj->getCount());
+}
+
+int DownloadView::getGenlistGroupCount(int type)
+{
+       DateGroup *obj = getDateGroupObj(type);
+       if (!obj)
+               return 0;
+       DP_LOGD("Group count[%d]",obj->getCount());
+       return obj->getCount();
+}
+
+void DownloadView::handleGenlistGroupItem(int type)
+{
+       DateGroup *obj = getDateGroupObj(type);
+       if (!obj)
+               return;
+       obj->decreaseCount();
+       DP_LOGD("count[%d]type[%d]",obj->getCount(),type);
+       if (obj->getCount() < 1) {
+               //DP_LOGD("Group Item[%p][%d]", obj->glGroupItem(),type);
+               elm_object_item_del(obj->glGroupItem());
+               obj->setGlGroupItem(NULL);
+       }
+}
+
+void DownloadView::handleUpdateDateGroupType(ViewItem *viewItem)
+{
+       int diffDays = 0;
+       DateUtil &inst = DateUtil::getInstance();
+       DP_LOGD_FUNC();
+       diffDays = inst.getDiffDaysFromToday();
+       if (viewItem) {
+       /* Update a view item which is added now
+        * This should be only called when attaching item
+       **/
+               viewItem->extractDateGroupType();
+       } else if (diffDays != 0) {
+       /* FIXME later
+        * Now, it is recreated download items and group items.
+        * Consider to move only group item later.
+        * This should be only called from show() function
+       **/
+/* FIXME later
+ * Another problem is happend becuase eina list is used repacing with vector */
+#if 0
+               cleanGenlistData();
+               Elm_Object_Item *it = NULL;
+               ViewItem *viewItem = NULL;
+               it = elm_genlist_first_item_get(eoDldList);
+               while (it) {
+                       viewItem = (ViewItem *)elm_object_item_data_get(it);
+                       if (!viewItem || elm_genlist_item_select_mode_get(it) !=
+                                       ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
+                               continue;
+                       viewItem->extractDateGroupType();
+                       createGenlistItem(viewItem);
+                       it = elm_genlist_item_next_get(it);
+               }
+#endif
+       }
+       inst.setTodayStandardTime();
+}
+
+void DownloadView::moveRetryItem(ViewItem *viewItem)
+{
+       Elm_Object_Item *todayGroupItem = NULL;
+       Elm_Object_Item *firstItem = NULL;
+       DP_LOGD_FUNC();
+       if (!viewItem) {
+               DP_LOGE("view item is NULL");
+               return;
+       }
+       firstItem = elm_genlist_first_item_get(eoDldList);
+       if (firstItem) {
+               DP_LOGD("groupItem[%p] viewItem[%p]", firstItem, viewItem);
+               /* This is group item */
+               if (elm_genlist_item_select_mode_get(firstItem) ==
+                               ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) {
+                       /* The top item is the item after group item */
+                       firstItem = elm_genlist_item_next_get(firstItem);
+                       DP_LOGD("firstItem[%p], present item[%p]", firstItem, viewItem->genlistItem());
+                       if (firstItem == viewItem->genlistItem()) {
+                               DP_LOGD("This is already top item. Don't need to move");
+                               return;
+                       }
+               }
+       }
+       elm_object_item_del(viewItem->genlistItem());
+       viewItem->setGenlistItem(NULL);
+       handleGenlistGroupItem(viewItem->dateGroupType());
+       todayGroupItem = getGenlistGroupItem(DATETIME::DATE_TYPE_TODAY);
+       if (!todayGroupItem) {
+               DateGroup *dateGrpObj = getDateGroupObj(DATETIME::DATE_TYPE_TODAY);
+               todayGroupItem = elm_genlist_item_prepend(
+                               eoDldList,
+                               &dldGenlistGroupStyle,
+                               static_cast<const void*>(dateGrpObj),
+                               NULL,
+                               ELM_GENLIST_ITEM_GROUP,
+                               NULL,
+                               NULL);
+               setGenlistGroupItem(DATETIME::DATE_TYPE_TODAY, todayGroupItem);
+               if (!todayGroupItem)
+                       DP_LOGE("Fail to add a genlist group item");
+               else
+                       elm_genlist_item_select_mode_set(todayGroupItem,
+                               ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+       }
+       increaseGenlistGroupCount(DATETIME::DATE_TYPE_TODAY);
+       Elm_Object_Item *glItem = elm_genlist_item_insert_after(
+                       eoDldList,
+                       viewItem->elmGenlistStyle(),
+                       static_cast<const void*>(viewItem),
+                       todayGroupItem,
+                       todayGroupItem,
+                       ELM_GENLIST_ITEM_NONE,
+                       genlistClickCB,
+                       static_cast<const void*>(viewItem));
+       if (!glItem)
+               DP_LOGE("Fail to add a genlist item");
+       DP_LOGD("genlist groupItem[%p] item[%p] viewItem[%p]", todayGroupItem,
+               glItem, viewItem);
+       viewItem->setGenlistItem(glItem);
+       elm_genlist_item_show(todayGroupItem, ELM_GENLIST_ITEM_SCROLLTO_TOP);
+       viewItem->extractDateGroupType();
+}
+
+char *DownloadView::getGenlistGroupLabel(void *data, Evas_Object *obj, const char *part)
+{
+       DateGroup *dateGrp = static_cast<DateGroup *>(data);
+
+       if(!data || !obj || !part)
+               return NULL;
+
+       DP_LOGD("ViewItem::getListGroupLabel:part[%s] groupDateType[%d] obj[%p]", part, dateGrp->getType(), obj);
+       if (strncmp(part, "elm.text", strlen("elm.text")) == 0) {
+               DateUtil &inst = DateUtil::getInstance();
+               string msg;
+               string outBuf;
+               double udateTime = 0;
+               switch (dateGrp->getType()) {
+               case DATETIME::DATE_TYPE_PREVIOUS:
+                       msg = S_("IDS_COM_BODY_PREVIOUS_DAYS");
+                       break;
+               case DATETIME::DATE_TYPE_YESTERDAY:
+                       udateTime = inst.yesterdayTime()*1000;
+                       msg = S_("IDS_COM_BODY_YESTERDAY");
+                       msg += " (";
+                       inst.getDateStr(LOCALE_STYLE::FULL_DATE, udateTime, outBuf);
+                       msg += outBuf;
+                       msg += ")";
+                       break;
+               case DATETIME::DATE_TYPE_LATER:
+               case DATETIME::DATE_TYPE_TODAY:
+                       udateTime = inst.nowTime()*1000;
+                       msg = S_("IDS_COM_BODY_TODAY");
+                       msg += " (";
+                       inst.getDateStr(LOCALE_STYLE::FULL_DATE, udateTime, outBuf);
+                       msg += outBuf;
+                       msg += ")";
+                       break;
+               default :
+                       DP_LOGE("Cannot enter here");
+                       return NULL;
+               }
+               return strdup(msg.c_str());
+       }
+       return NULL;
+}
+
+char *DownloadView::getGenlistGroupLabelCB(void *data, Evas_Object *obj, const char *part)
+{
+//     DP_LOGD_FUNC();
+       if(!data || !obj || !part)
+               return NULL;
+
+       DownloadView &view = DownloadView::getInstance();
+       return view.getGenlistGroupLabel(data, obj, part);
+}
+
+void DownloadView::cleanGenlistData()
+{
+       Elm_Object_Item *grpItem = NULL;
+       DP_LOGD_FUNC();
+       grpItem = m_today.glGroupItem();
+       if (grpItem)
+               elm_object_item_del(grpItem);
+       m_today.initData();
+       grpItem = m_yesterday.glGroupItem();
+       if (grpItem)
+               elm_object_item_del(grpItem);
+       m_yesterday.initData();
+       grpItem = m_previousDay.glGroupItem();
+       if (grpItem)
+               elm_object_item_del(grpItem);
+       m_previousDay.initData();
+       elm_genlist_clear(eoDldList);
+}
+
diff --git a/src/download-manager-viewItem.cpp b/src/download-manager-viewItem.cpp
new file mode 100644 (file)
index 0000000..1d559fe
--- /dev/null
@@ -0,0 +1,633 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-viewItem.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      item data class for download view
+ */
+#include "download-manager-viewItem.h"
+#include "download-manager-items.h"
+#include "download-manager-view.h"
+
+ViewItem::ViewItem(Item *item)
+       : m_item(item)
+       , m_glItem(NULL)
+       , m_progressBar(NULL)
+       , m_checkedBtn(NULL)
+       , m_checked(EINA_FALSE)
+       , m_isRetryCase(false)
+       , m_dateGroupType(DATETIME::DATE_TYPE_NONE)
+{
+       // FIXME need to makes exchange subject?? not yet, but keep it in mind!
+       if (item) {
+               m_aptr_observer = auto_ptr<Observer>(
+                       new Observer(updateCB, this, "viewItemObserver"));
+               item->subscribe(m_aptr_observer.get());
+       }
+
+       dldGenlistStyle.item_style = "3text.3icon";
+#ifndef _TIZEN_PUBLIC
+       dldGenlistStyle.decorate_item_style = "mode/slide";
+#endif
+       dldGenlistStyle.func.text_get = getGenlistLabelCB;
+       dldGenlistStyle.func.content_get = getGenlistIconCB;
+       dldGenlistStyle.func.state_get = NULL;
+       dldGenlistStyle.func.del = NULL;
+       dldGenlistStyle.decorate_all_item_style = "edit_default";
+
+       dldHistoryGenlistStyle.item_style = "3text.1icon.2";
+#ifndef _TIZEN_PUBLIC
+       dldHistoryGenlistStyle.decorate_item_style = "mode/slide";
+#endif
+       dldHistoryGenlistStyle.func.text_get = getGenlistLabelCB;
+       dldHistoryGenlistStyle.func.content_get = getGenlistIconCB;
+       dldHistoryGenlistStyle.func.state_get = NULL;
+       dldHistoryGenlistStyle.func.del = NULL;
+       dldHistoryGenlistStyle.decorate_all_item_style = "edit_default";
+
+       dldGenlistSlideStyle.item_style = "3text.1icon.2";
+#ifndef _TIZEN_PUBLIC
+       dldGenlistSlideStyle.decorate_item_style = "mode/slide2";
+#endif
+       dldGenlistSlideStyle.func.text_get = getGenlistLabelCB;
+       dldGenlistSlideStyle.func.content_get= getGenlistIconCB;
+       dldGenlistSlideStyle.func.state_get = NULL;
+       dldGenlistSlideStyle.func.del = NULL;
+       dldGenlistSlideStyle.decorate_all_item_style = "edit_default";
+
+}
+
+ViewItem::~ViewItem()
+{
+       DP_LOGD_FUNC();
+}
+
+void ViewItem::create(Item *item)
+{
+       ViewItem *newViewItem = new ViewItem(item);
+
+       DownloadView &view = DownloadView::getInstance();
+       view.attachViewItem(newViewItem);
+}
+
+void ViewItem::destroy()
+{
+       DP_LOGD("ViewItem::destroy");
+       /* After item is destory,
+          view item also will be destroyed through event system */
+       if (m_item) {
+#ifndef _TIZEN_PUBLIC
+               DownloadView &view = DownloadView::getInstance();
+               if (this == view.sweepedItem()) {
+                       DP_LOGD("reset sweeped item[%p]", view.sweepedItem());
+                       view.setSweepedItem(NULL);
+               }
+#endif
+               m_item->destroy();
+       }
+}
+
+void ViewItem::updateCB(void *data)
+{
+       if (data)
+               static_cast<ViewItem*>(data)->updateFromItem();
+}
+
+void ViewItem::updateFromItem()
+{
+       DownloadView &view = DownloadView::getInstance();
+       DP_LOGD("ViewItem::updateFromItem() ITEM::[%d]", state());
+       if (state() == ITEM::DESTROY) {
+               int tempType = 0;
+               DP_LOGD("ViewItem::updateFromItem() ITEM::DESTROY");
+               if (m_item)
+                       m_item->deSubscribe(m_aptr_observer.get());
+               m_aptr_observer->clear();
+               elm_object_item_del(m_glItem);
+               m_glItem = NULL;
+               tempType = dateGroupType();
+               view.detachViewItem(this);
+               view.handleGenlistGroupItem(tempType);
+               return;
+       }
+       if (m_glItem == NULL) {
+               return;
+       }
+       if (state() == ITEM::SUSPENDED) {
+               return;
+       } else if (state() == ITEM::DOWNLOADING) {
+               if (fileSize() > 0 && m_progressBar) {
+                       double percentageProgress = 0.0;
+                       percentageProgress = (double)(receivedFileSize()) /
+                               (double)(fileSize());
+                       DP_LOGD("progress value[%.2f]",percentageProgress);
+                       elm_progressbar_value_set(m_progressBar, percentageProgress);
+               }
+               elm_genlist_item_fields_update(m_glItem,"elm.text.2",
+                       ELM_GENLIST_ITEM_FIELD_TEXT);
+       } else if (m_isRetryCase && state() == ITEM::RECEIVING_DOWNLOAD_INFO) {
+               elm_genlist_item_item_class_update(m_glItem, &dldGenlistStyle);
+       } else if (!isFinished()) {
+               elm_genlist_item_update(m_glItem);
+       } else {/* finished state */
+               if (state() == ITEM::FINISH_DOWNLOAD)
+                       elm_genlist_item_item_class_update(m_glItem, &dldHistoryGenlistStyle);
+               else
+                       elm_genlist_item_item_class_update(m_glItem, &dldGenlistSlideStyle);
+               if (view.isGenlistEditMode())
+                       elm_object_item_disabled_set(m_glItem, EINA_FALSE);
+       }
+}
+
+char *ViewItem::getGenlistLabelCB(void *data, Evas_Object *obj, const char *part)
+{
+//     DP_LOGD_FUNC();
+
+       if(!data || !obj || !part)
+               return NULL;
+
+       ViewItem *item = static_cast<ViewItem *>(data);
+       return item->getGenlistLabel(obj, part);
+}
+
+char *ViewItem::getGenlistLabel(Evas_Object *obj,      const char *part)
+{
+       DP_LOGD("ViewItem::getListLabel:part[%s]", part);
+
+#ifndef _TIZEN_PUBLIC
+       if (strncmp(part, "elm.text.1", strlen("elm.text.1")) == 0 ||
+               strncmp(part, "elm.slide.text.1", strlen("elm.slide.text.1")) == 0 ||
+               strncmp(part, "elm.slide.text.2", strlen("elm.slide.text.2")) == 0) {
+#else
+       if (strncmp(part, "elm.text.1", strlen("elm.text.1")) == 0) {
+#endif
+               return strdup(getTitle());
+       } else if (strncmp(part, "elm.text.2", strlen("elm.text.2")) == 0) {
+               return strdup(getMessage());
+       } else if (strncmp(part, "elm.text.3", strlen("elm.text.3")) == 0) {
+               if (!isFinished()) {
+                       return NULL;
+               } else {
+                       string outBuf;
+                       DateUtil &inst = DateUtil::getInstance();
+                       double udateTime = finishedTime() * 1000;
+                       if (dateGroupType() == DATETIME::DATE_TYPE_PREVIOUS
+                               || dateGroupType() == DATETIME::DATE_TYPE_LATER)
+                               inst.getDateStr(LOCALE_STYLE::SHORT_DATE, udateTime, outBuf);
+                       else
+                               inst.getDateStr(LOCALE_STYLE::TIME, udateTime, outBuf);
+                       return strdup(outBuf.c_str());
+               }
+       } else {
+               DP_LOGD("No Implementation");
+               return NULL;
+       }
+}
+
+Evas_Object *ViewItem::getGenlistIconCB(void *data, Evas_Object *obj,
+       const char *part)
+{
+//     DP_LOGD_FUNC();
+       if(!data || !obj || !part) {
+               DP_LOGE("parameter is NULL");
+               return NULL;
+       }
+
+       ViewItem *item = static_cast<ViewItem *>(data);
+       return item->getGenlistIcon(obj, part);
+}
+
+Evas_Object *ViewItem::getGenlistIcon(Evas_Object *obj, const char *part)
+{
+       //DP_LOGD("ViewItem::getGenlistIcon:part[%s]state[%s]", part, stateStr());
+
+       if (elm_genlist_decorate_mode_get(obj) && isFinished()) {
+               if (strncmp(part,"elm.edit.icon.1", strlen("elm.edit.icon.1")) == 0) {
+                       Evas_Object *checkBtn = elm_check_add(obj);
+                       elm_check_state_pointer_set(checkBtn, &m_checked);
+                       evas_object_smart_callback_add(checkBtn, "changed", checkChangedCB,
+                               this);
+                       m_checkedBtn = checkBtn;
+                       return checkBtn;
+               } else if (strncmp(part,"elm.edit.icon.2", strlen("elm.edit.icon.2")) ==
+                       0) {
+                       return NULL;
+               }
+
+       }
+       /* elm.icon.2 should be checked prior to elm.icon */
+       if (strncmp(part,"elm.icon.2", strlen("elm.icon.2")) == 0) {
+               if (state() == ITEM::RECEIVING_DOWNLOAD_INFO ||
+                       state() == ITEM::DOWNLOADING ||
+                       isPreparingDownload())
+                       return createCancelBtn(obj);
+               else
+                       return NULL;
+       } else if (strncmp(part,"elm.icon.1", strlen("elm.icon.1")) == 0 ||
+               strncmp(part, "elm.icon", strlen("elm.icon")) == 0) {
+//     if (strncmp(part,"elm.icon.1", strlen("elm.icon.1")) == 0) {
+               Evas_Object *icon = elm_icon_add(obj);
+               elm_icon_file_set(icon, getIconPath(), NULL);
+               evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL,1,1);
+               return icon;
+       } else if (strcmp(part,"elm.swallow.progress") == 0) {
+               return createProgressBar(obj);
+#ifndef _TIZEN_PUBLIC
+       } else if (strcmp(part,"elm.slide.swallow.1") == 0) {
+               if (isFinished())
+                       return createDeleteBtn(obj);
+               else
+                       return NULL;
+       } else if (strcmp(part,"elm.slide.swallow.2") == 0) {
+               if (isFinishedWithErr())
+                       return createRetryBtn(obj);
+               else
+                       return NULL;
+#endif
+       } else {
+               DP_LOGE("Cannot enter here");
+               return NULL;
+       }
+}
+
+void ViewItem::checkChangedCB(void *data, Evas_Object *obj,
+       void *event_info)
+{
+       DownloadView &view = DownloadView::getInstance();
+       DP_LOGD_FUNC();
+       //ViewItem *item = static_cast<ViewItem *>(data);
+       //DP_LOGD("checked[%d] viewItem[%p]",(bool)(item->checkedValue()),item);
+       view.handleCheckedState();
+}
+
+#ifndef _TIZEN_PUBLIC
+void ViewItem::sweepRight()
+{
+       DP_LOGD_FUNC();
+       if (!m_glItem) {
+               DP_LOGE("genlist item is NULL");
+               return;
+       }
+       elm_genlist_item_decorate_mode_set(m_glItem,"slide", EINA_TRUE);
+       elm_genlist_item_select_mode_set(m_glItem, ELM_OBJECT_SELECT_MODE_NONE);
+}
+
+void ViewItem::sweepLeft()
+{
+       DP_LOGD_FUNC();
+       if (!m_glItem) {
+               DP_LOGE("genlist item is NULL");
+               return;
+       }
+       elm_genlist_item_decorate_mode_set(m_glItem,"slide", EINA_FALSE);
+       elm_genlist_item_select_mode_set(m_glItem, ELM_OBJECT_SELECT_MODE_NONE);
+}
+#endif
+
+void ViewItem::clickedDeleteButton()
+{
+       DP_LOGD("ViewItem::clickedDeleteButton()");
+       m_item->deleteFromDB();
+       destroy();
+}
+
+void ViewItem::clickedCancelButton()
+{
+       DP_LOG("ViewItem::clickedCancelButton()");
+       requestCancel();
+}
+
+void ViewItem::requestCancel()
+{
+       if (m_item) {
+               m_item->cancel();
+       }
+}
+
+void ViewItem::clickedRetryButton()
+{
+       DP_LOG_FUNC();
+       retryViewItem();
+}
+
+void ViewItem::clickedGenlistItem()
+{
+       DownloadView &view = DownloadView::getInstance();
+       DP_LOG_FUNC();
+       if (!m_item) {
+               DP_LOGE("m_item is NULL");
+               return;
+       }
+       if (view.isGenlistEditMode()) {
+               m_checked = !m_checked;
+               if (m_checkedBtn)
+                       elm_genlist_item_fields_update(genlistItem(),"elm.edit.icon.1",
+                               ELM_GENLIST_ITEM_FIELD_CONTENT);
+               else
+                       DP_LOGE("m_checkedBtn is NULL");
+               view.handleCheckedState();
+       } else if (state() == ITEM::FINISH_DOWNLOAD) {
+               bool ret = m_item->play();
+               if (ret == false) {
+                       string desc = __("IDS_BR_POP_UNABLE_TO_OPEN_FILE");
+                       view.showErrPopup(desc);
+               }
+       } else if (isFinishedWithErr()) {
+               retryViewItem();
+       }
+       elm_genlist_item_selected_set(genlistItem(), EINA_FALSE);
+}
+
+Elm_Genlist_Item_Class *ViewItem::elmGenlistStyle()
+{
+       /* Change the genlist style class in case of download history item */
+       if (state() == ITEM::FINISH_DOWNLOAD)
+               return &dldHistoryGenlistStyle;
+       else if (isFinishedWithErr())
+                return &dldGenlistSlideStyle;
+       else
+               return &dldGenlistStyle;
+}
+
+const char *ViewItem::getMessage()
+{
+       DP_LOGD("ViewItem state() ITEM::[%d]", state());
+       const char *buff = NULL;
+       switch(state()) {
+       case ITEM::IDLE:
+       case ITEM::REQUESTING:
+       case ITEM::PREPARE_TO_RETRY:
+       case ITEM::RECEIVING_DOWNLOAD_INFO:
+       /* Do not display string and show only the progress bar */
+//             buff = __("Check for download");
+               buff = "";
+               break;
+       case ITEM::DOWNLOADING:
+       case ITEM::SUSPENDED:
+               buff = getHumanFriendlyBytesStr(receivedFileSize(), true);
+//             DP_LOGD("%s", buff);
+               break;
+       case ITEM::CANCEL:
+               buff = S_("IDS_COM_POP_CANCELLED");
+               break;
+       case ITEM::FAIL_TO_DOWNLOAD:
+               buff = getErrMsg();
+               break;
+       case ITEM::REGISTERING_TO_SYSTEM:
+               buff = "";
+               break;
+       case ITEM::FINISH_DOWNLOAD:
+               buff =  __("IDS_EMAIL_BODY_COMPLETE");
+               break;
+       default:
+               buff = "";
+               break;
+       }
+       return buff;
+}
+
+const char *ViewItem::getHumanFriendlyBytesStr(unsigned long int bytes,
+       bool progressOption)
+{
+       double doubleTypeBytes = 0.0;
+       const char *unitStr[4] = {"B", "KB", "MB", "GB"};
+       int unit = 0;
+       unsigned long int unitBytes = bytes;
+
+       /* using bit operation to avoid floating point arithmetic */
+       for (unit=0; (unitBytes > 1024 && unit < 4) ; unit++) {
+               unitBytes = unitBytes >> 10;
+       }
+
+       unitBytes = 1 << (10*unit);
+       doubleTypeBytes = ((double)bytes / (double)(unitBytes));
+       // FIXME following code should be broken into another function, but leave it now to save function call time.s
+       char str[32] = {0};
+       if (progressOption && fileSize() != 0) {
+               /* using fixed point arithmetic to avoid floating point arithmetic */
+               const int fixed_point = 6;
+               unsigned long long int receivedBytes = receivedFileSize() << fixed_point;
+               unsigned long long int result = (receivedBytes*100) / fileSize();
+               unsigned long long int result_int = result >> fixed_point;
+               unsigned long long int result_fraction = result &
+                       ~(0xFFFFFFFF << fixed_point);
+               if (unit == 0)
+                       snprintf(str, sizeof(str), "%lu %s / %llu.%.2llu %%",
+                               bytes, unitStr[unit], result_int, result_fraction);
+               else
+                       snprintf(str, sizeof(str), "%.2f %s / %llu.%.2llu %%",
+                               doubleTypeBytes, unitStr[unit], result_int, result_fraction);
+       } else {
+               if (unit == 0)
+                       snprintf(str, sizeof(str), "%lu %s", bytes, unitStr[unit]);
+               else
+                       snprintf(str, sizeof(str), "%.2f %s", doubleTypeBytes, unitStr[unit]);
+       }
+       return string(str).c_str();
+}
+
+unsigned long int ViewItem::receivedFileSize()
+{
+       if (m_item)
+               return m_item->receivedFileSize();
+
+       return 0;
+}
+
+unsigned long int ViewItem::fileSize()
+{
+       if (m_item)
+               return m_item->fileSize();
+
+       return 0;
+}
+
+const char *ViewItem::getTitle()
+{
+       const char *title = NULL;
+       if (m_item)
+               title = m_item->title().c_str();
+
+       if (!title)
+               return S_("IDS_COM_BODY_NO_NAME");
+
+       return title;
+}
+
+Evas_Object *ViewItem::createProgressBar(Evas_Object *parent)
+{
+       Evas_Object *progress = NULL;
+       if (!parent) {
+               DP_LOGE("parent is NULL");
+               return NULL;
+       }
+       progress = elm_progressbar_add(parent);
+       setProgressBar(progress);
+       if (isFinished()) {
+               DP_LOGE("Cannot enter here. finished item has othere genlist style");
+               return NULL;
+       }
+
+       if (fileSize() == 0 || isPreparingDownload()) {
+               //DP_LOGD("Pending style::progressBar[%p]",progress);
+               elm_object_style_set(progress, "pending_list");
+               elm_progressbar_horizontal_set(progress, EINA_TRUE);
+               evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND,
+                       EVAS_HINT_EXPAND);
+               elm_progressbar_pulse(progress, EINA_TRUE);
+       } else {
+               //DP_LOGD("List style::progressBar[%p] fileSize[%d] state[%d]",progress, fileSize(),state());
+               elm_object_style_set(progress, "list_progress");
+               elm_progressbar_horizontal_set(progress, EINA_TRUE);
+
+               if (isCompletedDownload())
+                       elm_progressbar_value_set(progress, 1.0);
+               /* When realized event is happened, the progress is created.
+                  This is needed for that case */
+               else if (state() == ITEM::DOWNLOADING) {
+                       double percentageProgress = 0.0;
+                       percentageProgress = (double)(receivedFileSize()) /
+                               (double)(fileSize());
+                       elm_progressbar_value_set(progress, percentageProgress);
+               }
+       }
+       evas_object_show(progress);
+       return progress;
+}
+
+void ViewItem::updateCheckedBtn()
+{
+       if (m_checkedBtn)
+               elm_check_state_pointer_set(m_checkedBtn,&m_checked);
+}
+
+#ifndef _TIZEN_PUBLIC
+Evas_Object *ViewItem::createDeleteBtn(Evas_Object *parent)
+{
+       DP_LOGD("DeleteButton::create()");
+       Evas_Object *button = elm_button_add(parent);
+       elm_object_style_set(button, "text_only/sweep");
+       elm_object_text_set(button, S_("IDS_COM_OPT_DELETE"));
+       evas_object_propagate_events_set(button, EINA_FALSE);
+       evas_object_smart_callback_add(button ,"clicked", deleteBtnClickedCB, this);
+       return button;
+}
+
+Evas_Object *ViewItem::createRetryBtn(Evas_Object *parent)
+{
+       DP_LOGD("DeleteButton::create()");
+       Evas_Object *button = elm_button_add(parent);
+       elm_object_style_set(button, "text_only/sweep");
+       elm_object_text_set(button, __("IDS_BR_SK_RETRY"));
+       evas_object_propagate_events_set(button, EINA_FALSE);
+       evas_object_smart_callback_add(button ,"clicked", retryBtnClickedCB, this);
+       return button;
+}
+#endif
+
+void ViewItem::deleteBtnClickedCB(void *data, Evas_Object *obj, void *event_info)
+{
+       DP_LOGD_FUNC();
+       if (!data) {
+               DP_LOGE("data is NULL");
+               return;
+       }
+       ViewItem *viewItem = static_cast<ViewItem *>(data);
+       viewItem->clickedDeleteButton();
+}
+
+void ViewItem::retryBtnClickedCB(void *data, Evas_Object *obj, void *event_info)
+{
+       DP_LOGD_FUNC();
+       if (!data) {
+               DP_LOGE("data is NULL");
+               return;
+       }
+       ViewItem *viewItem = static_cast<ViewItem *>(data);
+       viewItem->clickedRetryButton();
+}
+
+Evas_Object *ViewItem::createCancelBtn(Evas_Object *parent)
+{
+       DP_LOGD_FUNC();
+       Evas_Object *button = elm_button_add(parent);
+       elm_object_part_content_set(parent, "btn_style1", button);
+       elm_object_style_set(button, "style1/auto_expand");
+       evas_object_size_hint_aspect_set(button, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+       elm_object_text_set(button, S_("IDS_COM_SK_CANCEL"));
+       evas_object_propagate_events_set(button, EINA_FALSE);
+       evas_object_smart_callback_add(button,"clicked", cancelBtnClickedCB, this);
+       return button;
+}
+
+void ViewItem::cancelBtnClickedCB(void *data, Evas_Object *obj, void *event_info)
+{
+       DP_LOGD_FUNC();
+       if (!data) {
+               DP_LOGE("data is NULL");
+               return;
+       }
+       ViewItem *viewItem = static_cast<ViewItem *>(data);
+       viewItem->clickedCancelButton();
+}
+
+void ViewItem::extractDateGroupType()
+{
+       DP_LOGD_FUNC();
+       /* History Item */
+       //DP_LOGD("state[%s],finishedTime[%ld]",stateStr(),finishedTime());
+       if (isFinished() && finishedTime() > 0) {
+               int diffDay = 0;
+               DateUtil &inst = DateUtil::getInstance();
+               double nowTime = inst.nowTime();
+               double finishTime = finishedTime();
+               diffDay = inst.getDiffDays((time_t)nowTime, (time_t)finishTime);
+               if (diffDay == 0)
+                       m_dateGroupType = DATETIME::DATE_TYPE_TODAY;
+               else if (diffDay == 1)
+                       m_dateGroupType = DATETIME::DATE_TYPE_YESTERDAY;
+               else if (diffDay > 1)
+                       m_dateGroupType = DATETIME::DATE_TYPE_PREVIOUS;
+               else
+                       m_dateGroupType = DATETIME::DATE_TYPE_LATER;
+               return;
+       }
+       /* Item which is added now or retrying item */
+       m_dateGroupType = DATETIME::DATE_TYPE_TODAY;
+}
+
+
+void ViewItem::retryViewItem(void)
+{
+       DownloadView &view = DownloadView::getInstance();
+       DP_LOGD_FUNC();
+       if (m_item) {
+               m_isRetryCase = true;
+               m_item->clearForRetry();
+               if (!m_item->retry()) {
+                       DownloadView &view = DownloadView::getInstance();
+                       string desc = S_("IDS_COM_POP_FAILED");
+                       view.showErrPopup(desc);
+                       m_item->deleteFromDB();
+                       m_item->destroy();
+                       return;
+               }
+               /* Move a item to Today group, if it is not included to Today group */
+               view.moveRetryItem(this);
+       }
+}
diff --git a/src/include/download-manager-common.h b/src/include/download-manager-common.h
new file mode 100644 (file)
index 0000000..b480f17
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-common.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      Common define and data
+ */
+
+#ifndef DOWNLOAD_MANAGER_DOWNLOAD_COMMON_H
+#define DOWNLOAD_MANAGER_DOWNLOAD_COMMON_H
+
+#include <libintl.h>
+#include "download-manager-debug.h"
+
+#if !defined(PACKAGE)
+       #define PACKAGE "download-manager"
+#endif
+
+#define _EDJ(o) elm_layout_edje_get(o)
+#define __(s) dgettext(PACKAGE, s)
+#define S_(s) dgettext("sys_string", s)
+
+#define ERROR_POPUP_LOW_MEM S_("IDS_COM_POP_NOT_ENOUGH_MEMORY")
+#define ERROR_POPUP_UNKNOWN S_("IDS_COM_POP_INTERNAL_ERROR")
+#define ERROR_POPUP_INVALID_URL S_("IDS_COM_POP_INVALID_URL")
+
+#define DP_DRM_ICON_PATH IMAGEDIR"/U06_icon_DRM.png"
+#define DP_JAVA_ICON_PATH IMAGEDIR"/U06_icon_Java.png"
+#define DP_UNKNOWN_ICON_PATH IMAGEDIR"/U06_icon_Unknown.png"
+#define DP_EXCEL_ICON_PATH IMAGEDIR"/U06_icon_excel.png"
+#define DP_HTML_ICON_PATH IMAGEDIR"/U06_icon_html.png"
+#define DP_MUSIC_ICON_PATH IMAGEDIR"/U06_icon_music.png"
+#define DP_PDF_ICON_PATH IMAGEDIR"/U06_icon_pdf.png"
+#define DP_PPT_ICON_PATH IMAGEDIR"/U06_icon_ppt.png"
+#define DP_RINGTONE_ICON_PATH IMAGEDIR"/U06_icon_ringtone.png"
+#define DP_TEXT_ICON_PATH IMAGEDIR"/U06_icon_text.png"
+#define DP_WORD_ICON_PATH IMAGEDIR"/U06_icon_word.png"
+#define DP_VIDEO_ICON_PATH IMAGEDIR"/U06_icon_video.png"
+#define DP_IMAGE_ICON_PATH IMAGEDIR"/U06_icon_image.png"
+
+#define MAX_FILE_PATH_LEN 256
+#define MAX_BUF_LEN 256
+
+#define LOAD_HISTORY_COUNT 500
+
+enum
+{
+       DP_CONTENT_NONE = 0,
+       DP_CONTENT_IMAGE,
+       DP_CONTENT_VIDEO,
+       DP_CONTENT_MUSIC,
+       DP_CONTENT_PDF,
+       DP_CONTENT_WORD,
+       DP_CONTENT_PPT, // 5
+       DP_CONTENT_EXCEL,
+       DP_CONTENT_HTML,
+       DP_CONTENT_TEXT,
+       DP_CONTENT_RINGTONE,
+       DP_CONTENT_DRM, // 10
+       DP_CONTENT_JAVA,
+       DP_CONTENT_SVG,
+       DP_CONTENT_FLASH,
+       DP_CONTENT_UNKOWN
+};
+
+namespace DL_TYPE{
+enum TYPE {
+       TYPE_NONE,
+       HTTP_DOWNLOAD,
+};
+}
+
+namespace ERROR {
+enum CODE {
+       NONE,
+       INVALID_URL,
+       NETWORK_FAIL,
+       NOT_ENOUGH_MEMORY,
+       FAIL_TO_INSTALL,
+       ENGINE_FAIL,
+       UNKNOWN
+};
+}
+
+#endif /* DOWNLOAD_MANAGER_DOWNLOAD_COMMON_H */
diff --git a/src/include/download-manager-dateTime.h b/src/include/download-manager-dateTime.h
new file mode 100644 (file)
index 0000000..1b0f0e8
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-dateTime.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      data and utility APIs for Date and Time
+ */
+
+#ifndef DOWNLOAD_MANAGER_DATE_TIME_H
+#define DOWNLOAD_MANAGER_DATE_TIME_H
+
+#include <time.h>
+#include <Elementary.h>
+#include <unicode/udat.h>
+#include <unicode/udatpg.h>
+#include <unicode/ustring.h>
+
+#include "download-manager-common.h"
+
+using namespace std;
+
+namespace DATETIME {
+enum {
+       DATE_TYPE_NONE = 0,
+       DATE_TYPE_LATER,
+       DATE_TYPE_TODAY,
+       DATE_TYPE_YESTERDAY,
+       DATE_TYPE_PREVIOUS,
+};
+}
+
+namespace LOCALE_STYLE{
+enum {
+       TIME = 0,
+       SHORT_DATE,
+       MEDIUM_DATE,
+       FULL_DATE
+};
+}
+
+class DateGroup {
+public:
+       DateGroup(void);
+       ~DateGroup(void);
+
+       Elm_Object_Item *glGroupItem() { return m_glGroupItem; }
+       void setGlGroupItem(Elm_Object_Item *i) { m_glGroupItem = i; }
+       void increaseCount(void) { count++; }
+       void decreaseCount(void) { count--; }
+       int getCount(void) { return count; }
+       void initData(void);
+       void setType(int t) { type = t; }
+       int getType(void) { return type; }
+
+private:
+       int count;
+       int type;
+       Elm_Object_Item *m_glGroupItem;
+};
+
+class DateUtil {
+public:
+       static DateUtil& getInstance(void) {
+               static DateUtil inst;
+               return inst;
+       }
+
+       inline void setTodayStandardTime(void) { m_todayStandardTime = time(NULL); }
+       int getDiffDaysFromToday(void);
+       int getDiffDays(time_t nowTime, time_t refTime);
+       void updateLocale(void);
+       void getDateStr(int style, double time, string &outBuf);
+       inline double nowTime(void) { return (double)(time(NULL)); }
+       /* yesterday is same to 24*60*60 seconds from now */
+       inline double yesterdayTime(void) { return (double)(time(NULL)+24*60*60); }
+
+private:
+       DateUtil(void);
+       ~DateUtil(void);
+
+       UDateFormat *getBestPattern(const char *patternStr,
+               UDateTimePatternGenerator *generator, const char *locale);
+       void deinitLocaleData(void);
+       /* Update this in case of follows
+        * 1. show main view.
+        * 2. add new item
+        * 3. create today group
+       **/
+       time_t m_todayStandardTime;
+       UDateFormat *dateShortFormat;
+       UDateFormat *dateMediumFormat;
+       UDateFormat *dateFullFormat;
+       UDateFormat *timeFormat12H;
+       UDateFormat *timeFormat24H;
+};
+
+#endif /* DOWNLOAD_MANAGER_DATE_TIME_H */
diff --git a/src/include/download-manager-debug.h b/src/include/download-manager-debug.h
new file mode 100644 (file)
index 0000000..286fca3
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-debug.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      debug function
+ */
+
+#ifndef DOWNLOAD_MANAGER_DEBUG_H
+#define DOWNLOAD_MANAGER_DEBUG_H
+
+#define _USE_DLOG 1
+
+#ifdef _USE_DLOG
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "DownloadManager"
+
+#define DP_LOG(format, args...) LOGI("[%s] "format, __func__, ##args)
+#define DP_LOGD(format, args...) LOGD("[%s] "format, __func__, ##args)
+#define DP_LOG_START(msg) LOGI("<<= [%s] Start =>>\n",msg)
+#define DP_LOG_FUNC() LOGI("<<= [%s]=>>\n",__func__)
+#define DP_LOGD_FUNC() LOGD("<<= [%s]=>>\n",__func__)
+#define DP_LOG_END(msg) LOGI("<<= [%s] End [%d] =>>\n",msg)
+#define DP_LOGE(format, args...) LOGE("[%s][ERR] "format, __func__, ##args)
+#define DP_LOG_TEST(format, args...) LOGI("####TEST####[%s] "format, __func__, ##args)
+
+#else
+
+#include <stdio.h>
+#include <pthread.h>
+
+#define DP_LOG(args...) do {\
+               printf("[DP:%s][LN:%d][%lu]",__func__,__LINE__,pthread_self());\
+               printf(args);printf("\n"); }while(0)
+#define DP_LOGD(args...) do {\
+               printf("[DP_D:%s][LN:%d][%lu]",__func__,__LINE__,pthread_self());\
+               printf(args);printf("\n");}while(0)
+#define DP_LOGE(args...) do {\
+               printf("[DP_ERR:%s][LN:%d][%lu]",__func__,__LINE__,pthread_self());\
+               printf(args);printf("\n");}while(0)
+#define DP_LOG_FUNC() do {\
+               printf("<<==[DP:%s][LN:%d][%lu] ==>> \n",__func__,__LINE__,pthread_self());\
+               }while(0)
+#define DP_LOGD_FUNC() do {\
+               printf("<<==[DP_D:%s][LN:%d][%lu] ==>> \n",__func__,__LINE__,pthread_self());\
+               }while(0)
+#define DP_LOG_START(msg) do {\
+               printf("<<==[DP:%s][LN:%d][%lu] Start ==>> \n",\
+               __FUNCTION__,__LINE__,pthread_self());\
+               }while(0)
+#define DP_LOG_END(msg) do {\
+               printf("<<==[DP:%s][LN:%d][%lu] End  ==>> \n",\
+               __FUNCTION__,__LINE__,pthread_self());\
+               }while(0)
+#endif /*_USE_DLOG*/
+
+#endif /* DOWNLOAD_MANAGER_DEBUG_H */
diff --git a/src/include/download-manager-downloadItem.h b/src/include/download-manager-downloadItem.h
new file mode 100644 (file)
index 0000000..6a3c7b5
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-downloadItem.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      download item class
+ */
+
+#ifndef DOWNLOAD_MANAGER_DOWNLOAD_ITEM_H
+#define DOWNLOAD_MANAGER_DOWNLOAD_ITEM_H
+
+#include <memory>
+#include "url_download.h"
+#include "download-manager-common.h"
+#include "download-manager-downloadRequest.h"
+#include "download-manager-event.h"
+
+namespace DL_ITEM {
+enum STATE {
+       IGNORE,
+       STARTED,
+       UPDATING,
+       COMPLETE_DOWNLOAD,
+       INSTALL_NOTIFY,
+       WAITING_RO,
+       SUSPENDED,
+       RESUMED,
+       FINISHED,
+       CANCELED,
+       FAILED
+};
+}
+
+class DownloadItem {
+public:
+       DownloadItem(); /* FIXME remove after cleanup ecore_pipe */
+       DownloadItem(auto_ptr<DownloadRequest> request);
+       ~DownloadItem();
+
+       void start(bool isRetry);
+       void cancel(void);
+       void retry(void);
+       void suspend(void);
+       void resume(void);
+
+       inline void *downloadHandle(void) { return (void *)m_download_handle;}
+       inline void setDownloadHandle(url_download_h handle) { m_download_handle = handle; }
+
+       inline unsigned long int receivedFileSize(void) { return m_receivedFileSize; }
+       inline void setReceivedFileSize(unsigned long int size) { m_receivedFileSize = size; }
+
+       inline unsigned long int fileSize(void) { return m_fileSize; }
+       inline void setFileSize(unsigned long int size) { m_fileSize = size; }
+
+       inline string &filePath(void) { return m_filePath; }
+       inline void setFilePath(const char *path) { if (path) m_filePath = path; }
+       inline void setFilePath(string &path) { m_filePath = path; }
+
+       inline string &contentName(void) { return m_contentName; }
+       inline void setContentName(string &name) { m_contentName = name; }
+
+       inline string &registeredFilePath(void) { return m_registeredFilePath; }
+       inline void setRegisteredFilePath(string &path) { m_registeredFilePath = path; }
+
+       inline string &mimeType(void) { return m_mimeType; }
+       inline void setMimeType(const char *mime) { m_mimeType = mime; }
+       inline void setMimeType(string &mime) { m_mimeType = mime; }
+
+       inline DL_ITEM::STATE state(void) { return m_state; }
+       inline void setState(DL_ITEM::STATE state) { m_state = state; }
+
+       inline ERROR::CODE errorCode(void) { return m_errorCode; }
+       inline void setErrorCode(ERROR::CODE err) { m_errorCode = err;  }
+       inline DL_TYPE::TYPE downloadType(void) { return m_downloadType; }
+       inline void setDownloadType(DL_TYPE::TYPE t) { m_downloadType = t;}
+
+       inline void notify(void) { m_subject.notify(); }
+       inline void subscribe(Observer *o) { if (o) m_subject.attach(o); }
+       inline void deSubscribe(Observer *o) { if (o) m_subject.detach(o); }
+       inline string &url(void) { return m_aptr_request->getUrl(); }
+       inline string &cookie(void) { return m_aptr_request->getCookie(); }
+
+       ERROR::CODE _convert_error(int err);
+
+       static void started_cb(url_download_h download, const char *name,
+               const char *mime, void *user_data);
+       static void paused_cb(url_download_h download, void *user_data);
+       static void completed_cb(url_download_h download, const char *path,
+               void *user_data);
+       static void stopped_cb(url_download_h download, url_download_error_e error,
+               void *user_data);
+       static void progress_cb(url_download_h download, unsigned long long received,
+               unsigned long long total, void *user_data);
+
+private:
+       auto_ptr<DownloadRequest> m_aptr_request;
+       Subject m_subject;
+       url_download_h m_download_handle;
+       DL_ITEM::STATE m_state;
+       ERROR::CODE m_errorCode;
+       unsigned long int m_receivedFileSize;
+       unsigned long int m_fileSize;
+       string m_filePath;
+       string m_contentName;
+       string m_registeredFilePath;
+       string m_mimeType;
+       DL_TYPE::TYPE m_downloadType;
+};
+
+class DownloadEngine {
+public:
+       static DownloadEngine &getInstance(void) {
+               static DownloadEngine downloadEngine;
+               return downloadEngine;
+       }
+
+       void initEngine(void);
+       void deinitEngine(void);
+private:
+       DownloadEngine(void);
+       ~DownloadEngine(void);
+
+};
+
+
+#endif /* DOWNLOAD_MANAGER_DOWNLOAD_ITEM_H */
diff --git a/src/include/download-manager-downloadRequest.h b/src/include/download-manager-downloadRequest.h
new file mode 100644 (file)
index 0000000..621718b
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-downloadRequest.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      Download Request class
+ */
+
+#ifndef DOWNLOAD_MANAGER_DOWNLOAD_REQUEST_H
+#define DOWNLOAD_MANAGER_DOWNLOAD_REQUEST_H
+
+#include <string>
+
+using namespace std;
+
+class DownloadRequest
+{
+public:
+//     DownloadRequest();
+       DownloadRequest(string url, string cookie);
+       DownloadRequest(DownloadRequest &rRequest);
+       ~DownloadRequest();
+
+       string &getUrl();
+       string &getCookie();
+       bool isUrlEmpty();
+       bool isCookieEmpty();
+       void setUrl(string url);
+       void setCookie(string cookie);
+private:
+       string m_url;
+       string m_cookie;
+};
+
+#endif /* DOWNLOAD_MANAGER_DOWNLOAD_REQUEST_H */
diff --git a/src/include/download-manager-event.h b/src/include/download-manager-event.h
new file mode 100644 (file)
index 0000000..ec7fe9f
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-event.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      Download event class
+ */
+#ifndef DOWNLOAD_MANAGER_EVENT_H
+#define DOWNLOAD_MANAGER_EVENT_H
+
+#include <vector>
+/* For debug */
+#include <string>
+
+using namespace std;
+
+class Observer;
+class Subject
+{
+public:
+       Subject(){}
+       ~Subject(){}
+
+       void attach(Observer *);
+       void detach(Observer *);
+       void notify(void);
+
+private:
+       vector<Observer*> _observers;
+};
+
+typedef void (*updateFunction)(void *data);
+
+class Observer
+{
+public:
+       /* For debug */
+       Observer(updateFunction uf, void *data, const char *name);
+       //Observer(updateFunction uf, void *data);
+       ~Observer(){}
+
+       void update(Subject *s);
+       void set(updateFunction uf, void *data);
+       void clear(void);
+       void *getUserData(void) { return m_userData; }
+       /* For debug */
+       string name(void) { return observerName; }
+
+private:
+       void call(void);
+
+       updateFunction m_updateFunction;
+       void *m_userData;
+       /* For debug */
+       string observerName;
+};
+
+#endif /* DOWNLOAD_MANAGER_EVENT_H */
diff --git a/src/include/download-manager-history-db.h b/src/include/download-manager-history-db.h
new file mode 100644 (file)
index 0000000..4e1e4e8
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-history-db.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      Manager for a download history DB
+ */
+
+#ifndef DOWNLOAD_MANAGER_HISTORY_DB_H
+#define DOWNLOAD_MANAGER_HISTORY_DB_H
+
+#include <string>
+#include <queue>
+#include <db-util.h>
+#include "download-manager-item.h"
+extern "C" {
+#include <unicode/utypes.h>
+}
+
+using namespace std;
+
+class DownloadHistoryDB
+{
+public:
+       static bool addToHistoryDB(Item *item);
+       static bool createRemainedItemsFromHistoryDB(int limit, int offset);
+       static bool createItemsFromHistoryDB(void);
+       static bool deleteItem(unsigned int historyId);
+       static bool deleteMultipleItem(queue <unsigned int> &q);
+       static bool clearData(void);
+       static bool getCountOfHistory(int *count);
+private:
+       DownloadHistoryDB(void);
+       ~DownloadHistoryDB(void);
+       static sqlite3* historyDb;
+       static bool open(void);
+       static bool isOpen(void) { return historyDb ? true : false; }
+       static void close(void);
+};
+
+#endif /* DOWNLOAD_MANAGER_HISTORY_DB_H */
+
diff --git a/src/include/download-manager-item.h b/src/include/download-manager-item.h
new file mode 100644 (file)
index 0000000..cc0b936
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-item.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      Item class
+ */
+#ifndef DOWNLOAD_MANAGER_ITEM_H
+#define DOWNLOAD_MANAGER_ITEM_H
+
+#include <string>
+#include <memory>
+#include "download-manager-event.h"
+#include "download-manager-downloadRequest.h"
+#include "download-manager-downloadItem.h"
+#include "download-manager-util.h"
+
+using namespace std;
+
+namespace ITEM {
+enum STATE {
+       IDLE = 0,
+       REQUESTING,
+       PREPARE_TO_RETRY,
+       RECEIVING_DOWNLOAD_INFO,
+       DOWNLOADING,
+       REGISTERING_TO_SYSTEM,
+       SUSPENDED,
+       FINISH_DOWNLOAD,
+       FAIL_TO_DOWNLOAD,
+       CANCEL,
+       PLAY,
+       DESTROY
+};
+}
+
+class Item {
+public:
+       static void create(DownloadRequest &rRequest);
+       static Item *createHistoryItem(void);
+       ~Item(void);
+
+       void attachHistoryItem(void);
+       void destroy(void);
+       /* SHOULD call this before destrying an item*/
+       void deleteFromDB(void);
+       void download(void);
+       inline void cancel(void)
+       {
+               if (m_aptr_downloadItem.get())
+                       m_aptr_downloadItem->cancel();
+               return;
+       }
+       void clearForRetry(void);
+       bool retry(void);
+
+       bool play(void);
+
+       inline void subscribe(Observer *o) { m_subjectForView.attach(o); }
+       inline void deSubscribe(Observer *o) { m_subjectForView.detach(o); }
+
+       static void updateCBForDownloadObserver(void *data);
+       static void netEventCBObserver(void *data);
+       void updateFromDownloadItem(void);
+       inline void suspend(void) { m_aptr_downloadItem->suspend(); }
+
+       inline int id(void) {
+               if (m_aptr_downloadItem.get())
+                       return (int)(m_aptr_downloadItem->downloadHandle());
+
+               return -1;
+       }       // FIXME create Item's own id
+
+       inline unsigned long int receivedFileSize(void) {
+               if (m_aptr_downloadItem.get())
+                       return m_aptr_downloadItem->receivedFileSize();
+               return 0;
+       }
+
+       inline unsigned long int fileSize(void) {
+               if (m_aptr_downloadItem.get())
+                       return m_aptr_downloadItem->fileSize();
+               return 0;
+       }
+
+       inline string &filePath(void) {
+               if (m_aptr_downloadItem.get())
+                       return m_aptr_downloadItem->filePath();
+               return m_emptyString;
+       }
+
+
+       inline string &contentName(void) {
+               if (m_aptr_downloadItem.get())
+                       return m_aptr_downloadItem->contentName();
+               return m_emptyString;
+       }
+
+       inline void setHistoryId(unsigned int i) { m_historyId = i; }
+       inline unsigned int historyId(void) { return m_historyId; }     // FIXME duplicated with m_id
+       inline string &title(void) {return m_title;}
+       inline void setTitle(string &title) { m_title = title; }
+       string &registeredFilePath(void);
+       inline void setRegisteredFilePath(string &r) { m_registeredFilePath = r; }
+       string &url(void);
+       string &cookie(void);
+       void setRetryData(string &url, string &cookie);
+       int contentType(void) { return m_contentType; }
+       inline void setContentType(int t) { m_contentType = t; }
+       DL_TYPE::TYPE downloadType(void);
+       inline void setDownloadType(DL_TYPE::TYPE t) { m_downloadType = t; }
+
+//     string &getIconPath(void) {return m_iconPath; }
+       inline string &iconPath(void) { return m_iconPath; }
+
+       inline void setState(ITEM::STATE state) { m_state = state; }
+       inline ITEM::STATE state(void) { return m_state; }
+
+       inline void setErrorCode(ERROR::CODE err) { m_errorCode = err; }
+       inline ERROR::CODE errorCode(void) { return m_errorCode; }
+       const char *getErrorMessage(void);
+       inline void setFinishedTime(double t) { m_finishedTime = t; }
+       inline double finishedTime(void) { return m_finishedTime; }
+
+       bool isFinished(void); /* include finish download state with error */
+       bool isFinishedWithErr(void);
+       bool isPreparingDownload(void); /* Before downloading start */
+       bool isCompletedDownload(void); /* After stating installation */
+
+       /* Test code */
+       const char *stateStr(void);
+
+private:
+       Item(void);
+       Item(DownloadRequest &rRequest);
+
+       inline void notify(void) { m_subjectForView.notify(); }
+
+       void createSubscribeData(void);
+       void extractTitle(void);
+       void extractIconPath(void);
+
+       void startUpdate(void);
+       void createHistoryId(void);
+       bool isExistedHistoryId(unsigned int id);
+       void handleFinishedItem(void);
+
+       auto_ptr<DownloadRequest> m_aptr_request;
+       auto_ptr<DownloadItem> m_aptr_downloadItem;
+       FileOpener m_fileOpener;
+
+       Subject m_subjectForView;
+       auto_ptr<Observer> m_aptr_downloadObserver;
+       auto_ptr<Observer> m_aptr_netEventObserver;
+
+       ITEM::STATE m_state;
+       ERROR::CODE m_errorCode;
+       string m_title;
+       unsigned int m_historyId;
+       int m_contentType;
+       string m_iconPath; // FIXME Later:is it right to exist here? (ViewItem or not)
+       string m_emptyString; // FIXME this is temporary to avoid crash when filePath() is called if m_aptr_downloaditem points nothing
+       double m_finishedTime;
+       DL_TYPE::TYPE m_downloadType;
+       string m_registeredFilePath;
+       string m_url;
+       string m_cookie;
+
+       bool m_gotFirstData;
+};
+
+#endif /* DOWNLOAD_MANAGER_ITEM_H */
diff --git a/src/include/download-manager-items.h b/src/include/download-manager-items.h
new file mode 100644 (file)
index 0000000..e431b51
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/*
+ * @file       download-manager-items.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief   item inventory class
+ */
+#ifndef DOWNLOAD_MANAGER_ITEMS_H
+#define DOWNLOAD_MANAGER_ITEMS_H
+
+#include "download-manager-item.h"
+#include <vector>
+
+class Items {
+public:
+       static Items& getInstance(void) {
+               static Items inst;
+               return inst;
+       }
+
+       void attachItem(Item *item);
+       void detachItem(Item *item);
+       bool isExistedHistoryId(unsigned int id);
+private:
+       Items(){}
+       ~Items(){DP_LOGD_FUNC();}
+
+       vector<Item*> m_items;
+};
+
+#endif /* DOWNLOAD_MANAGER_ITEMS_H */
diff --git a/src/include/download-manager-network.h b/src/include/download-manager-network.h
new file mode 100644 (file)
index 0000000..3bbf4b3
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-network.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      Download netowkr manager
+ */
+
+#ifndef DOWNLOAD_MANAGER_NETWORK_H
+#define DOWNLOAD_MANAGER_NETWORK_H
+
+#include "net_connection.h"
+#include "download-manager-event.h"
+
+class NetMgr {
+public:
+       static NetMgr& getInstance(void) {
+               static NetMgr inst;
+               return inst;
+       }
+       void initNetwork(void);
+       void deinitNetwork(void);
+       inline void subscribe(Observer *o) { m_subject.attach(o); }
+       inline void deSubscribe(Observer *o) { m_subject.detach(o); }
+       static void netTypeChangedCB(connection_type_e type, void *data);
+       static void netConfigChangedCB(const char *ip,
+               const char *ipv6, void *data);
+private:
+       NetMgr(void);
+       ~NetMgr(void);
+       void netTypeChanged(void);
+       void netConfigChanged(string ip);
+       int getConnectionState(void);
+       int getCellularStatus(void);
+       int getWifiStatus(void);
+       void getProxy(void);
+       void getIPAddress(void);
+       inline void notify(void) { m_subject.notify(); }
+       int m_netStatus;
+       Subject m_subject;
+       connection_h m_handle;
+};
+
+#endif
diff --git a/src/include/download-manager-util.h b/src/include/download-manager-util.h
new file mode 100644 (file)
index 0000000..b1babaa
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * Copyright 2012  Samsung Electronics Co., Ltd\r
+ *\r
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license\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
+ * @file       download-manager-util.h\r
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)\r
+ * @brief   Utility APIs and interface with content player\r
+ */\r
+\r
+#ifndef DOWNLOAD_MANAGER_UTIL_H\r
+#define DOWNLOAD_MANAGER_UTIL_H\r
+\r
+#include <string>\r
+#include "download-manager-common.h"\r
+\r
+using namespace std;\r
+class FileOpener {\r
+public:\r
+       FileOpener() {}\r
+       ~FileOpener() {}\r
+\r
+       bool openFile(string &path, int contentType);\r
+};\r
+\r
+class DownloadUtil\r
+{\r
+public:\r
+       static DownloadUtil& getInstance(void) {\r
+               static DownloadUtil inst;\r
+               return inst;\r
+       }\r
+\r
+       int getContentType(const char *mimem, const char *filePath);\r
+       void registerContent(string filePath);\r
+\r
+private:\r
+       DownloadUtil(void);\r
+       ~DownloadUtil(void) {}\r
+       bool isAmbiguousMIMEType(const char *mimeType);\r
+};\r
+\r
+#endif//DOWNLOAD_MANAGER_UTIL_H\r
diff --git a/src/include/download-manager-view.h b/src/include/download-manager-view.h
new file mode 100644 (file)
index 0000000..bb7d20f
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-view.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      Download UI View manager
+ */
+
+#ifndef DOWNLOAD_MANAGER_VIEW_H
+#define DOWNLOAD_MANAGER_VIEW_H
+
+#include <Elementary.h>
+#include <libintl.h>
+
+#include <vector>
+#include "download-manager-common.h"
+#include "download-manager-viewItem.h"
+#include "download-manager-dateTime.h"
+
+enum {
+       POPUP_EVENT_EXIT = 0,
+       POPUP_EVENT_ERR,
+};
+
+class DownloadView {
+public:
+       static DownloadView& getInstance(void) {
+               static DownloadView inst;
+               return inst;
+       }
+
+       Evas_Object *create(void);
+       void destroy(void);
+       void createView(void);
+       void activateWindow(void);
+#ifndef _TIZEN_PUBLIC
+       void rotateWindow(int angle);
+#endif
+       void show(void);
+       void hide(void);
+
+       void attachViewItem(ViewItem *viewItem);
+       void detachViewItem(ViewItem *viewItem);
+
+       void changedRegion(void);
+       void showErrPopup(string &desc);
+       void update();
+       void update(ViewItem *viewItem);
+       void update(Elm_Object_Item *glItem);
+       void showViewItem(int id, const char *title);
+       void playContent(int id, const char *title);
+       void handleChangedAllCheckedState(void);
+       void handleCheckedState(void);
+       bool isGenlistEditMode(void);
+       void handleGenlistGroupItem(int type);
+#ifndef _TIZEN_PUBLIC
+       void setSweepedItem(ViewItem *item) { m_sweepedItem = item; }
+       ViewItem *sweepedItem(void) { return m_sweepedItem; }
+#endif
+       void moveRetryItem(ViewItem *viewItem);
+       static char *getGenlistGroupLabelCB(void *data, Evas_Object *obj,
+               const char *part);
+
+private:
+       static void showNotifyInfoCB(void *data, Evas *evas, Evas_Object *obj, void *event);
+       static void hideNotifyInfoCB(void *data, Evas *evas, Evas_Object *obj, void *event);
+#ifndef _TIZEN_PUBLIC
+       static void sweepRightCB(void *data, Evas_Object *obj, void *event_info);
+       static void sweepLeftCB(void *data, Evas_Object *obj, void *event_info);
+#endif
+       static void backBtnCB(void *data, Evas_Object *obj, void *event_info);
+       static void cbItemDeleteCB(void *data, Evas_Object *obj, void *event_info);
+       static void cbItemCancelCB(void *data, Evas_Object *obj, void *event_info);
+       static void selectAllClickedCB(void *data, Evas *evas, Evas_Object *obj,
+               void *event_info);
+       static void selectAllChangedCB(void *data, Evas_Object *obj,
+               void *event_info);
+       static void genlistClickCB(void *data, Evas_Object *obj, void *event_info);
+       static void cancelClickCB(void *data, Evas_Object *obj, void *event_info);
+       static void errPopupResponseCB(void *data, Evas_Object *obj, void *event_info);
+
+private:
+       DownloadView();
+       ~DownloadView();
+
+       inline void destroyEvasObj(Evas_Object *e) { if(e) evas_object_del(e); e = NULL;}
+       void setTheme(void);
+       void setIndicator(Evas_Object *window);
+       Evas_Object *createWindow(const char *windowName);
+       Evas_Object *createBackground(Evas_Object *window);
+       Evas_Object *createLayout(Evas_Object *parent);
+       void createTheme(void);
+       void createNaviBar(void);
+       void createBackBtn(void);
+       void createControlBar(void);
+       void createBox(void);
+       void createList(void);
+
+       void removeTheme(void);
+
+       void addViewItemToGenlist(ViewItem *viewItem);
+       void createGenlistItem(ViewItem *viewItem);
+       void showEmptyView(void);
+       void hideEmptyView(void);
+
+       void removePopup(void);
+       void showGenlistEditMode(void);
+       void hideGenlistEditMode(void);
+#ifndef _TIZEN_PUBLIC
+       void cancelSweepEvent(void);
+#endif
+       void createSelectAllLayout(void);
+       void changeAllCheckedValue(void);
+       void destroyCheckedItem(void);
+       void showNotifyInfo(int type, int selectedCount);
+       void destroyNotifyInfo(void);
+       void createNotifyInfo(void);
+
+       DateGroup *getDateGroupObj(int type);
+       Elm_Object_Item *getGenlistGroupItem(int type);
+       int getGenlistGroupCount(int type);
+       void setGenlistGroupItem(int type, Elm_Object_Item *item);
+       void increaseGenlistGroupCount(int type);
+       void handleUpdateDateGroupType(ViewItem *viewItem);
+       void cleanGenlistData();
+       char *getGenlistGroupLabel(void *data, Evas_Object *obj, const char *part);
+#ifndef _TIZEN_PUBLIC
+       ViewItem *findViewItemForGenlistItem(Elm_Object_Item *glItem);
+#endif
+
+       Evas_Object *eoWindow;
+       Evas_Object *eoBackground;
+       Evas_Object *eoLayout;
+       Elm_Theme *eoTheme;
+
+       Evas_Object *eoEmptyNoContent;
+       Evas_Object *eoNaviBar;
+       Elm_Object_Item *eoNaviBarItem;
+       Evas_Object *eoBackBtn;
+       Evas_Object *eoControlBar;
+       Elm_Object_Item *eoCbItemDelete;
+       Elm_Object_Item *eoCbItemCancel;
+       Elm_Object_Item *eoCbItemEmpty;
+       Evas_Object *eoBoxLayout;
+       Evas_Object *eoBox;
+       Evas_Object *eoDldList;
+       Evas_Object *eoPopup;
+       Evas_Object *eoSelectAllLayout;
+       Evas_Object *eoAllCheckedBox;
+       Evas_Object *eoNotifyInfo;
+       Evas_Object *eoNotifyInfoLayout;
+       Elm_Genlist_Item_Class dldGenlistGroupStyle;
+       Eina_Bool m_allChecked;
+#ifndef _TIZEN_PUBLIC
+       ViewItem *m_sweepedItem;
+#endif
+
+       int m_viewItemCount;
+       DateGroup m_today;
+       DateGroup m_yesterday;
+       DateGroup m_previousDay;
+};
+
+#endif /* DOWNLOAD_MANAGER_VIEW_H */
diff --git a/src/include/download-manager-viewItem.h b/src/include/download-manager-viewItem.h
new file mode 100644 (file)
index 0000000..67890ce
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       download-manager-viewItem.h
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      Item class for Download view
+ */
+
+#ifndef DOWNLOAD_MANAGER_VIEW_ITEM_H
+#define DOWNLOAD_MANAGER_VIEW_ITEM_H
+
+#include "download-manager-event.h"
+#include "download-manager-item.h"
+#include <Elementary.h>
+#include <memory>
+
+using namespace std;
+
+class ViewItem {
+public:
+       ~ViewItem();
+       static void create(Item *item);
+       void destroy(void);
+       inline void deleteFromDB(void) { m_item->deleteFromDB(); }
+
+       inline void setItem(Item *item) { m_item = item; }
+       static void updateCB(void *);
+
+
+       static char *getGenlistLabelCB(void *data, Evas_Object *obj,
+               const char *part);
+       char *getGenlistLabel(Evas_Object *obj, const char *part);
+
+       static Evas_Object *getGenlistIconCB(void *data, Evas_Object *obj,
+               const char *part);
+       Evas_Object *getGenlistIcon(Evas_Object *obj, const char *part);
+
+       static void checkChangedCB(void *data, Evas_Object *obj, void *event_info);
+
+#ifndef _TIZEN_PUBLIC
+       void sweepRight(void);
+       void sweepLeft(void);
+#endif
+
+       const char *getMessage(void);
+       const char *getBytesStr(void);
+       const char *getHumanFriendlyBytesStr(unsigned long int bytes,
+               bool progressOption);
+
+       Elm_Genlist_Item_Class *elmGenlistStyle(void);
+
+       inline Elm_Genlist_Item_Class *elmGenlistItemClass(void)
+               { return &dldGenlistStyle; }
+       inline Elm_Genlist_Item_Class *elmGenlistHistoryItemClass(void)
+               { return &dldHistoryGenlistStyle; }
+       inline Elm_Genlist_Item_Class *elmGenlistFailedItemClass(void)
+               { return &dldGenlistSlideStyle; }
+       inline ITEM::STATE state(void) { return m_item->state(); }
+       inline const char* stateStr(void) { return m_item->stateStr(); }
+       inline bool isFinished(void) { return m_item->isFinished(); }
+       inline bool isFinishedWithErr(void) { return m_item->isFinishedWithErr(); }
+       inline bool isPreparingDownload(void) { return m_item->isPreparingDownload(); }
+       inline bool isCompletedDownload(void) { return m_item->isCompletedDownload(); }
+
+       unsigned long int receivedFileSize(void);
+       unsigned long int fileSize(void);
+       const char *getTitle(void);
+       inline const char *getErrMsg(void) { return m_item->getErrorMessage(); }
+       const char *getIconPath(void) { return m_item->iconPath().c_str(); }
+
+       inline Elm_Object_Item *genlistItem(void) { return m_glItem; }
+       inline void setGenlistItem(Elm_Object_Item *glItem) { m_glItem = glItem; }
+       inline void setProgressBar(Evas_Object *p) { m_progressBar = p; }
+
+       void clickedDeleteButton(void);
+       void clickedCancelButton(void);
+       void clickedRetryButton(void);
+       void clickedGenlistItem(void);
+       void requestCancel(void);
+       inline Eina_Bool checkedValue(void) { return m_checked; }
+       void setCheckedValue(Eina_Bool b) { m_checked = b; }
+       inline Evas_Object *checkedBtn(void) { return m_checkedBtn; }
+       void setCheckedBtn(Evas_Object *e) { m_checkedBtn = e; }
+
+       void updateCheckedBtn(void);
+
+       inline int dateGroupType(void) { return m_dateGroupType; }
+       void setDateGroupType (int t) { m_dateGroupType = t; }
+
+       inline double finishedTime(void) { return m_item->finishedTime();}
+       void extractDateGroupType(void);
+
+       inline unsigned int historyId(void) { return m_item->historyId(); }
+private:
+       ViewItem(Item *item);
+
+       void updateFromItem(void);
+       Evas_Object *createProgressBar(Evas_Object *parent);
+#ifndef _TIZEN_PUBLIC
+       Evas_Object *createDeleteBtn(Evas_Object *parent);
+       Evas_Object *createRetryBtn(Evas_Object *parent);
+#endif
+       Evas_Object *createCancelBtn(Evas_Object *parent);
+       void retryViewItem(void);
+
+       static void deleteBtnClickedCB(void *data, Evas_Object *obj,
+               void *event_info);
+       static void cancelBtnClickedCB(void *data, Evas_Object *obj,
+               void *event_info);
+       static void retryBtnClickedCB(void *data, Evas_Object *obj,
+               void *event_info);
+
+       auto_ptr<Observer> m_aptr_observer;
+       Item *m_item;
+
+       Elm_Genlist_Item_Class dldGenlistStyle;
+       Elm_Genlist_Item_Class dldHistoryGenlistStyle;
+       Elm_Genlist_Item_Class dldGenlistSlideStyle;
+       Elm_Object_Item *m_glItem;
+       Evas_Object *m_progressBar;
+       Evas_Object *m_checkedBtn;
+       Eina_Bool m_checked;
+       bool m_isRetryCase;
+       int m_dateGroupType;
+};
+
+#endif /* DOWNLOAD_MANAGER_VIEW_ITEM_H */
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644 (file)
index 0000000..e80f3d4
--- /dev/null
@@ -0,0 +1,261 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
+ *
+ * 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.
+ */
+
+/**
+ * @file       main.cpp
+ * @author     Jungki Kwak (jungki.kwak@samsung.com)
+ * @brief      main file for download manager
+ */
+
+#include <list>
+#include <string>
+#include <iostream>
+#include <memory>
+
+#include "Ecore_X.h"
+#include "aul.h"
+#include "app.h"
+#include "app_service.h"
+
+#include "download-manager-common.h"
+#include "download-manager-view.h"
+#include "download-manager-network.h"
+#include "download-manager-downloadRequest.h"
+#include "download-manager-history-db.h"
+
+using namespace std;
+
+struct app_data_t {
+       Ecore_Idler *idler;
+       int history_count;
+       int load_count;
+};
+
+#ifndef _TIZEN_PUBLIC
+int __get_rotate_angle()
+{
+       int angle = 0;
+       app_device_orientation_e rotation_state;
+       rotation_state = app_get_device_orientation();
+
+       DP_LOG("Rotate angle[%d]",rotation_state);
+       return rotation_state;
+}
+
+static void __rotate_changed_cb(app_device_orientation_e m, void *data)
+{
+       int angle = 0;
+       DownloadView &view = DownloadView::getInstance();
+       angle = __get_rotate_angle();
+       view.rotateWindow(angle);
+       return;
+}
+#endif
+
+static void __lang_changed_cb(void *data)
+{
+       DP_LOG("=== Language changed nofification ===");
+       return;
+}
+
+static void __region_changed_cb(void *data)
+{
+       DownloadView &view = DownloadView::getInstance();
+       view.changedRegion();
+       DP_LOG("=== Region changed nofification ===");
+       return;
+}
+
+static void __low_memory_cb(void *data)
+{
+       DP_LOG("=== Low memory nofification ===");
+       return;
+}
+
+static Eina_Bool __load_remained_history(void *data)
+{
+       struct app_data_t *app_data = (struct app_data_t *)data;
+       if (app_data && app_data->load_count <= app_data->history_count) {
+               app_data->load_count += LOAD_HISTORY_COUNT;
+               DownloadHistoryDB::createRemainedItemsFromHistoryDB(
+                       LOAD_HISTORY_COUNT, app_data->load_count);
+               return ECORE_CALLBACK_RENEW;
+       } else
+               return ECORE_CALLBACK_CANCEL;
+}
+
+static bool __app_create(void *data)
+{
+       int count = 0;
+#ifndef _TIZEN_PUBLIC
+       int angle = 0;
+#endif
+       struct app_data_t *app_data = (struct app_data_t *)data;
+       DP_LOG_START("App Create");
+
+       DownloadView &view = DownloadView::getInstance();
+       Evas_Object *window = view.create();
+       if (!window) {
+               DP_LOGE("Fail to create main window");
+               return false;
+       }
+       /* Init network */
+       NetMgr &netObj = NetMgr::getInstance();
+       netObj.initNetwork();
+
+#ifndef _TIZEN_PUBLIC
+       angle = __get_rotate_angle();
+       view.rotateWindow(angle);
+#endif
+#ifndef _SILENT_LAUNCH
+       evas_object_show(window);
+       view.show();
+#endif
+
+       DownloadHistoryDB::getCountOfHistory(&count);
+       if (count > 0) {
+               DownloadHistoryDB::createItemsFromHistoryDB();
+               if (count > LOAD_HISTORY_COUNT) {
+                       if (app_data) {
+                               app_data->history_count = count;
+                               app_data->idler = ecore_idler_add(__load_remained_history, app_data);
+                       }
+               }
+       }
+
+       DP_LOG_END("App Create");
+
+       return true;
+}
+
+static void __app_terminate(void *data)
+{
+       DP_LOG_FUNC();
+       struct app_data_t *app_data = (struct app_data_t *)data;
+       NetMgr &netObj = NetMgr::getInstance();
+       netObj.deinitNetwork();
+       DownloadView &view = DownloadView::getInstance();
+       view.destroy();
+       if (app_data && app_data->idler)
+               ecore_idler_del(app_data->idler);
+       if (app_data) {
+               free(app_data);
+               app_data = NULL;
+       }
+       return;
+}
+
+static void __app_pause(void *data)
+{
+       DP_LOG_FUNC();
+       return;
+}
+
+static void __app_resume(void *data)
+{
+       return;
+}
+
+static void __app_service(service_h s, void *data)
+{
+       string s_url = std::string();
+       string s_cookie = std::string();
+       char *url = NULL;
+       char *cookie = NULL;
+       char *mode = NULL;
+       char *app_op = NULL;
+       DownloadView &view = DownloadView::getInstance();
+
+       DP_LOG_FUNC();
+
+       if (service_get_operation(s, &app_op) < 0) {
+               DP_LOGE("Fail to get service operation");
+               return;
+       }
+       DP_LOG("operation[%s]", app_op);
+
+       if (service_get_uri(s, &url) < 0) {
+               DP_LOGE("Invalid URL");
+       } else {
+               DP_LOG("url[%s]",url);
+               if (url)
+                       s_url = url;
+       }
+
+       if (service_get_extra_data(s, "cookie", &cookie) < 0) {
+               DP_LOG("No cookie");
+       } else {
+               DP_LOG("cookie[%s]",cookie);
+               if (cookie)
+                       s_cookie = cookie;
+       }
+
+       if (service_get_extra_data(s, "mode", &mode) < 0) {
+               DP_LOG("No mode");
+       } else {
+               DP_LOG("mode[%s]",mode);
+               if ( 0 == strncmp(mode, "view", strlen("view"))) {
+                       DP_LOG("View mode");
+                       view.activateWindow();
+                       return;
+               }
+               DP_LOGE("Invalid mode");
+               view.activateWindow();
+               return;
+       }
+
+       DownloadRequest request(s_url, s_cookie);
+       Item::create(request);
+#ifndef _SILENT_LAUNCH
+       view.activateWindow();
+#endif
+
+       return;
+}
+
+int main(int argc, char *argv[])
+{
+       app_event_callback_s evt_cb = {0,};
+       int ret = 0;
+       struct app_data_t *app_data = NULL;
+
+       app_data = (struct app_data_t *)calloc(1, sizeof(struct app_data_t));
+       if (!app_data) {
+               DP_LOGE("Fail to calloc of app data");
+               return ret;
+       }
+
+       evt_cb.create = __app_create;
+       evt_cb.terminate = __app_terminate;
+       evt_cb.pause = __app_pause;
+       evt_cb.resume = __app_resume;
+       evt_cb.service = __app_service;
+       evt_cb.low_memory = __low_memory_cb;
+       evt_cb.low_battery = NULL;
+#ifndef _TIZEN_PUBLIC
+       evt_cb.device_orientation = __rotate_changed_cb;
+#else
+       evt_cb.device_orientation = NULL;
+#endif
+       evt_cb.language_changed = __lang_changed_cb;
+       evt_cb.region_format_changed = __region_changed_cb;
+
+       ret = app_efl_main(&argc, &argv, &evt_cb, app_data);
+       DP_LOG("Main return");
+
+       return ret;
+}
+