[Installer] Add installation drm file
authorSoyoung Kim <sy037.kim@samsung.com>
Mon, 15 Oct 2012 07:28:10 +0000 (16:28 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Mon, 5 Nov 2012 08:32:08 +0000 (17:32 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] Add installation drm file
 - installation task fixed because drm file.
 - Parsing config.xml task hold off unzip widget file.
[SCMRequest] This commit should be released with wrt-commons

31 files changed:
etc/CMakeLists.txt
etc/drm/armv7l/libdrm-service-core-intel.so [new symlink]
etc/drm/armv7l/libdrm-service-core-intel.so.0 [new symlink]
etc/drm/armv7l/libdrm-service-core-intel.so.0.0.0 [new file with mode: 0755]
etc/drm/ix86/libdrm-service-core-intel.so [new symlink]
etc/drm/ix86/libdrm-service-core-intel.so.0 [new symlink]
etc/drm/ix86/libdrm-service-core-intel.so.0.0.0 [new file with mode: 0755]
packaging/wrt-installer.spec
src/CMakeLists.txt
src/commons/drm/CPointerArray.h [new file with mode: 0755]
src/commons/drm/CXMLAttribute.h [new file with mode: 0755]
src/commons/drm/CXMLElement.h [new file with mode: 0755]
src/commons/drm/CXMLFile.h [new file with mode: 0755]
src/commons/drm/InkaTypes.h [new file with mode: 0755]
src/commons/drm/IntelDrm_Core.h [new file with mode: 0755]
src/commons/drm/drm-intel-crypto-util.h [new file with mode: 0755]
src/commons/drm/drm-intel-util.h [new file with mode: 0755]
src/commons/drm/drm-oem-intel.h [new file with mode: 0755]
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/job_widget_install.h
src/jobs/widget_install/task_ace_check.cpp
src/jobs/widget_install/task_certify.cpp
src/jobs/widget_install/task_encrypt_resource.cpp
src/jobs/widget_install/task_file_manipulation.cpp
src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_widget_config.cpp
src/jobs/widget_install/widget_unzip.cpp [new file with mode: 0644]
src/jobs/widget_install/widget_unzip.h [new file with mode: 0644]
src/jobs/widget_uninstall/job_widget_uninstall.cpp
src/misc/widget_location.cpp
src/misc/widget_location.h

index 370d4af..adccb68 100644 (file)
@@ -1,3 +1,10 @@
 SET(ETC_DIR ${PROJECT_SOURCE_DIR}/etc)
 
 INSTALL(PROGRAMS ${ETC_DIR}/wrt_preinstall_widgets.sh DESTINATION /etc/rc.d/init.d)
+
+# Below Code is temporary. When DRM engine is provided it will be removed.
+IF("${ARCH}" MATCHES "arm")
+       INSTALL(FILES ${ETC_DIR}/drm/armv7l/libdrm-service-core-intel.so.0.0.0 DESTINATION lib)
+ELSE("${ARCH}" MATCHES "arm")
+       INSTALL(FILES ${ETC_DIR}/drm/ix86/libdrm-service-core-intel.so.0.0.0 DESTINATION lib)
+ENDIF("${ARCH}" MATCHES "arm")
diff --git a/etc/drm/armv7l/libdrm-service-core-intel.so b/etc/drm/armv7l/libdrm-service-core-intel.so
new file mode 120000 (symlink)
index 0000000..df92fda
--- /dev/null
@@ -0,0 +1 @@
+libdrm-service-core-intel.so.0
\ No newline at end of file
diff --git a/etc/drm/armv7l/libdrm-service-core-intel.so.0 b/etc/drm/armv7l/libdrm-service-core-intel.so.0
new file mode 120000 (symlink)
index 0000000..4af898f
--- /dev/null
@@ -0,0 +1 @@
+libdrm-service-core-intel.so.0.0.0
\ No newline at end of file
diff --git a/etc/drm/armv7l/libdrm-service-core-intel.so.0.0.0 b/etc/drm/armv7l/libdrm-service-core-intel.so.0.0.0
new file mode 100755 (executable)
index 0000000..68b76cf
Binary files /dev/null and b/etc/drm/armv7l/libdrm-service-core-intel.so.0.0.0 differ
diff --git a/etc/drm/ix86/libdrm-service-core-intel.so b/etc/drm/ix86/libdrm-service-core-intel.so
new file mode 120000 (symlink)
index 0000000..df92fda
--- /dev/null
@@ -0,0 +1 @@
+libdrm-service-core-intel.so.0
\ No newline at end of file
diff --git a/etc/drm/ix86/libdrm-service-core-intel.so.0 b/etc/drm/ix86/libdrm-service-core-intel.so.0
new file mode 120000 (symlink)
index 0000000..4af898f
--- /dev/null
@@ -0,0 +1 @@
+libdrm-service-core-intel.so.0.0.0
\ No newline at end of file
diff --git a/etc/drm/ix86/libdrm-service-core-intel.so.0.0.0 b/etc/drm/ix86/libdrm-service-core-intel.so.0.0.0
new file mode 100755 (executable)
index 0000000..d21a059
Binary files /dev/null and b/etc/drm/ix86/libdrm-service-core-intel.so.0.0.0 differ
index 068d546..46743bc 100644 (file)
@@ -35,8 +35,12 @@ BuildRequires:  pkgconfig(tapi)
 BuildRequires:  pkgconfig(shortcut)
 BuildRequires:  pkgconfig(dpl-encryption)
 BuildRequires:  pkgconfig(capi-appfw-app-manager)
+BuildRequires:  pkgconfig(drm-client)
+BuildRequires:  pkgconfig(drm-trusted)
 Requires: xmlsec1
 
+Provides: libdrm-service-core-intel.so.0
+
 %description
 Description: Wrt Installer for Tizen apps and Wac apps
 
@@ -44,12 +48,20 @@ Description: Wrt Installer for Tizen apps and Wac apps
 %setup -q
 
 %build
+# for drm temporary code
+%ifarch %{ix86}
+BUILD_ARCH_=x86
+%else
+BUILD_ARCH_=arm
+%endif
+
 export LDFLAGS+="-Wl,--rpath=/usr/lib -Wl,--hash-style=both -Wl,--as-needed"
 LDFLAGS="$LDFLAGS"
 
 cmake . -DCMAKE_INSTALL_PREFIX=/usr \
         -DDPL_LOG=ON \
         -DCMAKE_PACKAGE_VERSION=%{version} \
+        -DARCH="$BUILD_ARCH_" \
         -DCMAKE_BUILD_TYPE=%{?build_type:%build_type}
 make %{?jobs:-j%jobs}
 
@@ -75,6 +87,14 @@ mkdir -p /opt/share/widget/temp_info
 ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc3.d/S46lwrt_preinstall_widgets.sh
 ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc5.d/S46lwrt_preinstall_widgets.sh
 
+# for drm temporary code
+mkdir -p /opt/var/drm/inteldrm
+mkdir -p own 0:5000 /opt/var/drm/inteldrm
+chmod 755 /opt/var/drm/inteldrm
+
+ln -s /usr/lib/libdrm-service-core-intel.so.0.0.0 /usr/lib/libdrm-service-core-intel.so.0
+ln -s /usr/lib/libdrm-service-core-intel.so.0 /usr/lib/libdrm-service-core-intel.so
+
 %files
 %manifest wrt-installer.manifest
 %attr(755,root,root) %{_bindir}/wrt-installer
@@ -82,3 +102,5 @@ ln -s /etc/rc.d/init.d/wrt_preinstall_widgets.sh /etc/rc.d/rc5.d/S46lwrt_preinst
 %attr(644,root,root) %{_datadir}/edje/wrt/*
 /usr/etc/package-manager/backendlib/libwgt.so
 %{_datadir}/license/%{name}
+# for drm temporary code
+/usr/lib/*.so*
index 929571e..b77d47e 100644 (file)
@@ -45,6 +45,7 @@ SET(INSTALLER_INCLUDES
     ${INSTALLER_SRC_DIR}/configuration_parser
     ${INSTALLER_SRC_DIR}/wrt-installer
     ${INSTALLER_SRC_DIR}/commons
+    ${INSTALLER_SRC_DIR}/commons/drm    #this is temporary code for drm
     ${INSTALLER_SRC_DIR}/pkg-manager
 )
 
@@ -127,6 +128,8 @@ PKG_CHECK_MODULES(INSTALLER_STATIC_DEP
     tapi
     shortcut
     capi-appfw-app-manager
+    drm-client
+    drm-trusted
     REQUIRED
     )
 
@@ -147,6 +150,17 @@ TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC}
     ${INSTALLER_STATIC_DEP_LIBRARIES}
     )
 
+
+# Below Code is temporary. When DRM engine is provided it will be removed.
+MESSAGE("ARCH ${ARCH}")
+IF("${ARCH}" MATCHES "arm")
+       TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC}
+            "-L${PROJECT_SOURCE_DIR}/etc/drm/armv7l -ldrm-service-core-intel" -Wl,--allow-shlib-undefine)
+ELSE("${ARCH}" MATCHES "arm")
+       TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC}
+            "-L${PROJECT_SOURCE_DIR}/etc/drm/ix86 -ldrm-service-core-intel" -Wl,--allow-shlib-undefine)
+ENDIF("${ARCH}" MATCHES "arm")
+
 SET_TARGET_PROPERTIES(${TARGET_INSTALLER_STATIC} PROPERTIES
         COMPILE_FLAGS -fPIC)
 
diff --git a/src/commons/drm/CPointerArray.h b/src/commons/drm/CPointerArray.h
new file mode 100755 (executable)
index 0000000..3e30e79
--- /dev/null
@@ -0,0 +1,52 @@
+\r
+/********************************************************************************\r
+* Copyright ? 2004-2009 by INKA Entworks, Inc (www.inka.co.kr).                                        *\r
+* All rights reserved.                                                                 * \r
+*                                                                                              * \r
+* No parts of this source code may be in any way copied, reproduced, modified  *\r
+* or distributed without the prior written consent of INKA Entworks, Inc.      *\r
+* CPointerArray.h: interface for the CPointerArray class.                                              *\r
+*********************************************************************************/ \r
+\r
+#ifndef __CPOINTERARRAY_H__\r
+#define __CPOINTERARRAY_H__\r
+\r
+\r
+#if !defined(AFX_CPOINTERARRAY_H__AB67E4BE_A233_4E3E_B257_9830D90326EE__INCLUDED_)\r
+#define AFX_CPOINTERARRAY_H__AB67E4BE_A233_4E3E_B257_9830D90326EE__INCLUDED_\r
+\r
+#if _MSC_VER > 1000\r
+#pragma once\r
+#endif // _MSC_VER > 1000\r
+\r
+//#include "Shp.h"\r
+#include "InkaTypes.h"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif /* __cplusplus */\r
+\r
+class CPointerArray  \r
+{\r
+protected:\r
+       LPVOID*                                         m_ppData;\r
+       int                                                     m_nMaxSize;\r
+       int                                                     m_nNumOfData;\r
+\r
+public:\r
+       CPointerArray();\r
+       virtual ~CPointerArray();\r
+\r
+       int                                     Add( LPVOID pData );\r
+       int                                     Remove( int nIndex );\r
+       LPVOID                          Get( int nIndex );\r
+       inline int                      GetCount() { return m_nNumOfData; }\r
+       inline void                     RemoveAll() { m_nNumOfData = 0; }\r
+};\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif  /* __cplusplus */\r
+\r
+#endif // !defined(AFX_CPOINTERARRAY_H__AB67E4BE_A233_4E3E_B257_9830D90326EE__INCLUDED_)\r
+#endif /* __CPOINTERARRAY_H__ */\r
diff --git a/src/commons/drm/CXMLAttribute.h b/src/commons/drm/CXMLAttribute.h
new file mode 100755 (executable)
index 0000000..dda8fe3
--- /dev/null
@@ -0,0 +1,37 @@
+\r
+/********************************************************************************\r
+* Copyright ? 2004-2009 by INKA Entworks, Inc (www.inka.co.kr).                                        *\r
+* All rights reserved.                                                                 * \r
+*                                                                                              * \r
+* No parts of this source code may be in any way copied, reproduced, modified  *\r
+* or distributed without the prior written consent of INKA Entworks, Inc.      *\r
+* CXMLAttribute.h: interface for the CXMLAttribute class.                                              *\r
+*********************************************************************************/ \r
+//#include "Shp.h"\r
+#include "InkaTypes.h"\r
+\r
+#if !defined(AFX_CXMLATTRIBUTE_H__2B925786_3613_47B0_B85D_CAF2053F46DB__INCLUDED_)\r
+#define AFX_CXMLATTRIBUTE_H__2B925786_3613_47B0_B85D_CAF2053F46DB__INCLUDED_\r
+\r
+#if _MSC_VER > 1000\r
+#pragma once\r
+#endif // _MSC_VER > 1000\r
+\r
+class CXMLAttribute  \r
+{\r
+protected:\r
+       LPTSTR                                                  m_pszName;\r
+       LPTSTR                                                  m_pszValue;\r
+\r
+public:\r
+       CXMLAttribute();\r
+       virtual ~CXMLAttribute();\r
+\r
+       int                                             SetName( LPCTSTR pszName );\r
+       int                                             SetValue( LPCTSTR pszValue );\r
+\r
+       inline LPCTSTR                  GetName() { return m_pszName; }\r
+       inline LPCTSTR                  GetValue() { return m_pszValue; }\r
+};\r
+\r
+#endif // !defined(AFX_CXMLATTRIBUTE_H__2B925786_3613_47B0_B85D_CAF2053F46DB__INCLUDED_)\r
diff --git a/src/commons/drm/CXMLElement.h b/src/commons/drm/CXMLElement.h
new file mode 100755 (executable)
index 0000000..eb74a0c
--- /dev/null
@@ -0,0 +1,57 @@
+\r
+/********************************************************************************\r
+* Copyright ? 2004-2009 by INKA Entworks, Inc (www.inka.co.kr).                                        *\r
+* All rights reserved.                                                                 * \r
+*                                                                                              * \r
+* No parts of this source code may be in any way copied, reproduced, modified  *\r
+* or distributed without the prior written consent of INKA Entworks, Inc.      *\r
+* CXMLElement.h: interface for the CXMLElement class.                                                  *\r
+*********************************************************************************/ \r
+\r
+#if !defined(AFX_CXMLELEMENT_H__B6A6A39B_1980_4A4F_B68B_E87B53A3EE9B__INCLUDED_)\r
+#define AFX_CXMLELEMENT_H__B6A6A39B_1980_4A4F_B68B_E87B53A3EE9B__INCLUDED_\r
+\r
+//#include "Shp.h"\r
+#include "InkaTypes.h"\r
+#include "CXMLAttribute.h"\r
+#include "CPointerArray.h"\r
+\r
+\r
+#if _MSC_VER > 1000\r
+#pragma once\r
+#endif // _MSC_VER > 1000\r
+\r
+class CXMLElement  \r
+{\r
+protected:\r
+       LPTSTR                                                  m_pszName;\r
+       LPTSTR                                                  m_pszValue;\r
+       \r
+       CPointerArray                                   m_pChilds;\r
+       CPointerArray                                   m_pAttributes;\r
+       \r
+       int                                             _SearchNodes(  CPointerArray* ppaChildNodes,  CXMLElement* pCurrent,  LPCTSTR pszTagName,  va_list args );\r
+\r
+public:\r
+       CXMLElement();\r
+       virtual ~CXMLElement();\r
+\r
+       int                                     SetName(  LPCTSTR pszName );\r
+       int                                             SetValue(  LPCTSTR pszValue );\r
+       int                                             AddAttribute(  LPCTSTR pszName,  LPCTSTR pszValue );\r
+\r
+       inline LPCTSTR                  GetName() { return m_pszName; }\r
+       inline LPCTSTR                  GetValue() { return m_pszValue; }\r
+\r
+       int                                             AddChild(  CXMLElement* pChild );\r
+       LPCTSTR                                         GetAttribute(  LPCTSTR pszName );\r
+\r
+       inline int                              GetChildCount() { return m_pChilds.GetCount(); }\r
+       inline int                              GetAttributeCount() { return m_pAttributes.GetCount(); }\r
+       inline CXMLElement*             GetChild(  int nIndex ) { return (CXMLElement*)m_pChilds.Get( nIndex ); }\r
+       inline CXMLAttribute*   GetAttribute(  int nIndex ) { return (CXMLAttribute*)m_pAttributes.Get( nIndex ); }\r
+\r
+       int                                                             Find(  CPointerArray* pSearchedChild,  LPCTSTR pszChildName, ... );\r
+};\r
+\r
+#endif // !defined(AFX_CXMLELEMENT_H__B6A6A39B_1980_4A4F_B68B_E87B53A3EE9B__INCLUDED_)\r
diff --git a/src/commons/drm/CXMLFile.h b/src/commons/drm/CXMLFile.h
new file mode 100755 (executable)
index 0000000..0a3a2e2
--- /dev/null
@@ -0,0 +1,54 @@
+\r
+/********************************************************************************\r
+* Copyright ? 2004-2009 by INKA Entworks, Inc (www.inka.co.kr).                                        *\r
+* All rights reserved.                                                                 * \r
+*                                                                                              * \r
+* No parts of this source code may be in any way copied, reproduced, modified  *\r
+* or distributed without the prior written consent of INKA Entworks, Inc.      *\r
+* CXMLFile.h: interface for the CXMLFile class.                                                                        *\r
+*********************************************************************************/ \r
+\r
+#if !defined(AFX_CXMLFILE_H__21F76587_B9C8_4407_9C16_186F3D47ADE1__INCLUDED_)\r
+#define AFX_CXMLFILE_H__21F76587_B9C8_4407_9C16_186F3D47ADE1__INCLUDED_\r
+\r
+//#include "Shp.h"\r
+#include "InkaTypes.h"\r
+#include "CXMLElement.h"\r
+\r
+#if _MSC_VER > 1000\r
+#pragma once\r
+#endif // _MSC_VER > 1000\r
+\r
+#ifndef IN\r
+       #define IN\r
+#endif\r
+\r
+#ifndef OUT\r
+       #define OUT\r
+#endif\r
+\r
+#define ELEMENT_QUEUE_MAX              2048\r
+class CXMLFile  \r
+{\r
+protected:\r
+       LPCTSTR                                                 m_pszXML;\r
+       CXMLElement*                                    m_paElementQueue[ ELEMENT_QUEUE_MAX ];\r
+       int                                                             m_nQueueIndex;\r
+       CXMLElement*                                    m_pRoot;\r
+       \r
+       int                                     _Parse();\r
+       int                                             _GetElementName(  LPTSTR pszElementName );\r
+       CXMLElement*                            _Pop();\r
+       int                                             _Push( CXMLElement* p );\r
+       int                                             _GetAttributeNameAndValue(  LPTSTR pszName,  LPTSTR pszValue );\r
+\r
+public:\r
+       CXMLFile();\r
+       virtual ~CXMLFile();\r
+\r
+       int                                             LoadFromStream(  LPCTSTR pszXML );\r
+       int                                             LoadFromFile(  LPCTSTR pszFileName );\r
+       inline CXMLElement*             GetRoot() { return m_pRoot; }\r
+};\r
+\r
+#endif // !defined(AFX_CXMLFILE_H__21F76587_B9C8_4407_9C16_186F3D47ADE1__INCLUDED_)\r
diff --git a/src/commons/drm/InkaTypes.h b/src/commons/drm/InkaTypes.h
new file mode 100755 (executable)
index 0000000..d7a9291
--- /dev/null
@@ -0,0 +1,76 @@
+/*\r
+ * SHP\r
+ * Copyright (c) 2000-2007 UMTS Software Lab, Mobile Communication Division,\r
+ * Telecommunication Network Business, Samsung Electronics, Inc.\r
+ * All rights reserved.\r
+ *\r
+ * This software is the confidential and proprietary information\r
+ * of Samsung Electronics, Inc. ("Confidential Information").  You\r
+ * shall not disclose such Confidential Information and shall use\r
+ * it only in accordance with the terms of the license agreement\r
+ * you entered into with Samsung Electronics. \r
+ */\r
+\r
+/** \r
+ * @file       InkaTypes.h\r
+ * @brief      This file includes definitions of constants, \r
+ *                     enumerations, and datastructures for the Inka DRM service.\r
+# @author              Jihyun Lee(ezhyun.lee@samsung.com)\r
+# @author              Donghyun Yoo(marku.yoo@samsung.com)\r
+ * @version    1.0\r
+ */\r
+\r
+#ifndef INKA_DRM_TYPES_H\r
+#define INKA_DRM_TYPES_H\r
+\r
+//#include "shp.h"\r
+//#include "FileMgr.h"\r
+#include <stdio.h>\r
+#include <stdarg.h>\r
+\r
+#define _T\r
+#define        IF_ERROR_GOTO( error )  if( FAILED( HRESULT_FROM_WIN32( error ) ) ) { nResult = ERRORMSG( error, NULL ); goto finish; }\r
+#define        IF_TRUE_GOTO( cond, error )     if( cond ) { nResult = -1; goto finish; }\r
+\r
+#if defined(_WIN32) || defined(_WIN64) \r
+  #define snprintf _snprintf \r
+  #define vsnprintf _vsnprintf \r
+  #define strcasecmp _stricmp \r
+  #define strncasecmp _strnicmp \r
+#endif\r
+\r
+#ifndef _SHP_SIMUL\r
+typedef void* LPVOID;\r
+typedef const char* LPCTSTR;\r
+typedef unsigned char* LPBYTE;\r
+typedef char TCHAR;\r
+typedef char* LPTSTR;\r
+typedef LPTSTR LPSTR;\r
+typedef LPCTSTR LPCTSTR;\r
+typedef LPCTSTR LPCSTR;\r
+\r
+#define        DWORD           unsigned long\r
+#define        LPBYTE          unsigned char*\r
+#define BYTE           unsigned char\r
+#define UINT           unsigned int\r
+#define ULONG          unsigned long\r
+#define INT32          long\r
+#define INT64          long long\r
+#define TRUE           1\r
+#define FALSE          0\r
+\r
+\r
+typedef char CHAR;\r
+typedef bool BOOL;\r
+\r
+\r
+//typedef HFile HANDLE;\r
+#define ERROR_INVALID_DATA               13L\r
+#define ERROR_INSUFFICIENT_BUFFER        122L    // dderror\r
+//#define CopyMemory AcMemcpy\r
+#define INVALID_HOBJ   NULL\r
+\r
+#endif\r
+\r
+\r
+#endif //INKA_DRM_TYPES_H\r
diff --git a/src/commons/drm/IntelDrm_Core.h b/src/commons/drm/IntelDrm_Core.h
new file mode 100755 (executable)
index 0000000..b8b4b48
--- /dev/null
@@ -0,0 +1,46 @@
+//typedef      char    CHAR;\r
+//typedef      bool    BOOL;\r
+\r
+typedef struct t_cek\r
+{\r
+       char    *CID;                                   // Content ID ¹öÆÛ Æ÷ÀÎÅÍ\r
+       char    *CEK;                                   // Content Encryption Key ¹öÆÛ Æ÷ÀÎÅÍ\r
+       char    *EncryptionMethod;              // CEK ¾Ë°í¸®Áò\r
+}T_CEK;\r
+\r
+typedef struct t_dro\r
+{\r
+       char                    *CID;                                   // Content ID ¹öÆÛ Æ÷ÀÎÅÍ\r
+       char                    *deviceId;                              // »ç¿ëÀÚ ½Äº° ¹ÙÀεù. IMEI, MIN °ª ¹ÙÀεù Á¦¾î\r
+       char                    *digestValue;                           // »ç¿ëÀÚ ½Äº° ¹ÙÀεù. IMEI, MIN °ª ¹ÙÀεù Á¦¾î\r
+       char                    *signedValue;                           // »ç¿ëÀÚ ½Äº° ¹ÙÀεù. IMEI, MIN °ª ¹ÙÀεù Á¦¾î\r
+       char                    *cert;                          // »ç¿ëÀÚ ½Äº° ¹ÙÀεù. IMEI, MIN °ª ¹ÙÀεù Á¦¾î\r
+       int                             Count;                                  // »ç¿ë È¸¼ö\r
+       char                    *CreatedTimestamp;              // »ç¿ë °¡´É ½ÃÀÛ ÀϽà¹öÆÛ Æ÷ÀÎÅÍ. GMT Ç¥±â\r
+       char                    *ExpiredTimeStamp;              // »ç¿ë °¡´É ¸¸±â ÀϽà¹öÆÛ Æ÷ÀÎÅÍ. GMT Ç¥±â\r
+       char                    *ExpirationDate;                // ÃÖÃÊ »ç¿ë ÀÌÈÄ »ç¿ë °¡´É ½Ã°£.  ½Ã°£ ´ÜÀ§    \r
+}T_DRO;\r
+\r
+typedef struct t_dcf_file_header\r
+{\r
+       unsigned char   Version;\r
+       unsigned char   ContentTypeLen;\r
+       unsigned char   ContentURILen;\r
+       char                    *ContentType;\r
+       char                    *ContentURI;\r
+       unsigned int    HeadersLen;\r
+       unsigned int    DataLen;\r
+       char                    *Headers;\r
+       unsigned int    DataOffset;\r
+}T_DCF_FILE_HEADER;\r
+\r
+// DRO Value size\r
+#define                APPID_SIZE                              16\r
+#define                CEK_SIZE                                512\r
+#define                ENCRYPTION_METHOD_SIZE  512\r
+#define                DEVICEID_SIZE                   256\r
+#define                TIMESTAMP_SIZE                  256\r
+#define                DIGESTVALUE_SIZE                256\r
+#define                SIGNATUREVALUE_SIZE             1024\r
+#define                CERT_SIZE                               1024 * 4\r
+#define                AES_BLOCK_SIZE                  16\r
diff --git a/src/commons/drm/drm-intel-crypto-util.h b/src/commons/drm/drm-intel-crypto-util.h
new file mode 100755 (executable)
index 0000000..eacb1e5
--- /dev/null
@@ -0,0 +1,13 @@
+#include "InkaTypes.h"\r
+//#include "IntelDrm_Core.h"\r
+\r
+#include "stdlib.h"\r
+#include "string.h"\r
+#include "stdio.h"\r
+\r
+#define AES_BLOCK_SIZE 16\r
+\r
+LPSTR Base64Encode(LPBYTE pbData, int nLength);\r
+LPBYTE Base64Decode(LPCSTR pszString, int* pnLength);\r
+\r
+int decrypt_block(unsigned char *iv, unsigned char *cipherText, int cipherTextLen,  unsigned char *cek, int cekLen, unsigned char *plainText);\r
diff --git a/src/commons/drm/drm-intel-util.h b/src/commons/drm/drm-intel-util.h
new file mode 100755 (executable)
index 0000000..08bb2cd
--- /dev/null
@@ -0,0 +1,69 @@
+#include "CPointerArray.h"\r
+#include "CXMLAttribute.h"\r
+#include "CXMLElement.h"\r
+#include "CXMLFile.h"\r
+#include "InkaTypes.h"\r
+#include "IntelDrm_Core.h"\r
+#include "drm-intel-crypto-util.h"\r
+\r
+#include "stdlib.h"\r
+#include "string.h"\r
+#include "stdio.h"\r
+\r
+/**   \r
+ *  An application can parse CEK XML Foramt.\r
+ * \r
+ * @param[in]          pszXML          Data String of the CEK information\r
+ * @param[out]         t_cek           parsing result to be saved\r
+ * @return                     This function returns 1 on success or 0 on failure.\r
+ * @remarks     \r
+ * @see                \r
+ * @since         \r
+ */\r
+int parse_intel_cek(const char* pszXML, T_CEK* t_cek);\r
+\r
+/**   \r
+ *  An application can parse DRO XML Foramt.\r
+ * \r
+ * @param[in]          pszXML          Data String of the DRO information\r
+ * @param[out]         t_cek           parsing result to be saved\r
+ * @return                     This function returns 1 on success or 0 on failure.\r
+ * @remarks     \r
+ * @see                \r
+ * @since         \r
+ */\r
+int parse_intel_dro(const char* pszXML, T_DRO* t_RO);\r
+\r
+int parse_intel_dro2(const char* pszXML, T_DRO* t_RO);\r
+\r
+/**   \r
+ *  An application can parse stored dro.\r
+ * \r
+ * @param[in]          pFilepath               file path of the internal dro\r
+ * @param[out]         t_ro                    parsing result to be saved\r
+ * @return                     This function returns 1 on success or 0 on failure.\r
+ * @remarks     \r
+ * @see                \r
+ * @since         \r
+ */\r
+int get_internal_dro(char *pFilepath, T_DRO* t_ro);\r
+\r
+/**   \r
+ *  An application can parse stored cek.\r
+ * \r
+ * @param[in]          pFilepath               file path of the internal cek\r
+ * @param[out]         t_cek                   parsing result to be saved\r
+ * @return                     This function returns 1 on success or 0 on failure.\r
+ * @remarks     \r
+ * @see                \r
+ * @since         \r
+ */\r
+int get_internal_cek(char *pFilepath, T_CEK* t_cek);\r
+\r
+int delete_internal_cek(char *pAppId);\r
+\r
+int get_dcf_header_info(char *pFilePath, T_DCF_FILE_HEADER *pTdcfHeader);\r
+\r
+bool get_Uintvar(unsigned int *nValue, FILE *pFile);\r
+\r
+int decrypt_package(char *pDcfPath, char *pDecryptedFilePath, unsigned char *pCEK, int cekLen, T_DCF_FILE_HEADER *t_dcf_header);\r
diff --git a/src/commons/drm/drm-oem-intel.h b/src/commons/drm/drm-oem-intel.h
new file mode 100755 (executable)
index 0000000..80a9bb2
--- /dev/null
@@ -0,0 +1,172 @@
+/*\r
+ *  drm-intel\r
+ *\r
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Sunggun Jung       <sunggun.jung@samsung.com>\r
+ * \r
+ * This library is free software; you can redistribute it and/or modify it under\r
+ * the terms of the GNU Lesser General Public License as published by the\r
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)\r
+ * any later version.\r
+ * \r
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY\r
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public\r
+ * License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public License\r
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51\r
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
+ *\r
+ */\r
+\r
+/**\r
+* @internal\r
+* @defgroup DRM-INTEL drm-intel\r
+* @{  \r
+*/\r
+#include "drm-intel-util.h"\r
+//#include "drm-intel-crypto-util.h"\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+\r
+/**   \r
+ *  An application can install Intel DRM license(DRO).\r
+ * \r
+ * @param[in]          pDroXML         Data String of the Rights Request\r
+ * @param[in]          droBufLen       pDroXML Length\r
+ * @return                     This function returns 1 on success or 0 on failure.\r
+ * @remarks     \r
+ * @see                \r
+ * @since         \r
+ */\r
+int drm_oem_intel_install_license(char *pDroXML, int droBufLen);\r
+\r
+/**   \r
+ *  An application can uninstall Intel DRM license(DRO).\r
+ * \r
+ * @param[in]          pAppId          App-id of the rigths which want to un-install\r
+ * @return                     This function returns 1 on success or 0 on failure.\r
+ * @remarks     \r
+ * @see                \r
+ * @since         \r
+ */\r
+int drm_oem_intel_uninstall_license(char *pAppId);\r
+\r
+/**   \r
+ *  An application can install CEK(Contents Encryption Key).\r
+ * \r
+ * @param[in]          pCekXML         Data String of the Rights Request\r
+ * @param[in]          cekBufLen       pDroXML Length\r
+ * @return                     This function returns 1 on success or 0 on failure.\r
+ * @remarks     \r
+ * @see                \r
+ * @since         \r
+ */\r
+int drm_oem_intel_install_cek(char *pCekXML, int cekBufLen);\r
+\r
+/**   \r
+ *  An application can get decrypted contents(Apps) which is encrypted\r
+ * \r
+ * @param[in]  pDcfPath                Intel DRM Package File Path             \r
+ * @param[in]  pDecryptedFile  Decrypted File Path\r
+ * @return             This function returns 1 on success or 0 on failure.\r
+ * @remarks     \r
+ * @see\r
+ * @since\r
+ */\r
+int drm_oem_intel_decrypt_package(char *pDcfPath, char *pDecryptedFile);\r
+\r
+/**   \r
+ *  An application can get informations of rights (DRO).\r
+ * \r
+ * @param[in]          pAppId          App-id of the rights which want to know\r
+ * @param[out]         pDro            The rights information about the app-id\r
+ * @return  This function can return any of the following codes\r
+ * DRM_INTEL_SUCCESS = 0        <success \r
+ * DRM_INTEL_LIC_VALID = 1      <License is valid \r
+ * DRM_INTEL_LIC_SUSPEND = 2    <License is valid but for future use \r
+ * DRM_INTEL_INVALID_ARG = -1000   <invalid argument\r
+ * DRM_INTEL_PARSING_ERROR = -999      <parsing contents or rights error\r
+ * DRM_INTEL_DB_ERROR = -998        <data base error \r
+ * DRM_INTEL_INSUFFICIENT_MEMORY = -997      <memory error \r
+ * DRM_INTEL_INTERNAL_ERROR = -996     <processing error\r
+ * DRM_INTEL_FILE_ERROR = -995       <file error\r
+ * DRM_INTEL_LIC_EXPIRED_DATETIME = -994    <Datetime License is expired\r
+ * DRM_INTEL_LIC_EXPIRED_COUNT = -993    <Count License is expired \r
+ * DRM_INTEL_LIC_NO_LICENCE = -992      <No License\r
+ * DRM_INTEL_LIC_IMEI_MISMATCH = -991    <IMEI is mismatching \r
+ * DRM_INTEL_LIC_PNUM_MISMATCH = -990    <PNUM is mismatching \r
+ * DRM_INTEL_UNKNOWN_ERROR = -1    <dummy error value\r
+ * @remarks     \r
+ * @see                \r
+ * @since         \r
+ */\r
+int drm_oem_intel_getLicenseInfo(char *pAppId, T_DRO *pDro);\r
+\r
+/**   \r
+ *  An application can get informations of rights (DRO).\r
+ * \r
+ * @param[in]          pAppId          App-id of the rights which want to know\r
+ * @return  This function can return any of the following codes\r
+ * DRM_INTEL_SUCCESS = 0        <success \r
+ * DRM_INTEL_LIC_VALID = 1      <License is valid \r
+ * DRM_INTEL_LIC_SUSPEND = 2    <License is valid but for future use \r
+ * DRM_INTEL_INVALID_ARG = -1000   <invalid argument\r
+ * DRM_INTEL_PARSING_ERROR = -999      <parsing contents or rights error\r
+ * DRM_INTEL_DB_ERROR = -998        <data base error \r
+ * DRM_INTEL_INSUFFICIENT_MEMORY = -997      <memory error \r
+ * DRM_INTEL_INTERNAL_ERROR = -996     <processing error\r
+ * DRM_INTEL_FILE_ERROR = -995       <file error\r
+ * DRM_INTEL_LIC_EXPIRED_DATETIME = -994    <Datetime License is expired\r
+ * DRM_INTEL_LIC_EXPIRED_COUNT = -993    <Count License is expired \r
+ * DRM_INTEL_LIC_NO_LICENCE = -992      <No License\r
+ * DRM_INTEL_LIC_IMEI_MISMATCH = -991    <IMEI is mismatching \r
+ * DRM_INTEL_LIC_PNUM_MISMATCH = -990    <PNUM is mismatching \r
+ * DRM_INTEL_UNKNOWN_ERROR = -1    <dummy error value \r
+ * @remarks     \r
+ * @see                \r
+ * @since         \r
+ */\r
+int drm_oem_intel_consume_license(char *pAppID);\r
+\r
+/**   \r
+ *  An application can veify the app's rights.\r
+ * \r
+ * @param[in]          pAppId          App-id of the rights which want to know\r
+ * @return     This function can return any of the following codes\r
+ * DRM_INTEL_SUCCESS = 0                <success \r
+ * DRM_INTEL_LIC_VALID = 1      <License is valid \r
+ * DRM_INTEL_LIC_SUSPEND = 2    <License is valid but for future use \r
+ * DRM_INTEL_INVALID_ARG = -1000       <invalid argument\r
+ * DRM_INTEL_PARSING_ERROR = -999              <parsing contents or rights error\r
+ * DRM_INTEL_DB_ERROR = -998            <data base error \r
+ * DRM_INTEL_INSUFFICIENT_MEMORY = -997          <memory error \r
+ * DRM_INTEL_INTERNAL_ERROR = -996     <processing error\r
+ * DRM_INTEL_FILE_ERROR = -995           <file error\r
+ * DRM_INTEL_LIC_EXPIRED_DATETIME = -994        <Datetime License is expired\r
+ * DRM_INTEL_LIC_EXPIRED_COUNT = -993    <Count License is expired \r
+ * DRM_INTEL_LIC_NO_LICENCE = -992      <No License\r
+ * DRM_INTEL_LIC_IMEI_MISMATCH = -991    <IMEI is mismatching \r
+ * DRM_INTEL_LIC_PNUM_MISMATCH = -990    <PNUM is mismatching \r
+ * DRM_INTEL_UNKNOWN_ERROR = -1        <dummy error value \r
+\r
+ * @remarks     \r
+ * @see                \r
+ * @since         \r
+ */\r
+int drm_oem_intel_has_valid_license(char *pAppID);\r
+\r
+/**   \r
+ *  An application can check the file is drm enabled or not\r
+ * \r
+ * @param[in]  pDcfPath                The file path which want to check               \r
+  * @return            This function returns 1 on success or 0 on failure.\r
+ * @remarks     \r
+ * @see\r
+ * @since\r
+ */\r
+int drm_oem_intel_isDrmFile(char *pDcfPath);\r
index 7ffa615..efc3be9 100644 (file)
 #include <dpl/assert.h>
 #include <dpl/sstream.h>
 #include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <dpl/file_input.h>
+#include <dpl/utils/wrt_utility.h>
 #include "root_parser.h"
 #include "widget_parser.h"
 #include "parser_runner.h"
 #include <widget_install/job_widget_install.h>
-#include <widget_install/task_unzip.h>
 #include <widget_install/task_certify.h>
 #include <widget_install/task_widget_config.h>
 #include <widget_install/task_file_manipulation.h>
@@ -51,6 +52,8 @@
 #include <widget_install/task_remove_backup.h>
 #include <widget_install/task_encrypt_resource.h>
 #include <widget_install/task_certificates.h>
+#include <widget_install/task_unzip.h>
+#include <widget_install/task_commons.h>
 #include <widget_install/task_plugins_copy.h>
 
 #include <widget_install/widget_install_errors.h>
@@ -68,6 +71,9 @@
 #include <libiriwrapper.h>
 #include <pkg-manager/pkgmgr_signal.h>
 #include <app_manager.h>
+#include <drm_client.h>
+#include <drm_trusted_client.h>
+#include <drm-oem-intel.h> //temporary code
 
 using namespace WrtDB;
 
@@ -132,35 +138,13 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
     JobContextBase<WidgetInstallationStruct>(installerStruct),
     m_exceptionCaught(Exceptions::Success)
 {
-    // Check installation type (config.xml or widget.wgt)
-    bool browserRequest = hasExtension(widgetPath, XML_EXTENSION);
-
-    LogInfo("Hosted app installation: " << browserRequest);
-
     struct timeval tv;
     gettimeofday(&tv, NULL);
     srand(time(NULL) + tv.tv_usec);
 
     m_installerContext.m_quiet = m_jobStruct.m_quiet;
 
-    if(!browserRequest)
-    {
-        m_installerContext.widgetConfig.pType = checkPackageType(widgetPath);
-    }
-    else
-    {
-        m_installerContext.widgetConfig.pType = WrtDB::PKG_TYPE_TIZEN_WEBAPP;
-    }
-    LogDebug("widgetPath:" << widgetPath);
-
-    ConfigParserData configData = getWidgetDataFromXML(widgetPath, browserRequest,
-            m_installerContext.widgetConfig.pType);
-    WidgetUpdateInfo update = detectWidgetUpdate(configData);
-    bool needEncryption = detectResourceEncryption(configData);
-
-    // Configure installation
-    ConfigureResult result = ConfigureInstallation(widgetPath, configData,
-                                                   update, browserRequest);
+    ConfigureResult result = PrePareInstallation(widgetPath);
 
     if (result == ConfigureResult::Ok) {
         LogInfo("Configure installation succeeded");
@@ -168,15 +152,18 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         AddTask(new TaskRecovery(m_installerContext));
 
         // Create installation tasks
-        if (!m_installerContext.locations->browserRequest()) {
+        if (m_installerContext.widgetConfig.packagingType !=
+                WrtDB::PKG_TYPE_HOSTED_WEB_APP || !m_isDRM) {
             AddTask(new TaskUnzip(m_installerContext));
         }
+
         AddTask(new TaskWidgetConfig(m_installerContext));
-        if (m_installerContext.locations->browserRequest()) {
+        if (m_installerContext.widgetConfig.packagingType ==
+                WrtDB::PKG_TYPE_HOSTED_WEB_APP ) {
             AddTask(new TaskPrepareFiles(m_installerContext));
         }
         AddTask(new TaskCertify(m_installerContext));
-        if (needEncryption) {
+        if (m_needEncryption) {
             AddTask(new TaskEncryptResource(m_installerContext));
         }
         AddTask(new TaskFileManipulation(m_installerContext));
@@ -191,8 +178,8 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
 
         AddTask(new TaskManifestFile(m_installerContext));
         AddTask(new TaskCertificates(m_installerContext));
-        if (m_installerContext.widgetConfig.pType ==
-                PKG_TYPE_TIZEN_WITHSVCAPP) {
+        if (m_installerContext.widgetConfig.packagingType ==
+                PKG_TYPE_HYBRID_WEB_APP) {
             AddTask(new TaskInstallOspsvc(m_installerContext));
         }
         AddTask(new TaskPluginsCopy(m_installerContext));
@@ -201,12 +188,15 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
     } else if (result == ConfigureResult::Updated) {
         LogInfo("Configure installation updated");
         LogInfo("Widget Update");
-
-        if (!m_installerContext.locations->browserRequest()) {
+        if (m_installerContext.widgetConfig.packagingType !=
+                WrtDB::PKG_TYPE_HOSTED_WEB_APP || !m_isDRM) {
             AddTask(new TaskUnzip(m_installerContext));
         }
+
         AddTask(new TaskWidgetConfig(m_installerContext));
-        if (m_installerContext.locations->browserRequest()) {
+
+        if (m_installerContext.widgetConfig.packagingType ==
+                WrtDB::PKG_TYPE_HOSTED_WEB_APP ) {
             AddTask(new TaskPrepareFiles(m_installerContext));
         }
 
@@ -217,8 +207,8 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         AddTask(new TaskSmack(m_installerContext));
 
         AddTask(new TaskManifestFile(m_installerContext));
-        if (m_installerContext.widgetConfig.pType ==
-                PKG_TYPE_TIZEN_WITHSVCAPP) {
+        if (m_installerContext.widgetConfig.packagingType ==
+                PKG_TYPE_HYBRID_WEB_APP) {
             AddTask(new TaskInstallOspsvc(m_installerContext));
         }
         AddTask(new TaskRemoveBackupFiles(m_installerContext));
@@ -244,6 +234,48 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
     }
 }
 
+JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation(
+        const std::string &widgetPath)
+{
+    ConfigureResult result;
+    m_needEncryption = false;
+
+    Try
+    {
+        std::string tempDir = Jobs::WidgetInstall::createTempPath();
+
+        bool m_isDRM = isDRMWidget(widgetPath);
+        if (true == m_isDRM) {
+            LogDebug("decrypt DRM widget");
+            if(DecryptDRMWidget(widgetPath, tempDir)) {
+                LogDebug("Failed decrypt DRM widget");
+                return ConfigureResult::Failed;
+            }
+        }
+
+        LogDebug("widgetPath:" << widgetPath);
+
+        m_installerContext.widgetConfig.packagingType =
+            checkPackageType(widgetPath, tempDir);
+        ConfigParserData configData = getWidgetDataFromXML(widgetPath, tempDir,
+                m_installerContext.widgetConfig.packagingType, m_isDRM);
+        LogDebug("widget packaging type : " <<
+                m_installerContext.widgetConfig.packagingType.pkgType);
+        WidgetUpdateInfo update = detectWidgetUpdate(configData);
+        m_needEncryption = detectResourceEncryption(configData);
+
+        // Configure installation
+        result = ConfigureInstallation(widgetPath, configData, update, tempDir);
+    }
+    Catch(Exceptions::ExtractFileFailed)
+    {
+        LogError("Failed to create temporary path for widget");
+        result = ConfigureResult::Failed;
+    }
+
+    return result;
+}
+
 std::string JobWidgetInstall::generateTizenId() {
     std::string allowed("0123456789"
         "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -318,10 +350,13 @@ DPL::OptionalString JobWidgetInstall::getNewTizenId() const
     return m_installerContext.widgetConfig.pkgname;
 }
 
-void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath, bool browserRequest)
+void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath,
+                                               const std::string& tempPath)
 {
-    m_installerContext.locations = WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname),
-            widgetPath, browserRequest, m_installerContext.widgetConfig.pType);
+    m_installerContext.locations =
+        WidgetLocation(DPL::ToUTF8String(*m_installerContext.widgetConfig.pkgname),
+                widgetPath, tempPath,
+                m_installerContext.widgetConfig.packagingType);
 
     LogInfo("widgetSource " << widgetPath);
 }
@@ -330,7 +365,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
         const std::string &widgetSource,
         const WrtDB::ConfigParserData &configData,
         const WidgetUpdateInfo &update,
-        bool browserRequest)
+        const std::string &tempPath)
 {
     LogInfo(
         "Widget install/update: incoming guid = '" <<
@@ -406,7 +441,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation(
         using namespace PackageManager;
         LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
 
-        configureWidgetLocation(widgetSource, browserRequest);
+        configureWidgetLocation(widgetSource, tempPath);
 
         // send start signal of pkgmgr
         PkgmgrSignalSingleton::Instance().setPkgname(
@@ -462,48 +497,62 @@ WidgetUpdateMode::Type JobWidgetInstall::CalcWidgetUpdatePolicy(
 
 ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
         const std::string &widgetSource,
-        bool fromBrowser, WrtDB::PkgType isOspsvc)
+        const std::string &tempPath,
+        WrtDB::PackagingType pkgType,
+        bool isDRM)
 {
+    // Parse config
+    ParserRunner parser;
+    ConfigParserData configInfo;
+
     Try
     {
-        // Parse config
-        ParserRunner parser;
-        ConfigParserData configInfo;
-
-        if (fromBrowser) {
+        if (pkgType == PKG_TYPE_HOSTED_WEB_APP) {
             parser.Parse(widgetSource,
-                         ElementParserPtr(
-                             new RootParser<WidgetParser>(configInfo,
-                                                          DPL::FromUTF32String(
-                                                              L"widget"))));
-        }
-        else {
-            // Open zip file
-            std::unique_ptr<DPL::ZipInput> zipFile(
-                new DPL::ZipInput(widgetSource));
+                    ElementParserPtr(
+                        new RootParser<WidgetParser>(configInfo,
+                            DPL::FromUTF32String(
+                                L"widget"))));
+        } else {
+            if (!isDRM) {
+                std::unique_ptr<DPL::ZipInput> zipFile(
+                        new DPL::ZipInput(widgetSource));
 
-            std::unique_ptr<DPL::ZipInput::File> configFile;
+                std::unique_ptr<DPL::ZipInput::File> configFile;
 
-            // Open config.xml file
-            if (isOspsvc == PKG_TYPE_TIZEN_WITHSVCAPP) {
-                configFile.reset(zipFile->OpenFile(WITH_OSP_XML));
+                // Open config.xml file
+                if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
+                    configFile.reset(zipFile->OpenFile(WITH_OSP_XML));
+                } else {
+                    configFile.reset(zipFile->OpenFile(CONFIG_XML));
+                }
+
+                // Extract config
+                DPL::BinaryQueue buffer;
+                DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
+                DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
+                DPL::Copy(&inputAdapter, &outputAdapter);
+                parser.Parse(&buffer,
+                        ElementParserPtr(
+                            new RootParser<WidgetParser>(configInfo,
+                                DPL::FromUTF32String(
+                                    L"widget"))));
             } else {
-                configFile.reset(zipFile->OpenFile(CONFIG_XML));
-            }
+                // DRM widget
+                std::string configFile;
+                if (pkgType == PKG_TYPE_HYBRID_WEB_APP) {
+                    configFile = tempPath + "/" + WITH_OSP_XML;
+                } else {
+                    configFile = tempPath + "/" + CONFIG_XML;
+                }
 
-            // Extract config
-            DPL::BinaryQueue buffer;
-            DPL::AbstractWaitableInputAdapter inputAdapter(configFile.get());
-            DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
-            DPL::Copy(&inputAdapter, &outputAdapter);
-            parser.Parse(&buffer,
-                         ElementParserPtr(
-                             new RootParser<WidgetParser>(configInfo,
-                                                          DPL::FromUTF32String(
-                                                              L"widget"))));
+                parser.Parse(configFile,
+                        ElementParserPtr(
+                            new RootParser<WidgetParser>(configInfo,
+                                DPL::FromUTF32String(
+                                    L"widget"))));
+            }
         }
-
-        return configInfo;
     }
     Catch(DPL::ZipInput::Exception::OpenFailed)
     {
@@ -520,11 +569,17 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML(
         LogError("Failed to extract config.xml file");
         return ConfigParserData();
     }
+    Catch(DPL::FileInput::Exception::OpenFailed)
+    {
+        LogError("Failed to open config.xml file");
+        return ConfigParserData();
+    }
     Catch(ElementParser::Exception::ParseError)
     {
         LogError("Failed to parse config.xml file");
         return ConfigParserData();
     }
+    return configInfo;
 }
 
 WidgetUpdateInfo JobWidgetInstall::detectWidgetUpdate(
@@ -709,58 +764,68 @@ void JobWidgetInstall::displayWidgetInfo()
 }
 
 WrtDB::PackagingType JobWidgetInstall::checkPackageType(
-        const std::string &widgetSource)
+        const std::string &widgetSource,
+        const std::string &tempPath)
 {
-    using namespace WrtDB;
-
-    PackagingType pType = PKG_TYPE_UNKNOWN;
-    std::unique_ptr<DPL::ZipInput> zipFile;
+    // Check installation type (config.xml or widget.wgt)
+    if (hasExtension(widgetSource, XML_EXTENSION)) {
+        LogInfo("Hosted app installation");
+        return PKG_TYPE_HOSTED_WEB_APP;
+    }
 
-    Try
-    {
-        // Open zip file
-        zipFile.reset(new DPL::ZipInput(widgetSource));
+    if (m_isDRM) {
+        std::string configFile = tempPath + "/" + CONFIG_XML;
+        if (WrtUtilFileExists(configFile)) {
+            return PKG_TYPE_NOMAL_WEB_APP;
+        }
 
-    }
-    Catch(DPL::ZipInput::Exception::OpenFailed)
-    {
-        LogError("Failed to open widget package");
-        return PKG_TYPE_UNKNOWN;
-    }
+        configFile = tempPath + "/" + WITH_OSP_XML;
+        if (WrtUtilFileExists(configFile)) {
+            return PKG_TYPE_HYBRID_WEB_APP;
+        }
+    } else {
+        std::unique_ptr<DPL::ZipInput> zipFile;
 
-    Try
-    {
-        // Open config.xml file in package root
-        std::unique_ptr<DPL::ZipInput::File> configFile(
-                zipFile->OpenFile(CONFIG_XML));
-        pType = PKG_TYPE_TIZEN_WEBAPP;
-    }
-    Catch(DPL::ZipInput::Exception::OpenFileFailed)
-    {
-        LogWarning("Could not find ./config.xml");
-    }
+        Try
+        {
+            // Open zip file
+            zipFile.reset(new DPL::ZipInput(widgetSource));
 
-    Try
-    {
-        // Open config.xml file in package root
-        std::unique_ptr<DPL::ZipInput::File> configFile(
-                zipFile->OpenFile(WITH_OSP_XML));
-        if (pType == PKG_TYPE_TIZEN_WEBAPP) {
-            LogWarning("Two config.xml's found. Application type is unknown.");
+        }
+        Catch(DPL::ZipInput::Exception::OpenFailed)
+        {
+            LogDebug("Failed to open widget package");
             return PKG_TYPE_UNKNOWN;
         }
 
-        pType = PKG_TYPE_TIZEN_WITHSVCAPP;
-    }
-    Catch(DPL::ZipInput::Exception::OpenFileFailed)
-    {
-        LogWarning("Could not find ./res/wgt/config.xml");
-    }
+        Try
+        {
+            // Open config.xml file in package root
+            std::unique_ptr<DPL::ZipInput::File> configFile(
+                    zipFile->OpenFile(CONFIG_XML));
+            return PKG_TYPE_NOMAL_WEB_APP;
+        }
+        Catch(DPL::ZipInput::Exception::OpenFileFailed)
+        {
+            LogDebug("Could not find config.xml");
+        }
+
+        Try
+        {
+            // Open config.xml file in package root
+            std::unique_ptr<DPL::ZipInput::File> configFile(
+                    zipFile->OpenFile(WITH_OSP_XML));
 
-    if (pType == PKG_TYPE_UNKNOWN) {
-        LogWarning("config.xml not found. Application type is unknown.");
+            return PKG_TYPE_HYBRID_WEB_APP;
+        }
+        Catch(DPL::ZipInput::Exception::OpenFileFailed)
+        {
+            LogDebug("Could not find wgt/config.xml");
+            return PKG_TYPE_UNKNOWN;
+        }
     }
-    return pType;
+
+    return PKG_TYPE_UNKNOWN;
 }
 
 bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &configData)
@@ -776,5 +841,54 @@ bool JobWidgetInstall::detectResourceEncryption(const WrtDB::ConfigParserData &c
     return false;
 }
 
+bool JobWidgetInstall::isDRMWidget(std::string widgetPath)
+{
+    drm_bool_type_e is_drm_file = DRM_UNKNOWN;
+    int ret = -1;
+
+    /* TODO :
+    ret = drm_is_drm_file(widgetPath.c_str(), &is_drm_file);
+    if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_drm_file) {
+    */
+
+    /* blow code temporary code for drm. */
+    ret = drm_oem_intel_isDrmFile(const_cast<char*>(widgetPath.c_str()));
+    if ( 1 == ret) {
+        return true;
+    } else {
+        return false;
+    }
+}
+
+bool JobWidgetInstall::DecryptDRMWidget(std::string widgetPath,
+        std::string destPath)
+{
+    /* TODO : 
+    drm_trusted_sapps_decrypt_package_info_s package_info;
+
+    strncpy(package_info.sadcf_filepath, widgetPath.c_str(),
+            sizeof(package_info.sadcf_filepath));
+    strncpy(package_info.decrypt_filepath, destPath.c_str(),
+            sizeof(package_info.decrypt_filepath));
+
+    drm_trusted_request_type_e requestType =
+        DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE;
+
+    int ret = drm_trusted_handle_request(requestType,
+                                         (void *)&package_info, NULL);
+    if (DRM_TRUSTED_RETURN_SUCCESS == ret) {
+        return true;
+    } else {
+        return false;
+    }
+    */
+    if (drm_oem_intel_decrypt_package(const_cast<char*>(widgetPath.c_str()),
+                const_cast<char*>(destPath.c_str())) != 0) { 
+        return true;
+    } else {
+        return false;
+    }
+}
+
 } //namespace WidgetInstall
 } //namespace Jobs
index 6e4281b..fa39392 100644 (file)
@@ -48,6 +48,8 @@ class JobWidgetInstall :
     Exceptions::Type m_exceptionCaught;
     std::string m_exceptionMessage;
     WidgetUpdateInfo m_widgetUpdateInfo;
+    bool    m_needEncryption;
+    bool    m_isDRM;
 
     enum class ConfigureResult
     {
@@ -58,10 +60,12 @@ class JobWidgetInstall :
                                           const WrtDB::ConfigParserData
                                           &configData,
                                           const WidgetUpdateInfo &update,
-                                          bool browserRequest);
+                                          const std::string &tempPath);
     static WrtDB::ConfigParserData getWidgetDataFromXML(
             const std::string &widgetSource,
-            bool fromBrowser, WrtDB::PkgType isOspsvc);
+            const std::string &tempPath,
+            WrtDB::PackagingType pkgType,
+            bool isDRM);
     static WidgetUpdateInfo detectWidgetUpdate(
             const WrtDB::ConfigParserData &configInfo);
     WidgetUpdateMode::Type CalcWidgetUpdatePolicy(
@@ -70,12 +74,17 @@ class JobWidgetInstall :
     bool setTizenId(const WrtDB::ConfigParserData &configInfo,
                     ConfigureResult result);
     void displayWidgetInfo();
-    void configureWidgetLocation(const std::string & widgetPath, bool browserRequest);
+    void configureWidgetLocation(const std::string & widgetPath,
+                                 const std::string &tempPath);
 
     WrtDB::PackagingType checkPackageType(
-            const std::string &widgetSorce);
+            const std::string &widgetSource,
+            const std::string &tempPath);
     bool detectResourceEncryption(const WrtDB::ConfigParserData &configData);
     std::string generateTizenId();
+    bool isDRMWidget(std::string widgetPath);
+    bool DecryptDRMWidget(std::string widgetPath, std::string destPath);
+    ConfigureResult PrePareInstallation(const std::string &widgetPath);
 
   public:
     /**
index 616a1bd..c1b0a98 100644 (file)
@@ -95,7 +95,8 @@ void TaskAceCheck::StepAceCheck()
 void TaskAceCheck::StepProcessAceResponse()
 {
     WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
-    if (m_context.locations->browserRequest()) {
+    if (m_context.widgetConfig.packagingType ==
+            WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
         return;
     }
 
index f060447..532c206 100755 (executable)
@@ -437,7 +437,7 @@ void TaskCertify::stepAuthorInfoPopupAnswer()
 bool TaskCertify::isTizenWebApp() const
 {
     bool ret = FALSE;
-    if (m_installContext.widgetConfig.type.appType
+    if (m_installContext.widgetConfig.webAppType.appType
             == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
         ret = TRUE;
 
index cbcf554..d133d83 100644 (file)
@@ -21,6 +21,8 @@
  */
 #include "task_encrypt_resource.h"
 
+#undef __USE_FILE_OFFSET64
+
 #include <unistd.h>
 #include <string>
 #include <sys/stat.h>
index 48abe91..ae02d73 100644 (file)
@@ -61,7 +61,7 @@ void TaskFileManipulation::StepCreateDirs()
 
     // If package type is widget with osp service, we don't need to make bin
     // and src directory
-    if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
+    if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) {
         LogDebug("Doesn't need to create resource directory");
     } else {
         LogDebug("Create resource directory");
@@ -82,7 +82,7 @@ void TaskFileManipulation::StepRenamePath()
         ThrowMsg(Exceptions::InternalError, "No Package name exists.");
     }
 
-    if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
+    if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) {
         instDir = m_context.locations->getPackageInstallationDir();
     } else {
         instDir = m_context.locations->getSourceDir();
@@ -108,7 +108,7 @@ void TaskFileManipulation::StepAbortRenamePath()
 {
     LogDebug("[Rename Widget Path] Aborting.... (Rename path)");
     std::string widgetPath;
-    if (m_context.widgetConfig.pType == PKG_TYPE_TIZEN_WITHSVCAPP) {
+    if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) {
         widgetPath = m_context.locations->getPackageInstallationDir();
     } else {
         widgetPath = m_context.locations->getSourceDir();
index 0c97454..3acb023 100644 (file)
@@ -182,8 +182,9 @@ void TaskManifestFile::stepCopyIconFiles()
             targetFile << GlobalConfig::GetUserWidgetDesktopIconPath() << "/";
             targetFile << getIconTargetFilename(*locale);
 
-            if (m_context.locations->browserRequest())
-            {
+
+            if (m_context.widgetConfig.packagingType ==
+                    WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
                 m_context.locations->setIconTargetFilenameForLocale(targetFile.str());
             }
 
index c1f0706..420c0dd 100644 (file)
@@ -257,7 +257,7 @@ void TaskWidgetConfig::ProcessStartFile(const DPL::OptionalString& path,
             } else {
                 // set property data for hosted start url
                 // Hosted start url only support TIZEN WebApp
-                if (m_installContext.widgetConfig.type ==
+                if (m_installContext.widgetConfig.webAppType ==
                         APP_TYPE_TIZENWEBAPP)
                 {
                     const char *startPath =
@@ -423,7 +423,7 @@ void TaskWidgetConfig::StepShowWidgetInfo()
 void TaskWidgetConfig::StepCheckMinVersionInfo()
 {
     if (!isMinVersionCompatible(
-                m_installContext.widgetConfig.type.appType,
+                m_installContext.widgetConfig.webAppType.appType,
                 m_installContext.widgetConfig.minVersion)) {
         std::string label = WIDGET_NOT_COMPATIBLE + QUESTION;
         createInstallPopup(PopupType::WIDGET_MIN_VERSION, label);
@@ -448,14 +448,14 @@ void TaskWidgetConfig::StepVerifyFeatures()
         // check feature vender for permission
         // WAC, TIZEN WebApp cannot use other feature
 
-        if (!isFeatureAllowed(m_installContext.widgetConfig.type.appType,
+        if (!isFeatureAllowed(m_installContext.widgetConfig.webAppType.appType,
                               it->name))
         {
             LogInfo("This application type not allowed to use this feature");
             ThrowMsg(
                 Exceptions::WidgetConfigFileInvalid,
                 "This app type [" <<
-                m_installContext.widgetConfig.type.getApptypeToString() <<
+                m_installContext.widgetConfig.webAppType.getApptypeToString() <<
                 "] cannot be allowed to use [" <<
                 DPL::ToUTF8String(it->name) + "] feature");
         }
@@ -522,9 +522,9 @@ void TaskWidgetConfig::setApplicationType()
             currentAppType = APP_TYPE_TIZENWEBAPP;
         }
 
-        if (widgetInfo->type == APP_TYPE_UNKNOWN) {
-            widgetInfo->type = currentAppType;
-        } else if (widgetInfo->type == currentAppType) {
+        if (widgetInfo->webAppType == APP_TYPE_UNKNOWN) {
+            widgetInfo->webAppType = currentAppType;
+        } else if (widgetInfo->webAppType == currentAppType) {
             continue;
         } else {
             ThrowMsg(Exceptions::WidgetConfigFileInvalid,
@@ -533,11 +533,11 @@ void TaskWidgetConfig::setApplicationType()
     }
 
     // If there is no define, type set to WAC 2.0
-    if (widgetInfo->type == APP_TYPE_UNKNOWN) {
-        widgetInfo->type = APP_TYPE_WAC20;
+    if (widgetInfo->webAppType == APP_TYPE_UNKNOWN) {
+        widgetInfo->webAppType = APP_TYPE_WAC20;
     }
 
-    LogInfo("type = [" << widgetInfo->type.getApptypeToString() << "]");
+    LogInfo("type = [" << widgetInfo->webAppType.getApptypeToString() << "]");
 }
 
 bool TaskWidgetConfig::isFeatureAllowed(WrtDB::AppType appType,
@@ -644,7 +644,7 @@ bool TaskWidgetConfig::isMinVersionCompatible(WrtDB::AppType appType,
 bool TaskWidgetConfig::isTizenWebApp() const
 {
     bool ret = FALSE;
-    if (m_installContext.widgetConfig.type.appType
+    if (m_installContext.widgetConfig.webAppType.appType
             == WrtDB::AppType::APP_TYPE_TIZENWEBAPP)
         ret = TRUE;
 
diff --git a/src/jobs/widget_install/widget_unzip.cpp b/src/jobs/widget_install/widget_unzip.cpp
new file mode 100644 (file)
index 0000000..b8d0b98
--- /dev/null
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    widget_unzip.cpp
+ * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer task unzip
+ */
+#include <widget_install/widget_unzip.h>
+#include <widget_install/widget_install_errors.h>
+#include <widget_install/widget_install_context.h>
+#include <widget_install/job_widget_install.h>
+#include <dpl/log/log.h>
+#include <dpl/copy.h>
+#include <dpl/file_output.h>
+#include <dpl/abstract_waitable_input_adapter.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <task_commons.h>
+#include <sys/stat.h>
+#include <drm_trusted_client.h>
+
+using namespace WrtDB;
+
+namespace {
+struct PathAndFilePair
+{
+    std::string path;
+    std::string file;
+
+    PathAndFilePair(const std::string &p,
+            const std::string &f) :
+        path(p),
+        file(f)
+    {
+    }
+};
+
+PathAndFilePair SplitFileAndPath(const std::string &filePath)
+{
+    std::string::size_type position = filePath.rfind('/');
+
+    // Is this only a file without a path ?
+    if (position == std::string::npos) {
+        return PathAndFilePair(std::string(), filePath);
+    }
+
+    // This is full file-path pair
+    return PathAndFilePair(filePath.substr(0,
+                                           position),
+                           filePath.substr(position + 1));
+}
+}
+
+namespace Jobs {
+namespace WidgetInstall {
+WidgetUnzip::WidgetUnzip(std::string source, std::string path) :
+    m_source(source),
+    m_destPath(path)
+{
+    LogDebug("WidgetUnzip");
+}
+
+void WidgetUnzip::ExtractFile(DPL::ZipInput::File *input,
+        const std::string &destFileName)
+{
+    Try
+    {
+        DPL::AbstractWaitableInputAdapter inputAdapter(input);
+        DPL::FileOutput output(destFileName);
+
+        DPL::Copy(&inputAdapter, &output);
+    }
+    Catch(DPL::FileOutput::Exception::OpenFailed)
+    {
+        ReThrowMsg(Exceptions::ExtractFileFailed, destFileName);
+    }
+    Catch(DPL::CopyFailed)
+    {
+        ReThrowMsg(Exceptions::ExtractFileFailed, destFileName);
+    }
+}
+
+void WidgetUnzip::UnzipWidget()
+{
+    UnzipPrepare();
+    UnzipProgress();
+}
+
+void WidgetUnzip::UnzipPrepare()
+{
+    LogInfo("Prepare to unzip...");
+
+    Try
+    {
+        m_zip.reset(new DPL::ZipInput(m_source));
+        LogInfo("Widget package comment: " << m_zip->GetGlobalComment());
+
+        // Widget package must not be empty
+        if (m_zip->empty()) {
+            ThrowMsg(Exceptions::ZipEmpty, m_source);
+        }
+
+        // Set iterator to first file
+        m_zipIterator = m_zip->begin();
+    }
+    Catch(DPL::ZipInput::Exception::OpenFailed)
+    {
+        ReThrowMsg(Exceptions::OpenZipFailed, m_source);
+    }
+}
+
+void WidgetUnzip::UnzipProgress()
+{
+
+    // Show file info
+    LogInfo("Unzipping: '" << m_zipIterator->name <<
+            "', Comment: '" << m_zipIterator->comment <<
+            "', Compressed size: " << m_zipIterator->compressedSize <<
+            ", Uncompressed size: " << m_zipIterator->uncompressedSize);
+
+
+    // Normalize file paths
+    // FIXME: Implement checking for invalid characters
+
+    // Extract file or path
+    std::string fileName = m_zipIterator->name;
+
+    if (fileName[fileName.size() - 1] == '/') {
+        // This is path
+        std::string newPath = m_destPath + "/" +
+            fileName.substr(0, fileName.size() - 1);
+        LogPedantic("Path to extract: " << newPath);
+
+        // Create path in case of it is empty
+        createTempPath(newPath);
+    } else {
+        // This is regular file
+        std::string fileExtractPath = m_destPath + "/" + fileName;
+
+        LogPedantic("File to extract: " << fileExtractPath);
+
+        // Split into pat & file pair
+        PathAndFilePair pathAndFile = SplitFileAndPath(fileExtractPath);
+
+        LogPedantic("Path and file: " <<
+                    pathAndFile.path <<
+                    " : " << pathAndFile.file);
+
+        // First, ensure that path exists
+        createTempPath(pathAndFile.path);
+
+        Try
+        {
+            // Open file
+            std::unique_ptr<DPL::ZipInput::File> file(
+                m_zip->OpenFile(fileName));
+
+            // Extract single file
+            ExtractFile(file.get(), fileExtractPath);
+        }
+        Catch(DPL::ZipInput::Exception::OpenFileFailed)
+        {
+            ThrowMsg(Exceptions::ExtractFileFailed, fileName);
+        }
+    }
+
+    // Check whether there are more files to extract
+    if (++m_zipIterator == m_zip->end()) {
+        LogInfo("Unzip progress finished successfuly");
+        m_zip.reset();
+    } else {
+        UnzipProgress();
+    }
+}
+
+void WidgetUnzip::UnzipDRMWidget()
+{
+    LogDebug("Decrypt drm widget");
+    drm_trusted_sapps_decrypt_package_info_s package_info;
+
+    strncpy(package_info.sadcf_filepath, m_source.c_str(),
+            sizeof(package_info.sadcf_filepath));
+    strncpy(package_info.decrypt_filepath, m_destPath.c_str(),
+            sizeof(package_info.decrypt_filepath));
+
+    drm_trusted_request_type_e requestType =
+        DRM_TRUSTED_REQ_TYPE_SAPPS_DECRYPT_PACKAGE;
+
+    int ret = drm_trusted_handle_request(requestType,
+                                         (void *)&package_info, NULL);
+    if (DRM_TRUSTED_RETURN_SUCCESS != ret) {
+        LogDebug("Failed unzip drm widget");
+        ThrowMsg(Exceptions::ExtractFileFailed, m_destPath);
+    }
+}
+} //namespace WidgetInstall
+} //namespace Jobs
diff --git a/src/jobs/widget_install/widget_unzip.h b/src/jobs/widget_install/widget_unzip.h
new file mode 100644 (file)
index 0000000..7c7b4ca
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file    widget_unzip.cpp
+ * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief   Implementation file for installer task unzip
+ */
+#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_WIDGET_UNZIP_H
+#define INSTALLER_CORE_JOS_WIDGET_INSTALL_WIDGET_UNZIP_H
+
+#include <string>
+#include <memory>
+
+#include <dpl/zip_input.h>
+
+class InstallerContext;
+
+namespace Jobs {
+namespace WidgetInstall {
+class WidgetUnzip 
+{
+  private:
+    // Installation context
+    std::string m_source;
+    std::string m_destPath;
+
+    // Unzip state
+    std::unique_ptr<DPL::ZipInput> m_zip;
+    DPL::ZipInput::const_iterator m_zipIterator;
+
+    void ExtractFile(DPL::ZipInput::File *input,
+            const std::string &destFileName);
+
+    void UnzipPrepare();
+    void UnzipProgress();
+
+  public:
+    WidgetUnzip(std::string m_source, std::string m_destPath);
+    void UnzipWidget();
+    void UnzipDRMWidget();
+};
+} //namespace WidgetInstall
+} //namespace Jobs
+
+#endif // INSTALLER_CORE_JOS_WIDGET_INSTALL_WIDGET_UNZIP_H
index 0bfc879..392106f 100644 (file)
@@ -77,7 +77,7 @@ JobWidgetUninstall::JobWidgetUninstall(const std::string & widgetPkgName,
         AddTask(new TaskSmack(m_context));
         AddTask(new TaskCheck(m_context));
 
-        if (dao.getPkgType() == PKG_TYPE_TIZEN_WITHSVCAPP) {
+        if (dao.getPackagingType() == PKG_TYPE_HYBRID_WEB_APP) {
             AddTask(new TaskUninstallOspsvc(m_context));
         }
         AddTask(new TaskRemoveFiles(m_context));
index 712f344..b899bec 100644 (file)
@@ -34,6 +34,11 @@ WidgetLocation::DirectoryDeletor::DirectoryDeletor()
     m_dirpath = Jobs::WidgetInstall::createTempPath();
 }
 
+WidgetLocation::DirectoryDeletor::DirectoryDeletor(std::string tempPath)
+{
+    m_dirpath = tempPath;
+}
+
 WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
 {
     LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str());
@@ -45,11 +50,12 @@ std::string WidgetLocation::DirectoryDeletor::getTempPath() const
     return m_dirpath;
 }
 
-WidgetLocation::WidgetLocation() : m_browser(false)
+WidgetLocation::WidgetLocation()
 {
 }
 
-WidgetLocation::WidgetLocation(const std::string & widgetname) : m_pkgname(widgetname), m_browser(false)
+WidgetLocation::WidgetLocation(const std::string & widgetname) :
+                                        m_pkgname(widgetname)
 {
 }
 
@@ -59,16 +65,26 @@ WidgetLocation::~WidgetLocation()
 
 WidgetLocation::WidgetLocation(const std::string & widgetname,
                                std::string sourcePath,
-                               bool browserRequest,
-                               WrtDB::PkgType t):
+                               WrtDB::PackagingType t):
                                     m_pkgname(widgetname),
                                     m_widgetSource(sourcePath),
-                                    m_browser(browserRequest),
                                     m_type(t),
                                     m_temp(new WidgetLocation::DirectoryDeletor())
 {
 }
 
+WidgetLocation::WidgetLocation(const std::string & widgetname,
+                               std::string sourcePath,
+                               std::string dirPath,
+                               WrtDB::PackagingType t):
+                                    m_pkgname(widgetname),
+                                    m_widgetSource(sourcePath),
+                                    m_type(t),
+                                    m_temp(new
+                                            WidgetLocation::DirectoryDeletor(dirPath))
+{
+}
+
 // TODO cache all these paths
 std::string WidgetLocation::getInstallationDir() const
 {
@@ -123,14 +139,9 @@ std::string WidgetLocation::getTemporaryPackageDir() const
     return m_temp->getTempPath();
 }
 
-bool WidgetLocation::browserRequest() const
-{
-    return m_browser;
-}
-
 std::string WidgetLocation::getTemporaryRootDir() const
 {
-    if(m_type == WrtDB::PKG_TYPE_TIZEN_WITHSVCAPP)
+    if(m_type == WrtDB::PKG_TYPE_HYBRID_WEB_APP)
     {
         return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
     }
@@ -142,7 +153,7 @@ std::string WidgetLocation::getTemporaryRootDir() const
 
 std::string WidgetLocation::getConfigurationDir() const
 {
-    if(m_browser)
+    if(m_type ==  WrtDB::PKG_TYPE_HOSTED_WEB_APP)
     {
         std::string path = ".";
         int index = m_widgetSource.find_last_of("\\/");
index 84106e4..ab9fa29 100644 (file)
@@ -57,6 +57,7 @@ class WidgetLocation
     {
     public:
         DirectoryDeletor();
+        DirectoryDeletor(std::string tempPath);
         ~DirectoryDeletor();
         std::string getTempPath() const;
     private:
@@ -84,14 +85,17 @@ public:
      * @brief WidgetLocation Builds paths for widget location during installation
      *
      * @param widgetname name of widget
-     * @param browserRequest is browser Request
      * @param sourcePath given source path
      * @param t declaraced type of widget if type is needed
      *
      * In destruction removes temporary directory
      */
     WidgetLocation(const std::string & widgetname, std::string sourcePath,
-        bool browserRequest = false, WrtDB::PkgType t = WrtDB::PKG_TYPE_TIZEN_WEBAPP);
+                   WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP);
+
+    WidgetLocation(const std::string & widgetname, std::string sourcePath,
+                   std::string dirPath,
+                   WrtDB::PackagingType t = WrtDB::PKG_TYPE_NOMAL_WEB_APP);
     ~WidgetLocation();
 
     // Installed paths
@@ -105,8 +109,6 @@ public:
     std::string getBackupBinaryDir() const;              // /opt/apps/[package]/backup/bin
     std::string getBackupExecFile() const;              // /opt/apps/[package]/backup/bin/[package]
 
-    bool browserRequest() const;
-
     // Temporary paths
     /**
      * @brief getTemporaryRootDir
@@ -178,10 +180,9 @@ public:
 
 private:
     std::string m_widgetSource;                   // Source widget zip file/widget url
-    bool m_browser;                               // is browser request installation
     std::string m_pkgname;                        //name of package
     std::string m_iconPath;                       //installed icon path
-    WrtDB::PkgType m_type;
+    WrtDB::PackagingType m_type;
     std::shared_ptr<DirectoryDeletor> m_temp;      //directory
     WrtDB::ExternalLocationList m_externals;
 };