summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjh0522.choi <jh0522.choi@samsung.com>2012-10-05 13:54:12 +0900
committerjh0522.choi <jh0522.choi@samsung.com>2012-10-05 13:54:12 +0900
commitc6fdf2fe68fbab516825cb00afd34c86262e9fbd (patch)
treeb2662be0980746c19f0ddf8b7d7acb55eef74f29 /src
parentf064727a492edc71d743c53bb9b906ea8d3f379f (diff)
downloadinstaller-c6fdf2fe68fbab516825cb00afd34c86262e9fbd.tar.gz
installer-c6fdf2fe68fbab516825cb00afd34c86262e9fbd.tar.bz2
installer-c6fdf2fe68fbab516825cb00afd34c86262e9fbd.zip
Seperate the osp-installer
Diffstat (limited to 'src')
-rw-r--r--src/Context/DrmLicense.cpp36
-rwxr-xr-xsrc/Context/DrmLicense.h45
-rwxr-xr-xsrc/Context/InstallationContext.cpp405
-rwxr-xr-xsrc/Context/InstallationContext.h156
-rwxr-xr-xsrc/Installer/DirectoryInstaller.cpp177
-rw-r--r--src/Installer/DirectoryInstaller.h58
-rwxr-xr-xsrc/Installer/GuestInstaller.cpp79
-rw-r--r--src/Installer/GuestInstaller.h55
-rwxr-xr-xsrc/Installer/IDEInstaller.cpp79
-rw-r--r--src/Installer/IDEInstaller.h55
-rwxr-xr-xsrc/Installer/Installer.cpp162
-rw-r--r--src/Installer/Installer.h62
-rwxr-xr-xsrc/Installer/PackageInstaller.cpp83
-rw-r--r--src/Installer/PackageInstaller.h55
-rwxr-xr-xsrc/Installer/PreloadedInstaller.cpp79
-rw-r--r--src/Installer/PreloadedInstaller.h55
-rwxr-xr-xsrc/Installer/RestorationInstaller.cpp79
-rw-r--r--src/Installer/RestorationInstaller.h55
-rwxr-xr-xsrc/Manager/ConfigurationManager.cpp347
-rwxr-xr-xsrc/Manager/ConfigurationManager.h55
-rwxr-xr-xsrc/Manager/InstallerManager.cpp818
-rwxr-xr-xsrc/Manager/InstallerManager.h86
-rwxr-xr-xsrc/Manager/PermissionManager.cpp504
-rw-r--r--src/Manager/PermissionManager.h56
-rwxr-xr-xsrc/Manager/SignatureManager.cpp314
-rwxr-xr-xsrc/Manager/SignatureManager.h69
-rwxr-xr-xsrc/Step/DrmStep.cpp161
-rw-r--r--src/Step/DrmStep.h70
-rw-r--r--src/Step/IInstallationStep.cpp30
-rw-r--r--src/Step/IInstallationStep.h49
-rwxr-xr-xsrc/Step/LicenseStep.cpp101
-rw-r--r--src/Step/LicenseStep.h62
-rwxr-xr-xsrc/Step/ManifestXmlStep.cpp175
-rw-r--r--src/Step/ManifestXmlStep.h62
-rwxr-xr-xsrc/Step/PackageCheckStep.cpp137
-rw-r--r--src/Step/PackageCheckStep.h62
-rwxr-xr-xsrc/Step/SignatureStep.cpp219
-rwxr-xr-xsrc/Step/SignatureStep.h68
-rwxr-xr-xsrc/Step/SystemCheckStep.cpp134
-rw-r--r--src/Step/SystemCheckStep.h66
-rwxr-xr-xsrc/Step/UninstallStep.cpp227
-rw-r--r--src/Step/UninstallStep.h70
-rwxr-xr-xsrc/Step/UnpackStep.cpp288
-rw-r--r--src/Step/UnpackStep.h71
-rwxr-xr-xsrc/Util/InstallerUtil.cpp86
-rwxr-xr-xsrc/Util/InstallerUtil.h55
-rwxr-xr-xsrc/XmlHandler/ManifestGenerator.cpp346
-rw-r--r--src/XmlHandler/ManifestGenerator.h62
-rwxr-xr-xsrc/XmlHandler/ManifestHandler.cpp1164
-rwxr-xr-xsrc/XmlHandler/ManifestHandler.h109
-rwxr-xr-xsrc/XmlHandler/PrivilegeHandler.cpp399
-rw-r--r--src/XmlHandler/PrivilegeHandler.h61
-rwxr-xr-xsrc/XmlHandler/SignatureHandler.cpp222
-rwxr-xr-xsrc/XmlHandler/SignatureHandler.h72
-rwxr-xr-xsrc/XmlHandler/XmlAttribute.cpp115
-rwxr-xr-xsrc/XmlHandler/XmlAttribute.h54
-rwxr-xr-xsrc/XmlHandler/XmlHandler.cpp425
-rwxr-xr-xsrc/XmlHandler/XmlHandler.h101
-rw-r--r--src/XmlHandler/XmlWriter.cpp175
-rwxr-xr-xsrc/XmlHandler/XmlWriter.h62
-rwxr-xr-xsrc/backend/backend.cpp249
61 files changed, 9833 insertions, 0 deletions
diff --git a/src/Context/DrmLicense.cpp b/src/Context/DrmLicense.cpp
new file mode 100644
index 0000000..d69ebb9
--- /dev/null
+++ b/src/Context/DrmLicense.cpp
@@ -0,0 +1,36 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file DrmLicense.cpp
+ * @brief This is the implementation file for %DrmLicense class.
+ */
+
+#include "DrmLicense.h"
+
+DrmLicense::DrmLicense(void)
+{
+}
+
+DrmLicense::~DrmLicense(void)
+{
+}
+
+InstallerError
+DrmLicense::Construct(void)
+{
+ return INSTALLER_ERROR_NONE;
+}
diff --git a/src/Context/DrmLicense.h b/src/Context/DrmLicense.h
new file mode 100755
index 0000000..152a40e
--- /dev/null
+++ b/src/Context/DrmLicense.h
@@ -0,0 +1,45 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file DrmLicense.h
+ * @brief This is the header file for the %DrmLicense class.
+ *
+ * This header file contains the declarations of the %DrmLicense class.
+ */
+#ifndef _DRM_LICENSE_H_
+#define _DRM_LICENSE_H_
+
+#include "InstallerDefs.h"
+
+/**
+ * @class DrmLicense
+ * @brief This class represents the class of DrmLicense.
+ * @since 1.0
+ *
+ * This class represents the class of DrmLicense.
+ *
+ */
+class DrmLicense
+{
+public:
+ DrmLicense(void);
+ InstallerError Construct(void);
+ virtual ~DrmLicense(void);
+
+}; // DrmLicense
+
+#endif // _DRM_LICENSE_H_
diff --git a/src/Context/InstallationContext.cpp b/src/Context/InstallationContext.cpp
new file mode 100755
index 0000000..a940c68
--- /dev/null
+++ b/src/Context/InstallationContext.cpp
@@ -0,0 +1,405 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file InstallationContext.cpp
+ * @brief This is the implementation for the InstallerContext class.
+ */
+
+#include "InstallationContext.h"
+#include "SystemCheckStep.h"
+#include "PackageCheckStep.h"
+#include "ManifestXmlStep.h"
+#include "LicenseStep.h"
+#include "SignatureStep.h"
+#include "DrmStep.h"
+#include "UninstallStep.h"
+#include "UnpackStep.h"
+
+#include <FApp_PackageInfoImpl.h>
+
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::Io;
+using namespace Osp::App;
+
+InstallationContext::InstallationContext(void)
+:__pStep(null)
+,__pDrmLicense(null)
+,__error(INSTALLER_ERROR_NONE)
+,__step(INSTALLER_STEP_NONE)
+,__attributeType(0)
+,__state(INSTALLER_STATE_RUNNING)
+,__stepChanged(true)
+,__continue(true)
+,__preloaded(false)
+,__webService(false)
+,__operation(INSTALLER_OPERATION_INSTALL)
+,__storage(INSTALLATION_STORAGE_INTERNAL)
+,__pPrivilegeList(null)
+,__rootCertType(ROOT_CERTIFICATE_NONE)
+,__packageNameType(INSTALLER_PREFIX_TYPE_NONE)
+,__pPackageInfoImpl(null)
+{
+}
+
+InstallationContext::~InstallationContext(void)
+{
+ delete __pStep;
+ __pStep = null;
+
+ delete __pDrmLicense;
+ __pDrmLicense = null;
+
+ if (__pPrivilegeList)
+ {
+ __pPrivilegeList->RemoveAll();
+ delete __pPrivilegeList;
+ __pPrivilegeList = null;
+ }
+}
+
+InstallerError
+InstallationContext::Construct(void)
+{
+ __pPackageInfoImpl = new _PackageInfoImpl();
+ TryReturn(__pPackageInfoImpl, INSTALLER_ERROR_MEMORY, "[osp-installer] __pPackageInfoImpl is null.");
+
+ return INSTALLER_ERROR_NONE;
+}
+
+bool
+InstallationContext::ChangeStep(InstallationStep step)
+{
+ AppLogTag(OSP_INSTALLER, "step = [%d]", step);
+ delete __pStep;
+ __pStep = null;
+
+ switch (step)
+ {
+ case INSTALLER_STEP_NONE:
+ break;
+
+ case INSTALLER_STEP_INIT:
+ break;
+
+ case INSTALLER_STEP_CHECK_SYSTEM:
+ __pStep = new SystemCheckStep();
+ TryReturn(__pStep, false, "[osp-installer] SystemCheckStep is failed.");
+ break;
+
+ case INSTALLER_STEP_CHECK_PACKAGE:
+ __pStep = new PackageCheckStep();
+ TryReturn(__pStep, false, "[osp-installer] PackageCheckStep is failed.");
+ break;
+
+ case INSTALLER_STEP_UNPACK:
+ __pStep = new UnpackStep();
+ TryReturn(__pStep, false, "[osp-installer] UnpackStep is failed.");
+ break;
+
+ case INSTALLER_STEP_PARSE_MANIFEST:
+ __pStep = new ManifestXmlStep();
+ TryReturn(__pStep, false, "[osp-installer] ManifestXmlStep is failed.");
+ break;
+
+ case INSTALLER_STEP_PARSE_SIGNATURE:
+ __pStep = new SignatureStep();
+ TryReturn(__pStep, false, "[osp-installer] SignatureStep is failed.");
+ break;
+
+ case INSTALLER_STEP_UNINSTALL:
+ __pStep = new UninstallStep();
+ TryReturn(__pStep, false, "[osp-installer] UninstallStep is failed.");
+ break;
+
+ case INSTALLER_STEP_LICENSE:
+ __pStep = new LicenseStep();
+ TryReturn(__pStep, false, "[osp-installer] LicenseStep is failed.");
+ break;
+
+ case INSTALLER_STEP_DRM:
+ __pStep = new DrmStep();
+ TryReturn(__pStep, false, "[osp-installer] DrmStep is failed.");
+ break;
+
+ case INSTALLER_STEP_END:
+ break;
+
+ default:
+ break;
+ }
+
+ __step = step;
+ return true;
+}
+
+InstallerError
+InstallationContext::Run(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "InstallationContext::Run()");
+ return error;
+}
+
+InstallationStep
+InstallationContext::GetCurrentInstallationStep(void)
+{
+ return __step;
+}
+
+void
+InstallationContext::SetCurrentInstallationStep(InstallationStep step)
+{
+ __step = step;
+}
+
+InstallerError
+InstallationContext::GetError(void)
+{
+ return __error;
+}
+
+void
+InstallationContext::SetError(InstallerError installerError)
+{
+ __error = installerError;
+}
+
+InstallationState
+InstallationContext::GetState(void)
+{
+ return __state;
+}
+
+void
+InstallationContext::SetState(InstallationState installationState)
+{
+ __state = installationState;
+}
+
+IInstallationStep*
+InstallationContext::GetStep(void)
+{
+ return __pStep;
+}
+
+void
+InstallationContext::SetInputPath(const Osp::Base::String& path)
+{
+ __inputPath = path;
+}
+
+const String&
+InstallationContext::GetInputPath(void) const
+{
+ return __inputPath;
+}
+
+void
+InstallationContext::SetInstallerOperation(InstallerOperation op)
+{
+ __operation = op;
+}
+
+InstallerOperation
+InstallationContext::GetInstallerOperation(void) const
+{
+ return __operation;
+}
+
+bool
+InstallationContext::IsContinue(void)
+{
+ return __continue;
+}
+
+void
+InstallationContext::SetContinue(bool cont)
+{
+ __continue = cont;
+}
+
+bool
+InstallationContext::IsPreloaded(void)
+{
+ return __preloaded;
+}
+
+void
+InstallationContext::SetPreloaded(bool preloaded)
+{
+ __preloaded = preloaded;
+}
+
+const String&
+InstallationContext::GetPackagePath(void) const
+{
+ return __packagePath;
+}
+
+void
+InstallationContext::SetPackagePath(const String& packagePath)
+{
+ __packagePath = packagePath;
+}
+
+const String&
+InstallationContext::GetLicensePath(void) const
+{
+ return __licensePath;
+}
+
+void
+InstallationContext::SetLicensePath(const String& licensePath)
+{
+ __licensePath = licensePath;
+}
+
+const String&
+InstallationContext::GetTemporaryDir(void) const
+{
+ return __temporaryDir;
+}
+
+void
+InstallationContext::SetTemporaryDir(const String& temporaryDir)
+{
+ __temporaryDir = temporaryDir;
+}
+
+const String&
+InstallationContext::GetInstallDir(void) const
+{
+ return __installDir;
+}
+
+void
+InstallationContext::SetInstallDir(const String& installDir)
+{
+ __installDir = installDir;
+}
+
+const String&
+InstallationContext::GetWorkingDir(void) const
+{
+ return __workingDir;
+}
+
+void
+InstallationContext::SetWorkingDir(const String& workingDir)
+{
+ __workingDir = workingDir;
+}
+
+void
+InstallationContext::SetInstallationStorage(InstallationStorage storage)
+{
+ __storage = storage;
+}
+
+InstallationContext::InstallationStorage
+InstallationContext::GetInstallationStorage(void) const
+{
+ return __storage;
+}
+
+const String&
+InstallationContext::GetAppId(void) const
+{
+ return __appId;
+}
+
+void
+InstallationContext::SetAppId(const String& appId)
+{
+ __appId = appId;
+}
+
+const String&
+InstallationContext::GetAppVersion(void) const
+{
+ return __appVersion;
+}
+
+void
+InstallationContext::SetAppVersion(const String& appVersion)
+{
+ __appVersion = appVersion;
+}
+
+String
+InstallationContext::GetManifestXmlPath(void)
+{
+ String path;
+
+ path = GetInstallDir() + DIR_INFO + "/manifest.xml";
+
+ return path;
+}
+
+String
+InstallationContext::GetSignatureXmlPath(void)
+{
+ String path;
+
+ path = GetInstallDir() + "/signature1.xml";
+
+ return path;
+}
+
+const ArrayList*
+InstallationContext::GetPrivilegeList(void) const
+{
+ return __pPrivilegeList;
+}
+
+void
+InstallationContext::SetPrivilegeList(ArrayList* privilegeList)
+{
+ __pPrivilegeList = privilegeList;
+}
+
+RootCertificateType
+InstallationContext::GetRootCertType(void) const
+{
+ return __rootCertType;
+}
+
+void
+InstallationContext::SetRootCertType(RootCertificateType certType)
+{
+ __rootCertType = certType;
+}
+
+int
+InstallationContext::GetPackageNameType(void) const
+{
+ return __packageNameType;
+}
+
+void
+InstallationContext::SetPackageNameType(int type)
+{
+ __packageNameType = type;
+}
+
+_PackageInfoImpl*
+InstallationContext::GetPackageInfoImpl(void) const
+{
+ return __pPackageInfoImpl;
+}
+
diff --git a/src/Context/InstallationContext.h b/src/Context/InstallationContext.h
new file mode 100755
index 0000000..6898412
--- /dev/null
+++ b/src/Context/InstallationContext.h
@@ -0,0 +1,156 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file InstallerContext.h
+ * @brief This is the header file for the %InstallerContext class.
+ *
+ * This header file contains the declarations of the %InstallerContext class.
+ */
+#ifndef _INSTALLATION_CONTEXT_H_
+#define _INSTALLATION_CONTEXT_H_
+
+#include <FAppPackageInfo.h>
+
+#include "InstallerDefs.h"
+#include "IInstallationStep.h"
+#include "DrmLicense.h"
+
+class IInstallationStep;
+
+/**
+ * @class InstallationContext
+ * @brief This class represents the class of InstallationContext.
+ * @since 1.0
+ *
+ * This class represents the class of InstallationContext.
+ *
+ */
+class InstallationContext
+{
+public:
+ enum InstallationStorage
+ {
+ INSTALLATION_STORAGE_INTERNAL,
+ INSTALLATION_STORAGE_EXTERNAL,
+ };
+
+ InstallationContext(void);
+ virtual ~InstallationContext(void);
+ InstallerError Construct(void);
+
+ bool ChangeStep(InstallationStep step);
+ InstallerError Run(void);
+
+ InstallationStep GetCurrentInstallationStep(void);
+ void SetCurrentInstallationStep(InstallationStep step);
+
+ InstallerError GetError(void);
+ void SetError(InstallerError installerError);
+
+ InstallationState GetState(void);
+ void SetState(InstallationState installationState);
+
+ IInstallationStep* GetStep(void);
+
+ void SetInputPath(const Osp::Base::String& path);
+ const Osp::Base::String& GetInputPath(void) const;
+
+ void SetInstallerOperation(InstallerOperation op);
+ InstallerOperation GetInstallerOperation(void) const;
+
+ void SetInstallationStorage(InstallationStorage storage);
+ InstallationStorage GetInstallationStorage(void) const;
+
+ bool IsContinue(void);
+ void SetContinue(bool cont);
+
+ bool IsPreloaded(void);
+ void SetPreloaded(bool preloaded);
+
+ const Osp::Base::String& GetPackagePath(void) const;
+ void SetPackagePath(const Osp::Base::String& packagePath);
+
+ const Osp::Base::String& GetLicensePath(void) const;
+ void SetLicensePath(const Osp::Base::String& licensePath);
+
+ const Osp::Base::String& GetTemporaryDir(void) const;
+ void SetTemporaryDir(const Osp::Base::String& temporaryDir);
+
+ const Osp::Base::String& GetInstallDir(void) const;
+ void SetInstallDir(const Osp::Base::String& installDir);
+
+ const Osp::Base::String& GetWorkingDir(void) const;
+ void SetWorkingDir(const Osp::Base::String& workingDir);
+
+ const Osp::Base::String& GetAppId(void) const;
+ void SetAppId(const Osp::Base::String& appId);
+
+ const Osp::Base::String& GetAppVersion(void) const;
+ void SetAppVersion(const Osp::Base::String& appVersion);
+
+ Osp::Base::String GetManifestXmlPath(void);
+ Osp::Base::String GetSignatureXmlPath(void);
+
+ const Osp::Base::Collection::ArrayList* GetPrivilegeList(void) const;
+ void SetPrivilegeList(Osp::Base::Collection::ArrayList* privilegeList);
+
+ RootCertificateType GetRootCertType(void) const;
+ void SetRootCertType(RootCertificateType certType);
+
+ int GetPackageNameType(void) const;
+ void SetPackageNameType(int type);
+
+ Osp::App::_PackageInfoImpl* GetPackageInfoImpl(void) const;
+
+private:
+ InstallationContext(const InstallationContext& value);
+ InstallationContext& operator =(const InstallationContext& source);
+
+ IInstallationStep* __pStep;
+ DrmLicense* __pDrmLicense;
+ InstallerError __error;
+ InstallationStep __step;
+ int __attributeType;
+ InstallationState __state;
+ bool __stepChanged;
+ bool __continue;
+ bool __preloaded;
+ bool __webService;
+
+ Osp::Base::String __inputPath;
+ InstallerOperation __operation;
+ InstallationStorage __storage;
+
+ Osp::Base::String __packagePath;
+ Osp::Base::String __licensePath;
+ Osp::Base::String __temporaryDir;
+ Osp::Base::String __installDir;
+ Osp::Base::String __workingDir;
+ Osp::Base::String __appId;
+ Osp::Base::String __appVersion;
+ Osp::Base::String __appRootPath;
+
+ Osp::Base::Collection::ArrayList* __pPrivilegeList;
+ RootCertificateType __rootCertType;
+
+ int __packageNameType;
+
+ Osp::App::_PackageInfoImpl* __pPackageInfoImpl;
+
+}; // InstallationContext
+
+#endif // _INSTALLATION_CONTEXT_H_
diff --git a/src/Installer/DirectoryInstaller.cpp b/src/Installer/DirectoryInstaller.cpp
new file mode 100755
index 0000000..d891d82
--- /dev/null
+++ b/src/Installer/DirectoryInstaller.cpp
@@ -0,0 +1,177 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file DirectoryInstaller.cpp
+ * @brief This is the implementation file for %DirectoryInstaller class.
+ */
+
+#include <FIoFile.h>
+#include <FIoDirectory.h>
+#include <FIo_FileImpl.h>
+#include <FApp_PackageInfoImpl.h>
+
+#include "DirectoryInstaller.h"
+#include "InstallerUtil.h"
+
+using namespace Osp::App;
+using namespace Osp::Base;
+using namespace Osp::Io;
+
+DirectoryInstaller::DirectoryInstaller(void)
+{
+}
+
+DirectoryInstaller::~DirectoryInstaller(void)
+{
+}
+
+InstallationStep
+DirectoryInstaller::GetNext(InstallationStep step)
+{
+ if (step == INSTALLER_STEP_NONE)
+ {
+ return INSTALLER_STEP_INIT;
+ }
+ else if (step == INSTALLER_STEP_INIT)
+ {
+ return INSTALLER_STEP_CHECK_SYSTEM;
+ }
+ else if (step == INSTALLER_STEP_CHECK_SYSTEM)
+ {
+ return INSTALLER_STEP_PARSE_MANIFEST;
+ }
+ else if (step == INSTALLER_STEP_PARSE_MANIFEST)
+ {
+ return INSTALLER_STEP_PARSE_SIGNATURE;
+ }
+ else if (step == INSTALLER_STEP_PARSE_SIGNATURE)
+ {
+ return INSTALLER_STEP_END;
+ }
+ else
+ {
+ step = (InstallationStep)(step + 1);
+ return step;
+ }
+}
+
+InstallerError
+DirectoryInstaller::OnInit(void)
+{
+ AppLogTag(OSP_INSTALLER, "DirectoryInstaller::OnInit()");
+
+ // remove in /info/*.info files
+ RemoveInfoFiles();
+
+ return Installer::OnInit();
+}
+
+InstallerError
+DirectoryInstaller::OnRegister(void)
+{
+ AppLogTag(OSP_INSTALLER, "DirectoryInstaller::OnRegister()");
+ return Installer::OnRegister();
+}
+
+InstallerError
+DirectoryInstaller::OnEnd(void)
+{
+ AppLogTag(OSP_INSTALLER, "DirectoryInstaller::OnEnd()");
+ return Installer::OnEnd();
+}
+
+InstallerError
+DirectoryInstaller::OnError(void)
+{
+ AppLogTag(OSP_INSTALLER, "DirectoryInstaller::OnError()");
+ return Installer::OnError();
+}
+
+InstallerError
+DirectoryInstaller::OnRollback(void)
+{
+ AppLogTag(OSP_INSTALLER, "DirectoryInstaller::OnRollback()");
+ return Installer::OnRollback();
+}
+
+InstallerError
+DirectoryInstaller::OnUserCancel(void)
+{
+ AppLogTag(OSP_INSTALLER, "DirectoryInstaller::OnUserCancel()");
+ return Installer::OnUserCancel();
+}
+
+bool
+DirectoryInstaller::RemoveInfoFiles(void)
+{
+ Directory* pDir = null;
+ DirEnumerator* pDirEnum = null;
+ result r = E_SUCCESS;
+ int res = false;
+ String appid;
+ String path;
+
+ _PackageInfoImpl* pPackageInfoImpl = null;
+ InstallationContext* pContext = null;
+
+ pContext = GetContext();
+ TryCatch(pContext, res = false, "[osp-installer] pContext is null");
+
+ pPackageInfoImpl = pContext->GetPackageInfoImpl();
+ TryCatch(pPackageInfoImpl, res = false, "[osp-installer] pPackageInfoImpl is null");
+
+ path = pPackageInfoImpl->GetAppRootPath() + DIR_INFO;
+
+ pDir = new Directory; // Allocate %Directory instance
+ TryCatch(pDir, res = false, "[osp-installer] pDir is null");
+
+ r = pDir->Construct(path);
+ TryCatch(!IsFailed(r), res = false, "[osp-installer] pDir->Construct() failed, path=[%ls]", path.GetPointer());
+
+ pDirEnum = pDir->ReadN();
+ TryCatch(pDirEnum, res = false, "[osp-installer] pDirEnum is null");
+
+ while (pDirEnum->MoveNext() == E_SUCCESS)
+ {
+ DirEntry entry = pDirEnum->GetCurrentDirEntry();
+
+ String entryName = entry.GetName();
+ String entryDir = path;
+ entryDir += L"/";
+ entryDir += entryName;
+
+ if (entryName == L"." || entryName == L"..")
+ {
+ continue;
+ }
+
+ // check *.info file
+ if (_FileImpl::GetFileExtension(entryDir) == FILE_EXT_INFO)
+ {
+ AppLogTag(OSP_INSTALLER, " delete info/*.info file = [%ls]\n", entryDir.GetPointer());
+ InstallerUtil::Remove(entryDir);
+ }
+ }
+
+ delete pDir;
+ pDir = null;
+ return true;
+
+CATCH:
+ delete pDir;
+ return false;
+}
diff --git a/src/Installer/DirectoryInstaller.h b/src/Installer/DirectoryInstaller.h
new file mode 100644
index 0000000..6106332
--- /dev/null
+++ b/src/Installer/DirectoryInstaller.h
@@ -0,0 +1,58 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file DirectoryInstaller.h
+ * @brief This is the header file for the %DirectoryInstaller class.
+ *
+ * This header file contains the declarations of the %DirectoryInstaller class.
+ */
+#ifndef _DIRECTORY_INSTALLER_H_
+#define _DIRECTORY_INSTALLER_H_
+
+#include "Installer.h"
+
+/**
+ * @class DirectoryInstaller
+ * @brief This class represents the class of DirectoryInstaller.
+ * @since 1.0
+ *
+ * This class represents the class of DirectoryInstaller.
+ *
+ */
+class DirectoryInstaller
+ : public Installer
+{
+public:
+ DirectoryInstaller(void);
+ virtual ~DirectoryInstaller(void);
+
+ virtual InstallationStep GetNext(InstallationStep step);
+
+ virtual InstallerError OnInit(void);
+ virtual InstallerError OnRegister(void);
+ virtual InstallerError OnEnd(void);
+
+ virtual InstallerError OnError(void);
+ virtual InstallerError OnRollback(void);
+ virtual InstallerError OnUserCancel(void);
+
+private:
+ bool RemoveInfoFiles(void);
+
+}; // DirectoryInstaller
+
+#endif //_DIRECTORY_INSTALLER_H_
diff --git a/src/Installer/GuestInstaller.cpp b/src/Installer/GuestInstaller.cpp
new file mode 100755
index 0000000..7483f45
--- /dev/null
+++ b/src/Installer/GuestInstaller.cpp
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file GuestInstaller.cpp
+ * @brief This is the implementation for the %GuestInstaller class.
+ */
+
+#include "GuestInstaller.h"
+
+GuestInstaller::GuestInstaller(void)
+{
+}
+
+GuestInstaller::~GuestInstaller(void)
+{
+}
+
+InstallationStep
+GuestInstaller::GetNext(InstallationStep step)
+{
+ AppLogTag(OSP_INSTALLER, "GuestInstaller::GetNext()");
+ return PackageInstaller::GetNext(step);
+}
+
+InstallerError
+GuestInstaller::OnInit(void)
+{
+ AppLogTag(OSP_INSTALLER, "GuestInstaller::OnInit()");
+ return PackageInstaller::OnInit();
+}
+
+InstallerError
+GuestInstaller::OnRegister(void)
+{
+ AppLogTag(OSP_INSTALLER, "GuestInstaller::OnRegister()");
+ return PackageInstaller::OnRegister();
+}
+
+InstallerError
+GuestInstaller::OnEnd(void)
+{
+ AppLogTag(OSP_INSTALLER, "GuestInstaller::OnEnd()");
+ return PackageInstaller::OnEnd();
+}
+
+InstallerError
+GuestInstaller::OnError(void)
+{
+ AppLogTag(OSP_INSTALLER, "GuestInstaller::OnError()");
+ return PackageInstaller::OnError();
+}
+
+InstallerError
+GuestInstaller::OnRollback(void)
+{
+ AppLogTag(OSP_INSTALLER, "GuestInstaller::OnRollback()");
+ return PackageInstaller::OnRollback();
+}
+
+InstallerError
+GuestInstaller::OnUserCancel(void)
+{
+ AppLogTag(OSP_INSTALLER, "GuestInstaller::OnUserCancel()");
+ return PackageInstaller::OnUserCancel();
+}
diff --git a/src/Installer/GuestInstaller.h b/src/Installer/GuestInstaller.h
new file mode 100644
index 0000000..0ebdd42
--- /dev/null
+++ b/src/Installer/GuestInstaller.h
@@ -0,0 +1,55 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file GuestInstaller.h
+ * @brief This is the header file for the %GuestInstaller class.
+ *
+ * This header file contains the declarations of the %GuestInstaller class.
+ */
+#ifndef _GUEST_INSTALLER_H_
+#define _GUEST_INSTALLER_H_
+
+#include "PackageInstaller.h"
+
+/**
+ * @class GuestInstaller
+ * @brief This class represents the class of GuestInstaller.
+ * @since 1.0
+ *
+ * This class represents the class of GuestInstaller.
+ *
+ */
+class GuestInstaller
+ : public PackageInstaller
+{
+public:
+ GuestInstaller(void);
+ virtual ~GuestInstaller(void);
+
+ virtual InstallationStep GetNext(InstallationStep step);
+
+ virtual InstallerError OnInit(void);
+ virtual InstallerError OnRegister(void);
+ virtual InstallerError OnEnd(void);
+
+ virtual InstallerError OnError(void);
+ virtual InstallerError OnRollback(void);
+ virtual InstallerError OnUserCancel(void);
+
+}; // GuestInstaller
+
+#endif //_GUEST_INSTALLER_H_
diff --git a/src/Installer/IDEInstaller.cpp b/src/Installer/IDEInstaller.cpp
new file mode 100755
index 0000000..9cbd8fe
--- /dev/null
+++ b/src/Installer/IDEInstaller.cpp
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file IDEInstaller.cpp
+ * @brief This is the implementation file for %IDEInstaller class.
+ */
+
+#include "IDEInstaller.h"
+
+IDEInstaller::IDEInstaller(void)
+{
+}
+
+IDEInstaller::~IDEInstaller(void)
+{
+}
+
+InstallationStep
+IDEInstaller::GetNext(InstallationStep step)
+{
+ AppLogTag(OSP_INSTALLER, "IDEInstaller::GetNext()");
+ return DirectoryInstaller::GetNext(step);
+}
+
+InstallerError
+IDEInstaller::OnInit(void)
+{
+ AppLogTag(OSP_INSTALLER, "IDEInstaller::OnInit()");
+ return DirectoryInstaller::OnInit();
+}
+
+InstallerError
+IDEInstaller::OnRegister(void)
+{
+ AppLogTag(OSP_INSTALLER, "IDEInstaller::OnRegister()");
+ return DirectoryInstaller::OnRegister();
+}
+
+InstallerError
+IDEInstaller::OnEnd(void)
+{
+ AppLogTag(OSP_INSTALLER, "IDEInstaller::OnEnd()");
+ return DirectoryInstaller::OnEnd();
+}
+
+InstallerError
+IDEInstaller::OnError(void)
+{
+ AppLogTag(OSP_INSTALLER, "IDEInstaller::OnError()");
+ return DirectoryInstaller::OnError();
+}
+
+InstallerError
+IDEInstaller::OnUserCancel(void)
+{
+ AppLogTag(OSP_INSTALLER, "IDEInstaller::OnUserCancel()");
+ return DirectoryInstaller::OnUserCancel();
+}
+
+InstallerError
+IDEInstaller::OnRollback(void)
+{
+ AppLogTag(OSP_INSTALLER, "IDEInstaller::OnRollback()");
+ return DirectoryInstaller::OnRollback();
+}
diff --git a/src/Installer/IDEInstaller.h b/src/Installer/IDEInstaller.h
new file mode 100644
index 0000000..0218d4d
--- /dev/null
+++ b/src/Installer/IDEInstaller.h
@@ -0,0 +1,55 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file IDEInstaller.h
+ * @brief This is the header file for the %IDEInstaller class.
+ *
+ * This header file contains the declarations of the %IDEInstaller class.
+ */
+#ifndef _IDE_INSTALLER_H_
+#define _IDE_INSTALLER_H_
+
+#include "DirectoryInstaller.h"
+
+/**
+ * @class IDEInstaller
+ * @brief This class represents the class of IDEInstaller.
+ * @since 1.0
+ *
+ * This class represents the class of IDEInstaller.
+ *
+ */
+class IDEInstaller
+ : public DirectoryInstaller
+{
+public:
+ IDEInstaller(void);
+ virtual ~IDEInstaller(void);
+
+ virtual InstallationStep GetNext(InstallationStep step);
+
+ virtual InstallerError OnInit(void);
+ virtual InstallerError OnRegister(void);
+ virtual InstallerError OnEnd(void);
+
+ virtual InstallerError OnError(void);
+ virtual InstallerError OnRollback(void);
+ virtual InstallerError OnUserCancel(void);
+
+}; // IDEInstaller
+
+#endif //_IDE_INSTALLER_H_
diff --git a/src/Installer/Installer.cpp b/src/Installer/Installer.cpp
new file mode 100755
index 0000000..a65eb60
--- /dev/null
+++ b/src/Installer/Installer.cpp
@@ -0,0 +1,162 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file Installer.cpp
+ * @brief This is the implementation file for %Installer class.
+ */
+
+#include <stdio.h>
+#include <sys/stat.h>
+
+#include <FApp_PackageInfoImpl.h>
+#include <FApp_PackageManagerImpl.h>
+
+#include "Installer.h"
+#include "PermissionManager.h"
+#include "ConfigurationManager.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::App;
+using namespace Osp::Io;
+
+Installer::Installer(void)
+:__pContext(null)
+{
+}
+
+Installer::~Installer(void)
+{
+}
+
+InstallerError
+Installer::Construct(InstallationContext* pContext)
+{
+ __pContext = pContext;
+ return INSTALLER_ERROR_NONE;
+}
+
+InstallationStep
+Installer::GetNext(InstallationStep step)
+{
+ AppLogTag(OSP_INSTALLER, "step = [%d]", step);
+
+ if (step == INSTALLER_STEP_PARSE_SIGNATURE)
+ {
+ step = INSTALLER_STEP_END;
+ }
+ else
+ {
+ step = (InstallationStep)(step + 1);
+ }
+
+ return step;
+}
+
+InstallerError
+Installer::OnInit(void)
+{
+ AppLogTag(OSP_INSTALLER, "Installer::OnInit()");
+
+ return INSTALLER_ERROR_NONE;
+}
+
+InstallerError
+Installer::OnRegister(void)
+{
+ AppLogTag(OSP_INSTALLER, "START");
+ InstallationContext* pContext = GetContext();
+ TryReturn(pContext, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pContext is null");
+
+ InstallerOperation operation = pContext->GetInstallerOperation();
+ _PackageInfoImpl* pInfoImpl = null;
+
+ _PackageManagerImpl *pManagerImpl = null;
+ pManagerImpl = pManagerImpl->GetInstance();
+ TryReturn(pManagerImpl, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pManagerImpl is null");
+
+ pInfoImpl = pContext->GetPackageInfoImpl();
+ TryReturn(pInfoImpl, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pInfoImpl is null");
+
+ if (operation == INSTALLER_OPERATION_INSTALL)
+ {
+ pManagerImpl->UnregisterPackageInfo(pContext->GetAppId());
+ pManagerImpl->RegisterPackageInfo(*pContext->GetPackageInfoImpl());
+ }
+ else
+ {
+ pManagerImpl->UnregisterPackageInfo(pContext->GetAppId());
+ }
+ AppLogTag(OSP_INSTALLER, "END");
+
+ return INSTALLER_ERROR_NONE;
+}
+
+InstallerError
+Installer::OnEnd(void)
+{
+ AppLogTag(OSP_INSTALLER, "START");
+ InstallationContext* pContext = GetContext();
+ TryReturn(pContext, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pContext is null");
+
+ InstallerOperation operation = pContext->GetInstallerOperation();
+ ConfigurationManager configurationManager;
+
+ pContext->SetContinue(false);
+
+ if (operation == INSTALLER_OPERATION_INSTALL)
+ {
+ PermissionManager::SetDirectory(pContext);
+ PermissionManager::SetFile(pContext);
+
+ configurationManager.CreateFile(pContext);
+ }
+ else if (operation == INSTALLER_OPERATION_UNINSTALL)
+ {
+ configurationManager.RemoveFile(pContext);
+ }
+ AppLogTag(OSP_INSTALLER, "END");
+
+ return INSTALLER_ERROR_NONE;
+}
+
+InstallerError
+Installer::OnError(void)
+{
+ AppLogTag(OSP_INSTALLER, "Installer::OnError()");
+ return INSTALLER_ERROR_NONE;
+}
+
+InstallerError
+Installer::OnRollback(void)
+{
+ AppLogTag(OSP_INSTALLER, "Installer::OnRollback()");
+ return INSTALLER_ERROR_NONE;
+}
+
+InstallerError
+Installer::OnUserCancel(void)
+{
+ AppLogTag(OSP_INSTALLER, "Installer::OnUserCancel()");
+ return INSTALLER_ERROR_NONE;
+}
+
+InstallationContext*
+Installer::GetContext(void)
+{
+ return __pContext;
+}
diff --git a/src/Installer/Installer.h b/src/Installer/Installer.h
new file mode 100644
index 0000000..c131e33
--- /dev/null
+++ b/src/Installer/Installer.h
@@ -0,0 +1,62 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file Installer.h
+ * @brief This is the header file for the %Installer class.
+ *
+ * This header file contains the declarations of the %Installer class.
+ */
+#ifndef _INSTALLER_H_
+#define _INSTALLER_H_
+
+#include "InstallerDefs.h"
+#include "InstallationContext.h"
+
+/**
+ * @class Installer
+ * @brief This class represents the class of Installer.
+ * @since 1.0
+ *
+ * This class represents the class of Installer.
+ *
+ */
+class Installer
+{
+public:
+ Installer(void);
+ virtual InstallerError Construct(InstallationContext* pContext);
+ virtual ~Installer(void);
+
+ virtual InstallationStep GetNext(InstallationStep step);
+
+ virtual InstallerError OnInit(void);
+ virtual InstallerError OnRegister(void);
+ virtual InstallerError OnEnd(void);
+
+ virtual InstallerError OnError(void);
+ virtual InstallerError OnRollback(void);
+ virtual InstallerError OnUserCancel(void);
+
+protected:
+ InstallationContext* GetContext(void);
+
+private:
+ InstallationContext* __pContext;
+
+}; // Installer
+
+#endif // _INSTALLER_H_
diff --git a/src/Installer/PackageInstaller.cpp b/src/Installer/PackageInstaller.cpp
new file mode 100755
index 0000000..611fccd
--- /dev/null
+++ b/src/Installer/PackageInstaller.cpp
@@ -0,0 +1,83 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file PackageInstaller.cpp
+ * @brief This is the implementation file for %PackageInstaller class.
+ */
+
+#include "PackageInstaller.h"
+
+using namespace Osp::Io;
+
+PackageInstaller::PackageInstaller(void)
+{
+}
+
+PackageInstaller::~PackageInstaller(void)
+{
+}
+
+InstallationStep
+PackageInstaller::GetNext(InstallationStep step)
+{
+ AppLogTag(OSP_INSTALLER, "PackageInstaller::GetNext()");
+ return Installer::GetNext(step);
+}
+
+InstallerError
+PackageInstaller::OnInit(void)
+{
+ AppLogTag(OSP_INSTALLER, "PackageInstaller::OnInit()");
+ return Installer::OnInit();
+}
+
+InstallerError
+PackageInstaller::OnRegister(void)
+{
+ AppLogTag(OSP_INSTALLER, "PackageInstaller::OnRegister()");
+ return Installer::OnRegister();
+}
+
+InstallerError
+PackageInstaller::OnEnd(void)
+{
+ AppLogTag(OSP_INSTALLER, "PackageInstaller::OnEnd()");
+
+ return Installer::OnEnd();
+}
+
+InstallerError
+PackageInstaller::OnError(void)
+{
+ AppLogTag(OSP_INSTALLER, "PackageInstaller::OnError()");
+
+ return Installer::OnError();
+}
+
+InstallerError
+PackageInstaller::OnRollback(void)
+{
+ AppLogTag(OSP_INSTALLER, "PackageInstaller::OnRollback()");
+ return Installer::OnRollback();
+}
+
+InstallerError
+PackageInstaller::OnUserCancel(void)
+{
+ AppLogTag(OSP_INSTALLER, "PackageInstaller::OnUserCancel()");
+ return Installer::OnUserCancel();
+}
diff --git a/src/Installer/PackageInstaller.h b/src/Installer/PackageInstaller.h
new file mode 100644
index 0000000..8d6c71f
--- /dev/null
+++ b/src/Installer/PackageInstaller.h
@@ -0,0 +1,55 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file PackageInstaller.h
+ * @brief This is the header file for the %PackageInstaller class.
+ *
+ * This header file contains the declarations of the %PackageInstaller class.
+ */
+#ifndef _PACKAGE_INSTALLER_H_
+#define _PACKAGE_INSTALLER_H_
+
+#include "Installer.h"
+
+/**
+ * @class PackageInstaller
+ * @brief This class represents the class of PackageInstaller.
+ * @since 1.0
+ *
+ * This class represents the class of PackageInstaller.
+ *
+ */
+class PackageInstaller
+ : public Installer
+{
+public:
+ PackageInstaller(void);
+ virtual ~PackageInstaller(void);
+
+ virtual InstallationStep GetNext(InstallationStep step);
+
+ virtual InstallerError OnInit(void);
+ virtual InstallerError OnRegister(void);
+ virtual InstallerError OnEnd(void);
+
+ virtual InstallerError OnError(void);
+ virtual InstallerError OnRollback(void);
+ virtual InstallerError OnUserCancel(void);
+
+}; // PackageInstaller
+
+#endif // _PACKAGE_INSTALLER_H_
diff --git a/src/Installer/PreloadedInstaller.cpp b/src/Installer/PreloadedInstaller.cpp
new file mode 100755
index 0000000..7aee9da
--- /dev/null
+++ b/src/Installer/PreloadedInstaller.cpp
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file PreloadedInstaller.cpp
+ * @brief This is the implementation file for %PreloadedInstaller class.
+ */
+
+#include "PreloadedInstaller.h"
+
+PreloadedInstaller::PreloadedInstaller(void)
+{
+}
+
+PreloadedInstaller::~PreloadedInstaller(void)
+{
+}
+
+InstallationStep
+PreloadedInstaller::GetNext(InstallationStep step)
+{
+ AppLogTag(OSP_INSTALLER, "PreloadedInstaller::GetNext()");
+ return DirectoryInstaller::GetNext(step);
+}
+
+InstallerError
+PreloadedInstaller::OnInit(void)
+{
+ AppLogTag(OSP_INSTALLER, "PreloadedInstaller::OnInit()");
+ return DirectoryInstaller::OnInit();
+}
+
+InstallerError
+PreloadedInstaller::OnRegister(void)
+{
+ AppLogTag(OSP_INSTALLER, "PreloadedInstaller::OnRegister()");
+ return DirectoryInstaller::OnRegister();
+}
+
+InstallerError
+PreloadedInstaller::OnEnd(void)
+{
+ AppLogTag(OSP_INSTALLER, "PreloadedInstaller::OnEnd()");
+ return DirectoryInstaller::OnEnd();
+}
+
+InstallerError
+PreloadedInstaller::OnError(void)
+{
+ AppLogTag(OSP_INSTALLER, "PreloadedInstaller::OnError()");
+ return DirectoryInstaller::OnError();
+}
+
+InstallerError
+PreloadedInstaller::OnRollback(void)
+{
+ AppLogTag(OSP_INSTALLER, "PreloadedInstaller::OnRollback()");
+ return DirectoryInstaller::OnRollback();
+}
+
+InstallerError
+PreloadedInstaller::OnUserCancel(void)
+{
+ AppLogTag(OSP_INSTALLER, "PreloadedInstaller::OnUserCancel()");
+ return DirectoryInstaller::OnUserCancel();
+}
diff --git a/src/Installer/PreloadedInstaller.h b/src/Installer/PreloadedInstaller.h
new file mode 100644
index 0000000..a19eb44
--- /dev/null
+++ b/src/Installer/PreloadedInstaller.h
@@ -0,0 +1,55 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file PreloadedInstaller.h
+ * @brief This is the header file for the %PreloadedInstaller class.
+ *
+ * This header file contains the declarations of the %PreloadedInstaller class.
+ */
+#ifndef _PRELOADED_INSTALLER_H_
+#define _PRELOADED_INSTALLER_H_
+
+#include "DirectoryInstaller.h"
+
+/**
+ * @class PreloadedInstaller
+ * @brief This class represents the class of PreloadedInstaller.
+ * @since 1.0
+ *
+ * This class represents the class of PreloadedInstaller.
+ *
+ */
+class PreloadedInstaller
+ : public DirectoryInstaller
+{
+public:
+ PreloadedInstaller(void);
+ virtual ~PreloadedInstaller(void);
+
+ virtual InstallationStep GetNext(InstallationStep step);
+
+ virtual InstallerError OnInit(void);
+ virtual InstallerError OnRegister(void);
+ virtual InstallerError OnEnd(void);
+
+ virtual InstallerError OnError(void);
+ virtual InstallerError OnRollback(void);
+ virtual InstallerError OnUserCancel(void);
+
+}; // PreloadedInstaller
+
+#endif // _PRELOADED_INSTALLER_H_
diff --git a/src/Installer/RestorationInstaller.cpp b/src/Installer/RestorationInstaller.cpp
new file mode 100755
index 0000000..26ce8e6
--- /dev/null
+++ b/src/Installer/RestorationInstaller.cpp
@@ -0,0 +1,79 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file RestorationInstaller.cpp
+ * @brief This is the implementation file for %RestorationInstaller class.
+ */
+
+#include "RestorationInstaller.h"
+
+RestorationInstaller::RestorationInstaller(void)
+{
+}
+
+RestorationInstaller::~RestorationInstaller(void)
+{
+}
+
+InstallationStep
+RestorationInstaller::GetNext(InstallationStep step)
+{
+ AppLogTag(OSP_INSTALLER, "RestorationInstaller::GetNext()");
+ return DirectoryInstaller::GetNext(step);
+}
+
+InstallerError
+RestorationInstaller::OnInit(void)
+{
+ AppLogTag(OSP_INSTALLER, "RestorationInstaller::OnInit()");
+ return DirectoryInstaller::OnInit();
+}
+
+InstallerError
+RestorationInstaller::OnRegister(void)
+{
+ AppLogTag(OSP_INSTALLER, "RestorationInstaller::OnRegister()");
+ return DirectoryInstaller::OnRegister();
+}
+
+InstallerError
+RestorationInstaller::OnEnd(void)
+{
+ AppLogTag(OSP_INSTALLER, "RestorationInstaller::OnEnd()");
+ return DirectoryInstaller::OnEnd();
+}
+
+InstallerError
+RestorationInstaller::OnError(void)
+{
+ AppLogTag(OSP_INSTALLER, "RestorationInstaller::OnError()");
+ return DirectoryInstaller::OnError();
+}
+
+InstallerError
+RestorationInstaller::OnRollback(void)
+{
+ AppLogTag(OSP_INSTALLER, "RestorationInstaller::OnRollback()");
+ return DirectoryInstaller::OnRollback();
+}
+
+InstallerError
+RestorationInstaller::OnUserCancel(void)
+{
+ AppLogTag(OSP_INSTALLER, "RestorationInstaller::OnUserCancel()");
+ return DirectoryInstaller::OnUserCancel();
+}
diff --git a/src/Installer/RestorationInstaller.h b/src/Installer/RestorationInstaller.h
new file mode 100644
index 0000000..baca42d
--- /dev/null
+++ b/src/Installer/RestorationInstaller.h
@@ -0,0 +1,55 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file RestorationInstaller.h
+ * @brief This is the header file for the %RestorationInstaller class.
+ *
+ * This header file contains the declarations of the %RestorationInstaller class.
+ */
+#ifndef _RESTORATION_INSTALLER_H_
+#define _RESTORATION_INSTALLER_H_
+
+#include "DirectoryInstaller.h"
+
+/**
+ * @class RestorationInstaller
+ * @brief This class represents the class of RestorationInstaller.
+ * @since 1.0
+ *
+ * This class represents the class of RestorationInstaller.
+ *
+ */
+class RestorationInstaller
+ : public DirectoryInstaller
+{
+public:
+ RestorationInstaller(void);
+ virtual ~RestorationInstaller(void);
+
+ virtual InstallationStep GetNext(InstallationStep step);
+
+ virtual InstallerError OnInit(void);
+ virtual InstallerError OnRegister(void);
+ virtual InstallerError OnEnd(void);
+
+ virtual InstallerError OnError(void);
+ virtual InstallerError OnRollback(void);
+ virtual InstallerError OnUserCancel(void);
+
+}; // RestorationInstaller
+
+#endif //_RESTORATION_INSTALLER_H_
diff --git a/src/Manager/ConfigurationManager.cpp b/src/Manager/ConfigurationManager.cpp
new file mode 100755
index 0000000..4a21f1b
--- /dev/null
+++ b/src/Manager/ConfigurationManager.cpp
@@ -0,0 +1,347 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file ConfigurationManager.cpp
+ * @brief This is the implementation file for %ConfigurationManager class.
+ */
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <pkgmgr_parser.h>
+
+#include <FBaseUtilStringUtil.h>
+#include <FIoFile.h>
+#include <FApp_PackageInfoImpl.h>
+#include <FApp_PackageManagerImpl.h>
+#include <FBase_StringConverter.h>
+
+#include "ConfigurationManager.h"
+#include "ManifestGenerator.h"
+#include "InstallerUtil.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::Base::Utility;
+using namespace Osp::App;
+using namespace Osp::Io;
+
+ConfigurationManager::ConfigurationManager(void)
+{
+}
+
+ConfigurationManager::~ConfigurationManager(void)
+{
+}
+
+bool
+ConfigurationManager::CreateFile(InstallationContext* pContext)
+{
+ bool res = false;
+ const char* pBinaryPath = null;
+ String xmlPath;
+ char* pXmlPath = null;
+ int err = 0;
+
+ _PackageInfoImpl *pPackageInfoImpl = null;
+ pPackageInfoImpl = pContext->GetPackageInfoImpl();
+ TryReturn(pPackageInfoImpl, false, "[osp-installer] pPackageInfoImpl is null.");
+
+ String rootPath;
+ rootPath = pPackageInfoImpl->GetAppRootPath();
+
+ String apiVersion;
+ apiVersion = pPackageInfoImpl->GetAppApiVersion();
+ String versionInfoFile;
+ versionInfoFile.Format(1024, L"%ls%ls", rootPath.GetPointer(), VERSION_INFO_FILE);
+ CreateInfoFile(versionInfoFile, &apiVersion);
+
+ String webServicePrivilege("WEB_SERVICE");
+ if (FindPrivilege(pContext, webServicePrivilege) == true)
+ {
+ AppLogTag(OSP_INSTALLER, "WEB_SERVICE privilege is detected. rootPath=[%ls]", rootPath.GetPointer());
+
+ String webServiceInfoFile;
+ webServiceInfoFile.Format(1024, L"%ls%ls", rootPath.GetPointer(), WEBSERVICE_INFO_FILE);
+ CreateInfoFile(webServiceInfoFile, null);
+ }
+
+ _PackageAppInfoImpl* pAppInfoImpl = null;
+ ArrayList* pAppList = null;
+ pAppList = pPackageInfoImpl->GetAppInfoList();
+ for (int i = 0 ; i < pAppList->GetCount(); i++)
+ {
+ pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
+ if (pAppInfoImpl)
+ {
+ result r = E_SUCCESS;
+
+ String appName;
+ appName = pAppInfoImpl->GetName();
+
+ String appType;
+ appType = pAppInfoImpl->GetType();
+
+ String packageName;
+ packageName = pAppInfoImpl->GetPackageName();
+
+ String binaryPath;
+ binaryPath.Format(1024, L"%ls%ls/%ls", rootPath.GetPointer(), DIR_BIN, appName.GetPointer());
+
+ pBinaryPath = _StringConverter::CopyToCharArrayN(binaryPath);
+ TryCatch(pBinaryPath, res = false, "[osp-installer] pBinaryPath is null");
+
+ if (File::IsFileExist(binaryPath) == true)
+ {
+ InstallerUtil::Remove(binaryPath);
+ }
+
+ if (appType == L"UiApp")
+ {
+ //err = symlink(UIAPP_LOADER_PATH, pBinaryPath);
+
+ r = File::Copy(UIAPP_LOADER_PATH, pBinaryPath, false);
+ TryCatch(!IsFailed(r), res = false, "[osp-installer] File::Copy() failed, filePath=[%s]", pBinaryPath);
+
+ ArrayList* pFeatureList = pAppInfoImpl->GetAppFeatureList();
+ TryCatch(pFeatureList, res = false, "[osp-installer] pFeatureList is null");
+
+ String coordinateSystem;
+ String baseScreenSize;
+ String logicalCoordinate;
+
+ for (int j = 0; j < pFeatureList->GetCount(); j++)
+ {
+ _AppFeatureInfoImpl* pAppFeature = dynamic_cast<_AppFeatureInfoImpl*>(pFeatureList->GetAt(j));
+
+ if (pAppFeature != null)
+ {
+ if (pAppFeature->GetName() == L"CoordinateSystem")
+ {
+ coordinateSystem = pAppFeature->GetValue();
+ }
+
+ if (pAppFeature->GetName() == L"BaseScreenSize")
+ {
+ baseScreenSize = pAppFeature->GetValue();
+ }
+
+ if (pAppFeature->GetName() == L"LogicalCoordinate")
+ {
+ logicalCoordinate = pAppFeature->GetValue();
+ }
+ }
+ }
+
+ String uiScalability;
+ uiScalability.Format(1024, UISCALABILITY_INFO, coordinateSystem.GetPointer(), baseScreenSize.GetPointer(), logicalCoordinate.GetPointer());
+
+ String uiScalabilityInfoFile;
+ uiScalabilityInfoFile.Format(1024, L"%ls%ls", rootPath.GetPointer(), UISCALABILITY_INFO_FILE);
+
+ CreateInfoFile(uiScalabilityInfoFile, &uiScalability);
+ }
+ else if (appType == L"ServiceApp")
+ {
+ if (pContext->IsPreloaded() == false)
+ {
+ //err = symlink(SERVICEAPP_LOADER_PATH, pBinaryPath);
+ r = File::Copy(SERVICEAPP_LOADER_PATH, pBinaryPath, false);
+ TryCatch(!IsFailed(r), res = false, "[osp-installer] File::Copy() failed, filePath=[%s]", pBinaryPath);
+ }
+ else
+ {
+ //err = symlink(SYSTEMAPP_LOADER_PATH, pBinaryPath);
+ r = File::Copy(SYSTEMAPP_LOADER_PATH, pBinaryPath, false);
+ TryCatch(!IsFailed(r), res = false, "[osp-installer] File::Copy() failed, filePath=[%s]", pBinaryPath);
+ }
+ }
+
+ int res = -1;
+ res = chmod(pBinaryPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ if (res != 0)
+ {
+ AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", pBinaryPath, res);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", pBinaryPath, res);
+ }
+
+ delete[] pBinaryPath;
+ pBinaryPath = null;
+ }
+ }
+
+ //if (pContext->IsPreloaded() == true)
+ //{
+ // xmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, pContext->GetAppId().GetPointer());
+ //}
+ //else
+ //{
+ xmlPath.Format(1024, DIR_RW_PACKAGE_SYSTEM_MANIFEST, pContext->GetAppId().GetPointer());
+ //}
+
+ pXmlPath = _StringConverter::CopyToCharArrayN(xmlPath);
+ TryCatch(pXmlPath != null, res = false, "[osp-installer] pXmlPath is null");
+
+ pkgmgr_parser_parse_manifest_for_uninstallation(pXmlPath, null);
+
+ CreateSystemXmlFile(pContext);
+
+ AppLogTag(OSP_INSTALLER, "START(sync)");
+ sync();
+ AppLogTag(OSP_INSTALLER, "END(sync)");
+
+ AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() START");
+ if (pkgmgr_parser_parse_manifest_for_installation(pXmlPath, null) != 0)
+ {
+ AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() is failed.[%s]", pXmlPath);
+ }
+ AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_installation() END");
+
+ res = true;
+
+CATCH:
+ delete[] pBinaryPath;
+ delete[] pXmlPath;
+
+ return res;
+}
+
+bool
+ConfigurationManager::RemoveFile(InstallationContext* pContext)
+{
+ String xmlPath;
+ char* pXmlPath = null;
+ _PackageInfoImpl *pPackageInfoImpl = null;
+ _PackageAppInfoImpl* pAppInfoImpl = null;
+ ArrayList* pAppList = null;
+
+ //if (pContext->IsPreloaded() == true)
+ //{
+ // xmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, pContext->GetAppId().GetPointer());
+ //}
+ //else
+ //{
+ xmlPath.Format(1024, DIR_RW_PACKAGE_SYSTEM_MANIFEST, pContext->GetAppId().GetPointer());
+ //}
+
+ pXmlPath = _StringConverter::CopyToCharArrayN(xmlPath);
+ TryCatch(pXmlPath != null, , "[osp-installer] pXmlPath is null");
+
+ AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() START");
+ if (pkgmgr_parser_parse_manifest_for_uninstallation(pXmlPath, null) != 0)
+ {
+ AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() is failed.[%s]", pXmlPath);
+ }
+ AppLogTag(OSP_INSTALLER, "pkgmgr_parser_parse_manifest_for_uninstallation() END");
+
+ if (File::IsFileExist(xmlPath) == true)
+ {
+ AppLogTag(OSP_INSTALLER, "removing xml filePath=[%ls]", xmlPath.GetPointer());
+
+ InstallerUtil::Remove(xmlPath);
+ }
+
+ pPackageInfoImpl = pContext->GetPackageInfoImpl();
+ TryCatch(pPackageInfoImpl, , "[osp-installer] pPackageInfoImpl is null.");
+
+ pAppList = pPackageInfoImpl->GetAppInfoList();
+
+ for (int i = 0 ; i < pAppList->GetCount(); i++)
+ {
+ pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
+ if (pAppInfoImpl)
+ {
+ String packageName = pAppInfoImpl->GetPackageName();
+ String destPath;
+ char dest[772] = {0};
+
+ destPath.Format(1024, L"%ls/%ls", SLP_APP_PATH, packageName.GetPointer());
+ sprintf(dest, "%ls", destPath.GetPointer());
+ unlink(dest);
+ }
+ }
+
+CATCH:
+ delete[] pXmlPath;
+
+ return true;
+}
+
+bool
+ConfigurationManager::CreateSystemXmlFile(InstallationContext* pContext)
+{
+ AppLogTag(OSP_INSTALLER, "SystemXmlFile - START");
+ bool ret = false;
+
+ ManifestGenerator manifestGenerator;
+ manifestGenerator.Construct(pContext);
+ ret = manifestGenerator.Write();
+
+ if (ret == false)
+ {
+ fprintf(stderr, "manifestGenerator.Write() is failed.\n");
+ AppLogTag(OSP_INSTALLER, "manifestGenerator.Write() is failed.");
+ }
+ AppLogTag(OSP_INSTALLER, "SystemXmlFile - END");
+
+ return ret;
+}
+
+bool
+ConfigurationManager::CreateInfoFile(const String& filePath, const String* pContext)
+{
+ result r = E_SUCCESS;
+ File file;
+
+ r = file.Construct(filePath, "w");
+ TryReturn(!IsFailed(r), false, "[osp-installer] file.Construct() failed, filePath=[%ls]", filePath.GetPointer());
+
+ if (pContext)
+ {
+ r = file.Write(*pContext);
+ TryReturn(!IsFailed(r), false, "[osp-installer] file.Write() failed, filePath=[%ls]", filePath.GetPointer());
+ AppLogTag(OSP_INSTALLER, "Context = [%ls]", pContext->GetPointer());
+ }
+
+ AppLogTag(OSP_INSTALLER, "filePath = [%ls]", filePath.GetPointer());
+
+ return true;
+}
+
+bool
+ConfigurationManager::FindPrivilege(InstallationContext* pContext, const String& privilege) const
+{
+ TryReturn(pContext, false, "[osp-installer] pContext is null.");
+
+ bool ret = false;
+ const ArrayList* pPrivilegeList = pContext->GetPrivilegeList();
+
+ if (pPrivilegeList)
+ {
+ if (pPrivilegeList->Contains(privilege) == true)
+ {
+ AppLogTag(OSP_INSTALLER, "Privilege = [%ls]", privilege.GetPointer());
+ ret = true;
+ }
+ }
+
+ return ret;
+}
diff --git a/src/Manager/ConfigurationManager.h b/src/Manager/ConfigurationManager.h
new file mode 100755
index 0000000..31b8995
--- /dev/null
+++ b/src/Manager/ConfigurationManager.h
@@ -0,0 +1,55 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file ConfigurationManager.h
+ * @brief This is the header file for the %ConfigurationManager class.
+ *
+ * This header file contains the declarations of the %ConfigurationManager class.
+ */
+#ifndef _CONFIGURATION_MANAGER_H_
+#define _CONFIGURATION_MANAGER_H_
+
+#include <FApp_AppInfoImpl.h>
+
+#include "InstallationContext.h"
+
+
+/**
+ * @class ConfigurationManager
+ * @brief This class represents the class of ConfigurationManager.
+ * @since 1.0
+ *
+ * This class represents the class of ConfigurationManager.
+ *
+ */
+class ConfigurationManager
+{
+public:
+ ConfigurationManager(void);
+ virtual ~ConfigurationManager(void);
+
+ bool CreateFile(InstallationContext* pContext);
+ bool RemoveFile(InstallationContext* pContext);
+
+private:
+ bool CreateSystemXmlFile(InstallationContext* pContext);
+ bool CreateInfoFile(const Osp::Base::String& filePath, const Osp::Base::String* pContext);
+ bool FindPrivilege(InstallationContext* pContext, const Osp::Base::String& privilege) const;
+
+}; // ConfigurationManager
+
+#endif // _CONFIGURATION_MANAGER_H_
diff --git a/src/Manager/InstallerManager.cpp b/src/Manager/InstallerManager.cpp
new file mode 100755
index 0000000..fefc02d
--- /dev/null
+++ b/src/Manager/InstallerManager.cpp
@@ -0,0 +1,818 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file InstallerManager.cpp
+ * @brief This is the implementation file for %InstallerManager class.
+ */
+
+#include <unistd.h>
+
+#include <FIoFile.h>
+#include <FIoDirectory.h>
+#include <FBase_StringConverter.h>
+#include <FApp_PackageInfoImpl.h>
+
+#include "InstallerManager.h"
+#include "GuestInstaller.h"
+#include "IDEInstaller.h"
+#include "PreloadedInstaller.h"
+#include "RestorationInstaller.h"
+#include "InstallerUtil.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Utility;
+using namespace Osp::Base::Collection;
+using namespace Osp::Io;
+using namespace Osp::App;
+
+const int BUFSIZE = 512;
+InstallerManager* InstallerManager::__pInstallerManager = null;
+
+InstallerManager::InstallerManager(void)
+: __pContext(null)
+, __pInstaller(null)
+{
+}
+
+InstallerManager::~InstallerManager(void)
+{
+ delete __pContext;
+ __pContext = null;
+
+ delete __pInstaller;
+ __pInstaller = null;
+}
+
+InstallerManager*
+InstallerManager::GetInstance()
+{
+ if (__pInstallerManager == null)
+ {
+ AppLogTag(OSP_INSTALLER, "InstallerManager::GetInstance Create new instance.");
+ __pInstallerManager = new InstallerManager();
+ TryReturn(__pInstallerManager, null, "[osp-installer] __pInstallerManager is null");
+ }
+
+ return __pInstallerManager;
+}
+
+InstallerError
+InstallerManager::Construct(const String& path, InstallerType installerType, InstallerOperation operation, RequesterType requesterType)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+
+ __pContext = new InstallationContext();
+ TryReturn(__pContext, INSTALLER_ERROR_MEMORY, "[osp-installer] __pContext is null.");
+
+ error = __pContext->Construct();
+ TryReturn(error == INSTALLER_ERROR_NONE, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] __pContext->Construct() failed.");
+
+ __pContext->SetInstallerOperation(operation);
+
+ if (requesterType == REQUESTER_TYPE_PRELOADED)
+ {
+ __pContext->SetPreloaded(true);
+ }
+
+ __pInstaller = CreateInstaller(installerType);
+ TryReturn(__pInstaller, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] __pInstaller is null.");
+
+ if (installerType == INSTALLER_TYPE_DIRECTORY)
+ {
+ _PackageInfoImpl *pPackageInfoImpl = null;
+
+ pPackageInfoImpl = __pContext->GetPackageInfoImpl();
+ pPackageInfoImpl->SetAppRootPath(path);
+
+ AppLogTag(OSP_INSTALLER, "path = [%ls]", path.GetPointer());
+ }
+
+ if (operation == INSTALLER_OPERATION_INSTALL)
+ {
+ __pContext->SetInputPath(path);
+ __pContext->SetPackagePath(path);
+ __pContext->SetInstallDir(path);
+
+ FileAttributes attribute;
+ result r = File::GetAttributes(path, attribute);
+ TryReturn(!IsFailed(r), INSTALLER_ERROR_INVALID_PACKAGE, "[osp-installer] path is invalid. path=[%ls]", path.GetPointer());
+
+ // org.tizen.*
+ if (path.Contains(PACKAGE_NAME_PREFIX_ORG) == true)
+ {
+ __pContext->SetPackageNameType(INSTALLER_PREFIX_TYPE_ORG);
+ }
+ }
+ else if (operation == INSTALLER_OPERATION_UNINSTALL)
+ {
+ AppLogTag(OSP_INSTALLER, "operation is INSTALLER_OPERATION_UNINSTALL");
+ __pContext->SetCurrentInstallationStep(INSTALLER_STEP_INIT_UNINSTALL);
+ __pContext->SetAppId(path);
+ }
+
+ error = __pInstaller->Construct(__pContext);
+ TryReturn(error == INSTALLER_ERROR_NONE, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] __pInstaller->Construct() failed");
+
+ AppLogTag(OSP_INSTALLER, "Construct() is success");
+
+ return error;
+}
+
+void
+InstallerManager::Release(void)
+{
+ delete __pInstallerManager;
+ __pInstallerManager = null;
+}
+
+Installer*
+InstallerManager::CreateInstaller(InstallerType installerType)
+{
+ Installer* pInstaller = null;
+
+ switch (installerType)
+ {
+ case INSTALLER_TYPE_INSTALLER:
+ AppLogTag(OSP_INSTALLER, "INSTALLER_TYPE_INSTALLER");
+ pInstaller = new Installer();
+ break;
+
+ case INSTALLER_TYPE_PACKAGE:
+ AppLogTag(OSP_INSTALLER, "INSTALLER_TYPE_PACKAGE");
+ pInstaller = new PackageInstaller();
+ break;
+
+ case INSTALLER_TYPE_DIRECTORY:
+ AppLogTag(OSP_INSTALLER, "INSTALLER_TYPE_DIRECTORY");
+ pInstaller = new DirectoryInstaller();
+ break;
+
+ case INSTALLER_TYPE_GUEST:
+ AppLogTag(OSP_INSTALLER, "INSTALLER_TYPE_GUEST");
+ pInstaller = new GuestInstaller();
+ break;
+
+ case INSTALLER_TYPE_PRELOADED:
+ AppLogTag(OSP_INSTALLER, "INSTALLER_TYPE_PRELOADED");
+ pInstaller = new PreloadedInstaller();
+ break;
+
+ case INSTALLER_TYPE_IDE:
+ AppLogTag(OSP_INSTALLER, "INSTALLER_TYPE_IDE");
+ pInstaller = new IDEInstaller();
+ break;
+
+ case INSTALLER_TYPE_RESTORATION:
+ AppLogTag(OSP_INSTALLER, "INSTALLER_TYPE_RESTORATION");
+ pInstaller = new RestorationInstaller();
+ break;
+
+ default:
+ AppLogExceptionTag(OSP_INSTALLER, "Installer is not found.");
+ break;
+ }
+
+ return pInstaller;
+}
+
+InstallationStep
+InstallerManager::GetNext(void)
+{
+ InstallationStep step = __pContext->GetCurrentInstallationStep();
+ return __pInstaller->GetNext(step);
+}
+
+InstallerError
+InstallerManager::Init(void)
+{
+ return __pInstaller->OnInit();
+}
+
+InstallerError
+InstallerManager::Error(void)
+{
+ return __pInstaller->OnError();
+}
+
+InstallerError
+InstallerManager::Register(void)
+{
+ return __pInstaller->OnRegister();
+}
+
+InstallerError
+InstallerManager::End(void)
+{
+ return __pInstaller->OnEnd();
+}
+
+InstallerError
+InstallerManager::Rollback(void)
+{
+ return __pInstaller->OnRollback();
+}
+
+InstallerError
+InstallerManager::UserCancel(void)
+{
+ return __pInstaller->OnUserCancel();
+}
+
+InstallerError
+InstallerManager::Activate(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ IInstallationStep* pStep = null;
+ InstallationStep currentStep;
+
+ while (__pContext->GetState() == INSTALLER_STATE_RUNNING)
+ {
+ currentStep = GetNext();
+ __pContext->ChangeStep(currentStep);
+
+ pStep = __pContext->GetStep();
+ if (pStep)
+ {
+ error = pStep->Run(__pContext);
+
+ if (error != INSTALLER_ERROR_NONE)
+ {
+ __pContext->SetError(error);
+ fprintf(stderr, "Activate:: Error = [%d]\n", error);
+ Error();
+ return error;
+ }
+ }
+
+ if (currentStep == INSTALLER_STEP_INIT)
+ {
+ error = Init();
+ TryReturn(error == INSTALLER_ERROR_NONE, error, "[osp-installer] error is occurred.");
+ }
+ else if (currentStep == INSTALLER_STEP_END)
+ {
+ error = Register();
+ TryReturn(error == INSTALLER_ERROR_NONE, error, "[osp-installer] error is occurred.");
+
+ error = End();
+ TryReturn(error == INSTALLER_ERROR_NONE, error, "[osp-installer] error is occurred.");
+ }
+
+ if (__pContext->IsContinue() == false)
+ {
+ break;
+ }
+
+ if (__pContext->GetCurrentInstallationStep() >= INSTALLER_STEP_MAX)
+ {
+ break;
+ }
+ }
+
+ return error;
+}
+
+InstallerError
+InstallerManager::Progress(void)
+{
+ return INSTALLER_ERROR_NONE;
+}
+
+InstallationContext*
+InstallerManager::GetContext(void)
+{
+ return __pContext;
+}
+
+int
+InstallerManager::Request(const String& path, InstallerOperation operation, RequesterType requesterType, String& appid, int& errorType)
+{
+ InstallerType type = INSTALLER_TYPE_INSTALLER;
+ InstallationContext* pContext = null;
+ InstallerError error = INSTALLER_ERROR_NONE;
+ InstallerManager* pInstallManager = null;
+ //bool isRunning = false;
+
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "InstallerManager::Request");
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "# operation = [%s]", (operation == INSTALLER_OPERATION_INSTALL) ? "Install":"Uninstall");
+ AppLogTag(OSP_INSTALLER, "# path = [%ls]", path.GetPointer());
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+
+ if (operation == INSTALLER_OPERATION_INSTALL)
+ {
+ FileAttributes attr;
+ result r = File::GetAttributes(path, attr);
+ TryCatch(!IsFailed(r), error = INSTALLER_ERROR_INVALID_PACKAGE, "[osp-installer] File::GetAttributes() failed");
+
+ if (attr.IsDirectory())
+ {
+ type = INSTALLER_TYPE_DIRECTORY;
+ }
+ else
+ {
+ type = INSTALLER_TYPE_PACKAGE;
+ }
+ }
+ else if (operation == INSTALLER_OPERATION_UNINSTALL)
+ {
+ type = INSTALLER_TYPE_INSTALLER;
+ }
+
+ pInstallManager = InstallerManager::GetInstance();
+ TryCatch(pInstallManager, error = INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pInstallManager is null.");
+
+ error = pInstallManager->Construct(path, type, operation, requesterType);
+ TryCatch(error == INSTALLER_ERROR_NONE, , "[osp-installer] pInstallManager->Construct() failed.");
+
+ error = pInstallManager->Activate();
+ TryCatch(error == INSTALLER_ERROR_NONE, , "[osp-installer] pInstallManager->Activate() failed.");
+
+ pContext = pInstallManager->GetContext();
+ TryCatch(pContext, error = INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pContext is null.");
+
+ appid = pContext->GetAppId();
+
+CATCH:
+ if (File::IsFileExist(DIR_OSP_APPLICATIONS_TEMP) == true)
+ {
+ InstallerUtil::Remove(DIR_OSP_APPLICATIONS_TEMP);
+ }
+
+ if (pInstallManager)
+ {
+ pInstallManager->Release();
+ }
+
+ if (error != INSTALLER_ERROR_NONE)
+ {
+ fprintf(stderr, " ErrorType [%d]\n", error);
+ }
+
+ errorType = error;
+ return error;
+}
+
+int
+InstallerManager::RequestRecursiveDirectory(const Osp::Base::String& path, int& errorType)
+{
+ Directory* pDir = null;
+ DirEnumerator* pDirEnum = null;
+ result r = E_SUCCESS;
+ int res = false;
+ String appid;
+ InstallerError error = INSTALLER_ERROR_NONE;
+
+ pDir = new Directory; // Allocate %Directory instance
+ TryCatch(pDir, res = false, "[osp-installer] pDir is null");
+
+ r = pDir->Construct(path);
+ TryCatch(!IsFailed(r), res = false, "[osp-installer] pDir->Construct() failed, path=[%ls]", path.GetPointer());
+
+ pDirEnum = pDir->ReadN();
+ TryCatch(pDirEnum, res = false, "[osp-installer] pDirEnum is null");
+
+ while (pDirEnum->MoveNext() == E_SUCCESS)
+ {
+ DirEntry entry = pDirEnum->GetCurrentDirEntry();
+
+ String entryName = entry.GetName();
+ String entryDir = path;
+ entryDir += L"/";
+ entryDir += entryName;
+
+ if (entryName == L"." || entryName == L"..")
+ {
+ continue;
+ }
+
+ if (entry.IsDirectory() == false)
+ {
+ continue;
+ }
+
+ const int entryLength = entryName.GetLength();
+ if (entryLength == APPID_LENGTH)
+ {
+ // AppId
+ }
+ else if (entryLength == APP_DIR_LENGTH)
+ {
+ if (entryName.Contains(PACKAGE_NAME_PREFIX_ORG) == false)
+ {
+ fprintf(stderr, " - Not osp = [%ls]: prefix mismatch\n", entryDir.GetPointer());
+ continue;
+ }
+ }
+ else
+ {
+ fprintf(stderr, " - Not osp = [%ls]: length(%d) mismatch\n", entryDir.GetPointer(), entryLength);
+ continue;
+ }
+
+ String xmlFile;
+ xmlFile.Format(1024, L"%ls%ls", entryDir.GetPointer(), PACKAGE_XML_FILE);
+
+ FileAttributes attr;
+ r = File::GetAttributes(xmlFile, attr);
+ if (IsFailed(r))
+ {
+ fprintf(stderr, " - Not osp = [%ls]: No manifest.xml\n", entryDir.GetPointer());
+ continue;
+ }
+
+ fprintf(stderr, "---------------------------------------------------\n");
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+
+ fprintf(stderr, " # directory = [%ls]\n", entryDir.GetPointer());
+ AppLogTag(OSP_INSTALLER, " # directory = [%ls]", entryDir.GetPointer());
+
+ Request(entryDir, INSTALLER_OPERATION_INSTALL, REQUESTER_TYPE_PRELOADED, appid, errorType);
+
+ fprintf(stderr, " # appid = [%ls], error = [%d]\n", appid.GetPointer(), errorType);
+ AppLogTag(OSP_INSTALLER, " # appid = [%ls], error = [%d]", appid.GetPointer(), errorType);
+
+ if (errorType != 0)
+ {
+ fprintf(stderr, " # result = [installation][failure <------------------------]\n");
+ AppLogTag(OSP_INSTALLER, " # result = [installation][failure <------------------------]");
+ }
+ else
+ {
+ fprintf(stderr, " # result = [installation][success]\n");
+ AppLogTag(OSP_INSTALLER, " # result = [installation][success]");
+ }
+
+ fprintf(stderr, "---------------------------------------------------\n");
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+ }
+
+ delete pDir;
+ pDir = null;
+ return error;
+
+CATCH:
+ delete pDir;
+ return error;
+}
+
+int
+InstallerManager::RequestByCommand(int argc, char **argv)
+{
+ int mode = 0;
+ char buf[BUFSIZE] = {0};
+ String appId;
+ int errorType = -1;
+ int result = 0;
+ bool output = false;
+
+ fprintf(stderr, "%s\n", OSP_INSTALLER_VERSION);
+ AppLogTag(OSP_INSTALLER, "%s", OSP_INSTALLER_VERSION);
+
+ fprintf(stderr, " - argc = [%d]\n", argc);
+ AppLogTag(OSP_INSTALLER, " - argc = [%d]", argc);
+
+ for (int i = 0; i < argc; i++)
+ {
+ fprintf(stderr, " - argv[%d] = [%s]\n", i, argv[i]);
+ AppLogTag(OSP_INSTALLER, " - argv[%d] = [%s]", i, argv[i]);
+ }
+
+ ParseCommandArg(argc, argv, &mode, buf, &output);
+
+ switch (mode)
+ {
+ case INSTALLER_MODE_INSTALL:
+ {
+ fprintf(stderr, "---------------------------------------------------\n");
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+ fprintf(stderr, " # directory = [%s]\n", buf);
+ AppLogTag(OSP_INSTALLER, " # directory = [%s]", buf);
+
+ result = InstallerManager::Request(buf, INSTALLER_OPERATION_INSTALL, REQUESTER_TYPE_NORMAL, appId, errorType);
+
+ fprintf(stderr, " # appId = [%ls], error = [%d]\n", appId.GetPointer(), errorType);
+ AppLogTag(OSP_INSTALLER, " # appId = [%ls], error = [%d]", appId.GetPointer(), errorType);
+
+ if (errorType != 0)
+ {
+ RemoveGarbage(buf);
+ fprintf(stderr, " # result = [Installation][failure]\n");
+ AppLogTag(OSP_INSTALLER, " # result = [Installation][failure]");
+ }
+ else
+ {
+ fprintf(stderr, " # result = [Installation][success]\n");
+ AppLogTag(OSP_INSTALLER, " # result = [Installation][success]");
+ }
+ }
+ break;
+
+ case INSTALLER_MODE_UNINSTALL:
+ {
+ fprintf(stderr, "---------------------------------------------------\n");
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+ fprintf(stderr, " # directory = [%s]\n", buf);
+ AppLogTag(OSP_INSTALLER, " # directory = [%s]", buf);
+
+ result = Request(buf, INSTALLER_OPERATION_UNINSTALL, REQUESTER_TYPE_NORMAL, appId, errorType);
+
+ fprintf(stderr, " # appId = [%ls], error = [%d]\n", appId.GetPointer(), errorType);
+ AppLogTag(OSP_INSTALLER, " # appId = [%ls], error = [%d]", appId.GetPointer(), errorType);
+
+ if (errorType != 0)
+ {
+ fprintf(stderr, " # result = [Uninstallation][failure]\n");
+ AppLogTag(OSP_INSTALLER, " # result = [Uninstallation][failure]");
+ }
+ else
+ {
+ fprintf(stderr, " # result = [Uninstallation][success]\n");
+ AppLogTag(OSP_INSTALLER, " # result = [Uninstallation][success]");
+ }
+ }
+ break;
+
+ case INSTALLER_MODE_RECURSIVE_DIRECTORY_INSTALL:
+ {
+ fprintf(stderr, "---------------------------------------------------\n");
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+
+ result = RequestRecursiveDirectory(buf, errorType);
+ }
+ break;
+
+ default:
+ {
+ fprintf(stderr, "__install_package_by_cmd, Invalid mode\n");
+ }
+ break;
+ }
+
+ fprintf(stderr, "---------------------------------------------------\n");
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+
+ if (output == true)
+ {
+ AppLogTag(OSP_INSTALLER, "stdout is updated by errorType");
+ fprintf(stdout, "%d", errorType);
+ }
+
+ return errorType;
+}
+
+int
+InstallerManager::ParseCommandArg(int argc, char **argv, int *mode, char *buf, bool *output)
+{
+ const char* pOpts_str = "u:i:r:v";
+ int s = 0;
+
+ if (mode == NULL)
+ {
+ fprintf(stderr, "mode is null\n");
+ exit(-1);
+ }
+
+ *mode = 0;
+
+ while (1)
+ {
+ s = getopt(argc, argv, pOpts_str);
+
+ if (s == -1)
+ {
+ break;
+ }
+
+ switch (s)
+ {
+ case 'i':
+ if (*mode)
+ {
+ break;
+ }
+
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: i");
+ *mode = INSTALLER_MODE_INSTALL;
+ if (optarg[0] == 'v')
+ {
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: v");
+ *output = true;
+ strncpy(buf, argv[optind++], BUFSIZE);
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: buf = [%s]", buf);
+ }
+ else
+ {
+ strncpy(buf, optarg, BUFSIZE);
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: optarg = [%s]", optarg);
+ }
+ break;
+
+ case 'u':
+ if (*mode)
+ {
+ break;
+ }
+
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: u");
+ *mode = INSTALLER_MODE_UNINSTALL;
+ if (optarg[0] == 'v')
+ {
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: v");
+ *output = true;
+ strncpy(buf, argv[optind++], BUFSIZE);
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: buf = [%s]", buf);
+ }
+ else
+ {
+ strncpy(buf, optarg, BUFSIZE);
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: optarg = [%s]", optarg);
+ }
+ break;
+
+ case 'r':
+ if (*mode)
+ {
+ break;
+ }
+
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: r");
+ *mode = INSTALLER_MODE_RECURSIVE_DIRECTORY_INSTALL;
+ strncpy(buf, optarg, BUFSIZE);
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: optarg = [%s]", optarg);
+ break;
+
+ case 'v':
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: v");
+ *output = true;
+ AppLogTag(OSP_INSTALLER, "__osp_installer_parse_options: optarg = [%s]", optarg);
+ break;
+
+ default:
+ fprintf(stderr, "Invalid option\n");
+ exit(-1);
+ break;
+ }
+ }
+
+ if (mode == 0)
+ {
+ fprintf(stderr, "Invalid mode\n");
+ exit(-1);
+ }
+
+ return 0;
+}
+
+bool
+InstallerManager::RemoveGarbage(const char* pDirectory)
+{
+ char pkgname[1024] = {0};
+
+ if (pDirectory == null)
+ {
+ return false;
+ }
+
+ char* pStart = strrchr(const_cast<char*>(pDirectory), '/');
+ if (pStart == null)
+ {
+ return false;
+ }
+
+ strcpy(pkgname, pStart + 1);
+ AppLogTag(OSP_INSTALLER, "pkgname = %s", pkgname);
+
+ AppLogTag(OSP_INSTALLER, "Remove Directory=(%s)", pDirectory);
+ InstallerUtil::Remove(pDirectory);
+
+ return true;
+}
+
+int
+InstallerManager::ReqeustByTest(void)
+{
+ int errorType = 0;
+ String appId;
+ Osp::Io::File file;
+ Osp::Io::FileAttributes attr;
+ result r = E_SUCCESS;
+ char readBuf[512] = {0};
+
+ r = File::GetAttributes(L"/opt/apps/org.tizen.cmtamb4mtv/data/configuration", attr);
+ TryCatch(!IsFailed(r), errorType = INSTALLER_ERROR_INVALID_PACKAGE, "[osp-installer] file not found");
+
+ r = file.Construct(L"/opt/apps/org.tizen.cmtamb4mtv/data/configuration", L"r");
+ TryCatch(!IsFailed(r), errorType = INSTALLER_ERROR_INVALID_PACKAGE, "[osp-installer] file.Construct failed");
+
+ if (file.Read(readBuf, sizeof(readBuf)-1) > 1)
+ {
+ String path;
+ path.Format(1024, L"%s", &readBuf[1]);
+
+ if (readBuf[0] == '+')
+ {
+ errorType = Request(path, INSTALLER_OPERATION_INSTALL, REQUESTER_TYPE_NORMAL, appId, errorType);
+ }
+ else if (readBuf[0] == '-')
+ {
+ errorType = Request(path, INSTALLER_OPERATION_UNINSTALL, REQUESTER_TYPE_NORMAL, appId, errorType);
+ }
+ else if (readBuf[0] == '*')
+ {
+ errorType = RequestRecursiveDirectory(path, errorType);
+ }
+ }
+
+CATCH:
+ return errorType;
+}
+
+void
+InstallerManager::DisplayPackageInfo(const char* appId)
+{
+ _PackageInfoImpl* pPackageInfoImpl = null;
+ ArrayList* pAppList = null;
+ int totalCount = 0;
+
+ pPackageInfoImpl = new (std::nothrow) _PackageInfoImpl;
+ if (pPackageInfoImpl == null)
+ {
+ return;
+ }
+
+ pPackageInfoImpl->Construct(appId);
+
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "PackageInfo");
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "# id = [%S]", pPackageInfoImpl->GetAppId().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# version = [%S]", pPackageInfoImpl->GetAppVersion().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# secret = [%S]", pPackageInfoImpl->GetAppSecret().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# name = [%S]", pPackageInfoImpl->GetAppName().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# vendor = [%S]", pPackageInfoImpl->GetAppVendor().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# description = [%S]", pPackageInfoImpl->GetAppDescription().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# mimeType = [%S]", pPackageInfoImpl->GetAppMimeType().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# api version = [%S]", pPackageInfoImpl->GetAppApiVersion().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# uri = [%S]", pPackageInfoImpl->GetAppUrl().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# cid = [%S]", pPackageInfoImpl->GetAppCid().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# parentId = [%S]", pPackageInfoImpl->GetAppParentId().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# installationDate = [%S]", pPackageInfoImpl->GetAppInstallationTime().ToString().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# rootpath = [%S]", pPackageInfoImpl->GetAppRootPath().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# readOnlySize = [%d]", pPackageInfoImpl->GetAppReadOnlySize());
+ AppLogTag(OSP_INSTALLER, "# dataSize = [%d]", pPackageInfoImpl->GetAppDataSize());
+ AppLogTag(OSP_INSTALLER, "# storageType = [%d]", pPackageInfoImpl->GetAppStorageType());
+ AppLogTag(OSP_INSTALLER, "# state = [%d]", pPackageInfoImpl->GetAppState());
+ AppLogTag(OSP_INSTALLER, "# initiator = [%d]", pPackageInfoImpl->GetAppInitiatior());
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+
+ pAppList = pPackageInfoImpl->GetAppInfoListN();
+ if (pAppList == null)
+ {
+ delete pPackageInfoImpl;
+ return;
+ }
+
+ totalCount = pAppList->GetCount();
+
+ for (int i = 0; i < totalCount; i++)
+ {
+ _PackageAppInfoImpl* pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
+
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "AppInfo(%d/%d)", i+1, totalCount);
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "# default = [%S]", pAppInfoImpl->GetDefault().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# appname = [%S]", pAppInfoImpl->GetName().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# packagename = [%S]", pAppInfoImpl->GetPackageName().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# mainmenu icon = [%S]", pAppInfoImpl->GetMainmenuIcon().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# setting icon = [%S]", pAppInfoImpl->GetSettingIcon().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# ticker icon = [%S]", pAppInfoImpl->GetTickerIcon().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# quickpanel icon = [%S]", pAppInfoImpl->GetQuickpanelIcon().GetPointer());
+ AppLogTag(OSP_INSTALLER, "# launchImage icon = [%S]", pAppInfoImpl->GetLaunchImageIcon().GetPointer());
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ }
+
+ pAppList->RemoveAll();
+ delete pAppList;
+ pAppList = null;
+
+ delete pPackageInfoImpl;
+}
+
+
diff --git a/src/Manager/InstallerManager.h b/src/Manager/InstallerManager.h
new file mode 100755
index 0000000..2b583bb
--- /dev/null
+++ b/src/Manager/InstallerManager.h
@@ -0,0 +1,86 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file InstallerManager.h
+ * @brief This is the header file for the %InstallerManager class.
+ *
+ * This header file contains the declarations of the %InstallerManager class.
+ */
+#ifndef _INSTALLER_MANAGER_H_
+#define _INSTALLER_MANAGER_H_
+
+#include "InstallationContext.h"
+#include "Installer.h"
+
+/**
+ * @class InstallerManager
+ * @brief This class represents the class of InstallerManager.
+ * @since 1.0
+ *
+ * This class represents the class of InstallerManager.
+ *
+ */
+class InstallerManager
+{
+public:
+ InstallerManager(void);
+ InstallerError Construct(const Osp::Base::String& path, InstallerType installerType, InstallerOperation op, RequesterType requesterType);
+ virtual ~InstallerManager(void);
+
+ static InstallerManager* GetInstance(void);
+ void Release(void);
+
+ int Request(const Osp::Base::String& path, InstallerOperation op, RequesterType requesterType, Osp::Base::String& appid, int& errorType);
+ int RequestRecursiveDirectory(const Osp::Base::String& path, int& errorType);
+
+ bool RemoveGarbage(const char* pDirectory);
+
+ int RequestByCommand(int argc, char **argv);
+ int ReqeustByTest(void);
+
+ void DisplayPackageInfo(const char* appId);
+
+private:
+ InstallerManager(const InstallerManager& value);
+ InstallerManager& operator =(const InstallerManager& source);
+
+ InstallationStep GetNext(void);
+
+ InstallerError Init(void);
+ InstallerError Register(void);
+ InstallerError End(void);
+
+ InstallerError Error(void);
+ InstallerError Rollback(void);
+ InstallerError UserCancel(void);
+
+ InstallerError Activate(void);
+ InstallerError Progress(void);
+
+ Installer* CreateInstaller(InstallerType installerType);
+ InstallationContext* GetContext(void);
+
+ int ParseCommandArg(int argc, char **argv, int *mode, char *buf, bool *output);
+
+private:
+ static InstallerManager* __pInstallerManager;
+ InstallationContext* __pContext;
+ Installer* __pInstaller;
+
+}; // InstallerManager
+
+#endif //_INSTALLER_MANAGER_H_
diff --git a/src/Manager/PermissionManager.cpp b/src/Manager/PermissionManager.cpp
new file mode 100755
index 0000000..c6728ea
--- /dev/null
+++ b/src/Manager/PermissionManager.cpp
@@ -0,0 +1,504 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file PermissionManager.cpp
+ * @brief This is the implementation file for %PermissionManager class.
+ */
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <FBaseUtilStringUtil.h>
+#include <FIoFile.h>
+#include <FIoDirectory.h>
+#include <FBase_StringConverter.h>
+#include <FIo_FileImpl.h>
+#include <FApp_PackageManagerImpl.h>
+#include <FApp_PackageInfoImpl.h>
+#include <FApp_AppInfoImpl.h>
+
+#include "PermissionManager.h"
+#include "InstallerUtil.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::Base::Utility;
+using namespace Osp::Io;
+using namespace Osp::App;
+
+PermissionManager::PermissionManager(void)
+{
+}
+
+PermissionManager::~PermissionManager(void)
+{
+}
+
+bool
+PermissionManager::ChangeOwner(const Osp::Base::String& filePath)
+{
+ int res = -1;
+ char* pFilePath = null;
+
+ pFilePath = _StringConverter::CopyToCharArrayN(filePath);
+ TryReturn(pFilePath, false, "[osp-installer] pFilePath is null");
+
+ res = chown(pFilePath, APP_OWNER_ID, APP_GROUP_ID);
+ if (res != 0)
+ {
+ AppLogTag(OSP_INSTALLER, "Fail to change owner[%s], res=[%d]", pFilePath, res);
+ }
+
+ delete[] pFilePath;
+
+ return true;
+}
+
+bool
+PermissionManager::ChangeHomeDirectoryOwner(const String& rootPath, int depth)
+{
+ Directory* pDir = null;
+ DirEnumerator* pDirEnum = null;
+ result r = E_SUCCESS;
+ result res = false;
+
+ pDir = new Directory; // Allocate %Directory instance
+ TryCatch(pDir, res = false, "[osp-installer] pDir is null");
+
+ r = pDir->Construct(rootPath);
+ TryCatch(!IsFailed(r), res = false, "[osp-installer] pDir->Construct() failed, rootPath=[%ls]", rootPath.GetPointer());
+
+ pDirEnum = pDir->ReadN();
+ TryCatch(pDirEnum, res = false, "[osp-installer] pDirEnum is null");
+
+ while (pDirEnum->MoveNext() == E_SUCCESS)
+ {
+ DirEntry entry = pDirEnum->GetCurrentDirEntry();
+
+ String entryName = entry.GetName();
+ String entryDir = rootPath;
+ entryDir += L"/";
+ entryDir += entryName;
+
+ if (entryName == L".")
+ {
+ ChangeOwner(entryDir);
+ ChangeMode(entryDir, S_IRUSR | S_IWUSR | S_IXUSR);
+ continue;
+ }
+ else if (entryName == L"..")
+ {
+ // if (depth != 0)
+ // {
+ // ChangeOwner(entryDir);
+ // }
+
+ continue;
+ }
+
+ if (entry.IsDirectory() == false)
+ {
+ ChangeOwner(entryDir);
+ ChangeMode(entryDir, S_IRUSR | S_IWUSR | S_IXUSR);
+ }
+ else
+ {
+ ChangeHomeDirectoryOwner(entryDir, depth+1);
+ ChangeMode(entryDir, S_IRUSR | S_IWUSR | S_IXUSR);
+ }
+ }
+
+ delete pDir;
+ pDir = null;
+ return true;
+
+CATCH:
+ delete pDir;
+ return false;
+}
+
+
+bool
+PermissionManager::ApplyHomeDirectoryPolicy(const String& rootPath)
+{
+ String dataPath;
+ //char* pDataPath = null;
+ //int res = -1;
+
+ dataPath = rootPath;
+ dataPath += DIR_DATA;
+
+ AppLogTag(OSP_INSTALLER, "ApplyHomeDirectoryPolicy [%ls]", dataPath.GetPointer());
+
+ if (File::IsFileExist(dataPath) == false)
+ {
+ result r = E_SUCCESS;
+ r = Directory::Create(dataPath, false);
+ TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Directory::Create() failed");
+ }
+// else
+// {
+// if (File::IsFileExist(dataPath) == true)
+// {
+// AppLogTag(OSP_INSTALLER, "ApplyHomeDirectoryPolicy [%ls] is removed.", dataPath.GetPointer());
+// pDataPath = _StringConverter::CopyToCharArrayN(dataPath);
+// remove(pDataPath);
+// delete[] pDataPath;
+// pDataPath = null;
+// }
+// }
+
+ ChangeHomeDirectoryOwner(dataPath, 0);
+ ChangeMode(dataPath, S_IRUSR | S_IWUSR | S_IXUSR);
+
+ return true;
+}
+
+bool
+PermissionManager::ChangeMode(const String& filePath, int mode)
+{
+ int res = -1;
+ char* pFilePath = null;
+
+ pFilePath = _StringConverter::CopyToCharArrayN(filePath);
+ TryReturn(pFilePath, false, "[osp-installer] pFilePath is null");
+
+ res = chmod(pFilePath, mode);
+ if (res != 0)
+ {
+ AppLogTag(OSP_INSTALLER, "Fail to change mode, path=[%s], mode=[%o], res=[%d]", pFilePath, mode, res);
+ }
+
+ delete[] pFilePath;
+
+ return true;
+}
+
+bool
+PermissionManager::SetDirectory(InstallationContext* pContext)
+{
+ char destPath[772] = {0};
+ int res = -1;
+ int err = 0;
+ String appRootPath;
+ _PackageInfoImpl *pPackageInfoImpl = null;
+ FileAttributes attribute;
+ result r = E_SUCCESS;
+
+ pPackageInfoImpl = pContext->GetPackageInfoImpl();
+ appRootPath = pPackageInfoImpl->GetAppRootPath();
+
+ // set permission(755) to default folders(AppRootPath)
+ sprintf(destPath, "%ls", appRootPath.GetPointer());
+ r = File::GetAttributes(destPath, attribute);
+ if (r == E_SUCCESS)
+ {
+ res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ if (res != 0)
+ {
+ AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=[%d].\n", destPath, res);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
+ }
+ }
+
+ // set permission(755) to default folders(BIN, INFO, DATA, RES)
+ sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_BIN);
+ r = File::GetAttributes(destPath, attribute);
+ if (r == E_SUCCESS)
+ {
+ res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ if (res)
+ {
+ AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
+ }
+ }
+
+ sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_INFO);
+ r = File::GetAttributes(destPath, attribute);
+ if (r == E_SUCCESS)
+ {
+ res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ if (res != 0)
+ {
+ AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
+ }
+ }
+
+ sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_RES);
+ r = File::GetAttributes(destPath, attribute);
+ if (r == E_SUCCESS)
+ {
+ ChangeHomeDirectoryOwner(destPath, 0);
+ ChangeMode(destPath, S_IRUSR | S_IXUSR);
+ }
+
+ sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_DATA);
+ r = File::GetAttributes(destPath, attribute);
+ if (r == E_SUCCESS)
+ {
+ res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ if (res != 0)
+ {
+ AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
+ }
+ }
+
+ sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_LIB);
+ r = File::GetAttributes(destPath, attribute);
+ if (r == E_SUCCESS)
+ {
+ res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ if (res != 0)
+ {
+ AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
+ }
+ }
+
+ sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_ICONS);
+ r = File::GetAttributes(destPath, attribute);
+ if (r == E_SUCCESS)
+ {
+ ChangeHomeDirectoryOwner(destPath, 0);
+ ChangeMode(destPath, S_IRUSR | S_IWUSR | S_IXUSR);
+ }
+
+ sprintf(destPath, "%ls%ls", appRootPath.GetPointer(), DIR_SETTING);
+ r = File::GetAttributes(destPath, attribute);
+ if (r == E_SUCCESS)
+ {
+ String appVersion = pPackageInfoImpl->GetAppVersion();
+ char src[772] = {0};
+ char dest[772] = {0};
+
+ sprintf(src, "%s/%s.%ls.%s", destPath, "setting", appVersion.GetPointer(), "xml");
+ sprintf(dest, "%s/%s", destPath, "setting.xml");
+
+ unlink(dest);
+
+ if (File::IsFileExist(src) == true)
+ {
+ err = symlink(src, dest);
+ AppLogTag(OSP_INSTALLER, "[%s]->[%s]\n", dest, src);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "[%s] is not existed.\n", src);
+ }
+
+ ChangeHomeDirectoryOwner(destPath, 0);
+ ChangeMode(destPath, S_IRUSR | S_IWUSR | S_IXUSR);
+ }
+
+ ApplyHomeDirectoryPolicy(appRootPath);
+
+ String packageId = pContext->GetAppId();
+ String apiVersion = pPackageInfoImpl->GetAppApiVersion();
+ AppLogTag(OSP_INSTALLER, "Osp::Io > installed path: %ls, packageId: %ls, API version: %ls",
+ appRootPath.GetPointer(), packageId.GetPointer(), apiVersion.GetPointer());
+
+ if (apiVersion.CompareTo(L"3.0") < 0)
+ {
+ AppLogTag(OSP_INSTALLER, "Osp::Io > API version <= 2.0");
+
+ if (_FileImpl::PrepareDataCaging(appRootPath, packageId) == false)
+ {
+ AppLogTag(OSP_INSTALLER, "Osp::Io > _FileImpl::PrepareDataCaging() failed");
+ return false;
+ }
+
+ SetSymLink(pContext);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "Osp::Io > API version >= 3.0");
+
+ if (_FileImpl::CreateOspApplicationDirectories(appRootPath, packageId) == false)
+ {
+ AppLogTag(OSP_INSTALLER, "Osp::Io > _FileImpl::CreateOspApplicationDirectories() failed.");
+ return false;
+ }
+ }
+
+ CreateSystemDirectory(pContext, appRootPath);
+
+ return true;
+}
+
+bool
+PermissionManager::SetFile(InstallationContext* pContext)
+{
+ char destPath[772] = {0};
+ int res = -1;
+
+ _PackageInfoImpl *pPackageInfoImpl = null;
+ _PackageAppInfoImpl* pAppInfoImpl = null;
+ ArrayList* pAppList = null;
+
+ pPackageInfoImpl = pContext->GetPackageInfoImpl();
+ TryReturn(pPackageInfoImpl, false, "[osp-installer] pPackageInfoImpl is null.");
+
+ String appRootPath;
+ appRootPath = pPackageInfoImpl->GetAppRootPath();
+
+ pAppList = pPackageInfoImpl->GetAppInfoList();
+ for (int i = 0 ; i < pAppList->GetCount(); i++)
+ {
+ pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
+ if (pAppInfoImpl)
+ {
+ // set permission(755) to bin file.
+ sprintf(destPath, "%ls%ls/%ls", appRootPath.GetPointer(), DIR_BIN, (pAppInfoImpl->GetName()).GetPointer());
+ strcat(destPath, ".exe");
+ res = chmod(destPath, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ if (res != 0)
+ {
+ AppLogTag(OSP_INSTALLER, "Fail to set permission(755)[%s], res=%d.\n", destPath, res);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "Success to set permission(755)[%s], res=%d.\n", destPath, res);
+ }
+ }
+ }
+
+ return true;
+}
+
+bool
+PermissionManager::CreateSystemDirectory(InstallationContext* pContext, const Osp::Base::String& rootpath)
+{
+ _PackageInfoImpl *pPackageInfoImpl = null;
+ _PackageAppInfoImpl* pAppInfoImpl = null;
+ ArrayList* pAppList = null;
+ int err = 0;
+
+ pPackageInfoImpl = pContext->GetPackageInfoImpl();
+ TryReturn(pPackageInfoImpl, false, "[osp-installer] pPackageInfoImpl is null.");
+
+ pAppList = pPackageInfoImpl->GetAppInfoList();
+
+ for (int i = 0 ; i < pAppList->GetCount(); i++)
+ {
+ pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
+ if (pAppInfoImpl)
+ {
+ result r = E_SUCCESS;
+ String packageName = pAppInfoImpl->GetPackageName();
+ String destPath;
+ String appRootPath;
+ appRootPath = pPackageInfoImpl->GetAppRootPath();
+ char src[772] = {0};
+ char dest[772] = {0};
+
+ destPath.Format(1024, L"%ls/%ls", SLP_APP_PATH, packageName.GetPointer());
+
+ sprintf(src, "%ls", appRootPath.GetPointer());
+ sprintf(dest, "%ls", destPath.GetPointer());
+
+ unlink(dest);
+
+ FileAttributes attr;
+ r = File::GetAttributes(destPath, attr);
+ if (r == E_SUCCESS)
+ {
+ InstallerUtil::Remove(destPath);
+ AppLogTag(OSP_INSTALLER, "Directory is removed. [%ls]\n", destPath.GetPointer());
+ }
+
+ err = symlink(src, dest);
+ }
+ }
+
+ return true;
+}
+
+bool
+PermissionManager::SetSymLink(InstallationContext* pContext)
+{
+ char srcPath[772] = {0};
+ char destPath[772] = {0};
+ int err = 0;
+ String appRootPath;
+ _PackageInfoImpl *pPackageInfoImpl = null;
+
+ pPackageInfoImpl = pContext->GetPackageInfoImpl();
+ appRootPath = pPackageInfoImpl->GetAppRootPath();
+
+ sprintf(srcPath, "%ls%ls", appRootPath.GetPointer(), DIR_RES);
+ if (File::IsFileExist(srcPath) == true)
+ {
+ sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Res");
+ err = symlink("./res", destPath);
+ }
+
+ sprintf(srcPath, "%ls%ls", appRootPath.GetPointer(), DIR_DATA);
+ if (File::IsFileExist(srcPath) == true)
+ {
+ sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Home");
+ err = symlink("./data", destPath);
+ }
+
+ sprintf(srcPath, "%ls%s", appRootPath.GetPointer(), "/res/screen-size-normal");
+ if (File::IsFileExist(srcPath) == true)
+ {
+ sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Res/ScreenSize-Normal");
+ err = symlink(srcPath, destPath);
+ }
+
+ sprintf(srcPath, "%ls%s", appRootPath.GetPointer(), "/res/screen-density-high");
+ if (File::IsFileExist(srcPath) == true)
+ {
+ sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Res/ScreenDensity-High");
+ err = symlink(srcPath, destPath);
+ }
+
+ sprintf(srcPath, "%ls%s", appRootPath.GetPointer(), "/res/screen-density-middle");
+ if (File::IsFileExist(srcPath) == true)
+ {
+ sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Res/ScreenDensity-Middle");
+ err = symlink(srcPath, destPath);
+ }
+
+ sprintf(srcPath, "%ls%s", appRootPath.GetPointer(), "/res/screen-density-low");
+ if (File::IsFileExist(srcPath) == true)
+ {
+ sprintf(destPath, "%ls%s", appRootPath.GetPointer(), "/Res/ScreenDensity-Low");
+ err = symlink(srcPath, destPath);
+ }
+
+ return true;
+}
diff --git a/src/Manager/PermissionManager.h b/src/Manager/PermissionManager.h
new file mode 100644
index 0000000..7bdd7a5
--- /dev/null
+++ b/src/Manager/PermissionManager.h
@@ -0,0 +1,56 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file PermissionManager.h
+ * @brief This is the header file for the %PermissionManager class.
+ *
+ * This header file contains the declarations of the %PermissionManager class. @n
+ */
+#ifndef _PERMISSION_MANAGER_H_
+#define _PERMISSION_MANAGER_H_
+
+#include "InstallationContext.h"
+
+/**
+ * @class PermissionManager
+ * @brief This class represents the class of PermissionManager.
+ * @since 1.0
+ *
+ * This class represents the class of PermissionManager.
+ *
+ */
+class PermissionManager
+{
+public:
+ PermissionManager(void);
+ virtual ~PermissionManager(void);
+
+ static bool SetDirectory(InstallationContext* pContext);
+ static bool SetFile(InstallationContext* pContext);
+
+private:
+ static bool ChangeOwner(const Osp::Base::String& filePath);
+ static bool ChangeHomeDirectoryOwner(const Osp::Base::String&, int depth);
+ static bool ApplyHomeDirectoryPolicy(const Osp::Base::String& rootpath);
+ static bool ChangeMode(const Osp::Base::String& filePath, int mode);
+ static bool CreateSystemDirectory(InstallationContext* pContext, const Osp::Base::String& rootpath);
+ static bool SetSymLink(InstallationContext* pContext);
+ static bool PrepareDataCaging(InstallationContext* pContext);
+
+}; // PermissionManager
+
+#endif // _PERMISSION_MANAGER_H_
diff --git a/src/Manager/SignatureManager.cpp b/src/Manager/SignatureManager.cpp
new file mode 100755
index 0000000..dec8ef6
--- /dev/null
+++ b/src/Manager/SignatureManager.cpp
@@ -0,0 +1,314 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file SignatureManager.cpp
+ * @brief This is the implementation file for %SignatureManager class.
+ */
+
+#include <FBase_StringConverter.h>
+
+#include "SignatureManager.h"
+
+using namespace Osp::Base;
+using namespace Osp::Security::Cert;
+using namespace Osp::Base::Collection;
+using namespace Osp::Base::Utility;
+
+SignatureManager::SignatureManager(void)
+:__pContext(null)
+,__pSignature(null)
+,__pAuthorCertPath(null)
+,__pDistributorCertPath(null)
+{
+}
+
+SignatureManager::~SignatureManager(void)
+{
+ delete __pSignature;
+ delete __pAuthorCertPath;
+ delete __pDistributorCertPath;
+}
+
+bool
+SignatureManager::Construct(InstallationContext* pContext)
+{
+ __pContext = pContext;
+
+ return true;
+}
+
+bool
+SignatureManager::SetSignature()
+{
+ TryReturn(__pContext, false, "[osp-installer] __pContext is null.");
+
+ bool ret = true;
+ char* pFilepath = _StringConverter::CopyToCharArrayN(__pContext->GetSignatureXmlPath());
+
+ __pSignature = new SignatureHandler;
+ TryCatch(__pSignature, ret = false, "[osp-installer] __pSignature is null");
+
+ ret = __pSignature->Construct(__pContext);
+ TryCatch(ret == true, ret = false, "[osp-installer] __pSignature->Construct is failed.");
+
+ ret = __pSignature->Parse(pFilepath);
+ if (ret == false)
+ {
+ AppLogTag(OSP_INSTALLER, "__pSignature->Parse is failed. [%s]\n", pFilepath);
+ }
+
+CATCH:
+ delete[] pFilepath;
+ return ret;
+}
+
+bool
+SignatureManager::AddCert(RootCertificateType certType)
+{
+ TryReturn(__pSignature, false, "[osp-installer] __pSignature is null.");
+
+ bool ret = true;
+
+ if (certType == ROOT_CERTIFICATE_DEVELOPER)
+ {
+ IList* pAuthorCertChain = __pSignature->GetAuthorCertChain();
+
+ if (pAuthorCertChain)
+ {
+ AppLogTag(OSP_INSTALLER, "AddCertificate - AuthorCertChain");
+
+ __pAuthorCertPath = new X509CertificatePath();
+ TryCatch(__pAuthorCertPath, ret = false, "[osp-installer] __pAuthorCertPath is null.");
+
+ ret = AddCertificate(__pAuthorCertPath, pAuthorCertChain);
+ TryCatch(ret == true, ret = false, "[osp-installer] AddCertificate(AuthorCert) is failed.");
+
+ ret = AddRootCertificate(__pAuthorCertPath, certType);
+ TryCatch(ret == true, ret = false, "[osp-installer] AddRootCertificate(AuthorCertPath) is failed.");
+ }
+ }
+ else
+ {
+ IList* pDistributorCertChain = __pSignature->GetDistributorCertChain();
+
+ if (pDistributorCertChain)
+ {
+ AppLogTag(OSP_INSTALLER, "AddCertificate - DistributorCert [%d]", certType);
+
+ __pDistributorCertPath = new X509CertificatePath();
+ TryCatch(__pDistributorCertPath, ret = false, "[osp-installer] __pDistributorCertPath is null.");
+
+ ret = AddCertificate(__pDistributorCertPath, pDistributorCertChain);
+ TryCatch(ret == true, ret = false, "[osp-installer] AddCertificate(DistributorCert) is failed.");
+
+ ret = AddRootCertificate(__pDistributorCertPath, certType);
+ TryCatch(ret == true, ret = false, "[osp-installer] AddRootCertificate(DistributorCert) is failed.");
+ }
+ }
+
+CATCH:
+ return ret;
+}
+
+bool
+SignatureManager::VerifyChain(RootCertificateType certType)
+{
+ bool ret = true;
+
+ if (certType == ROOT_CERTIFICATE_DEVELOPER)
+ {
+ if (__pAuthorCertPath)
+ {
+ AppLogTag(OSP_INSTALLER, "__pAuthorCertPath Validate [START]");
+ ret = Validate(__pAuthorCertPath);
+ AppLogTag(OSP_INSTALLER, "__pAuthorCertPath Validate [END]");
+ TryCatch(ret == true, ret = false, "[osp-installer] Validate(AuthorCert) is failed.");
+ }
+ }
+ else
+ {
+ if (__pDistributorCertPath)
+ {
+ AppLogTag(OSP_INSTALLER, "__pDistributorCertPath Validate [START][%d]", certType);
+ ret = Validate(__pDistributorCertPath);
+ AppLogTag(OSP_INSTALLER, "__pDistributorCertPath Validate [END]");
+ TryCatch(ret == true, ret = false, "[osp-installer] Validate(DistributorCert) is failed.");
+ }
+ }
+
+CATCH:
+ delete __pAuthorCertPath;
+ __pAuthorCertPath = null;
+ delete __pDistributorCertPath;
+ __pDistributorCertPath = null;
+
+ return ret;
+}
+
+bool
+SignatureManager::Validate(X509CertificatePath* pCertPath)
+{
+ TryReturn(pCertPath, false, "[osp-installer] pCertPath is null.");
+
+ AppLogTag(OSP_INSTALLER, "------------------------------");
+ AppLogTag(OSP_INSTALLER, "# signature.xml");
+ ValidationResult valResult = VALIDATION_SUCCESS;
+ valResult = pCertPath->Validate();
+
+ if (valResult != VALIDATION_SUCCESS)
+ {
+
+ AppLogTag(OSP_INSTALLER, "Validate() fail! - ValidationResult = [%d]", valResult);
+ AppLogTag(OSP_INSTALLER, "------------------------------");
+ return false;
+ }
+ else
+ {
+ int depth = pCertPath->GetLength();
+ if (depth == 0)
+ {
+ AppLogTag(OSP_INSTALLER, "depth = 0");
+ return false;
+ }
+
+ AppLogTag(OSP_INSTALLER, "Validate() success!");
+ AppLogTag(OSP_INSTALLER, "------------------------------");
+
+ ICertificate *pTrustCa = null;
+ pTrustCa = pCertPath->GetTrustAnchorN();
+ if (pTrustCa)
+ {
+ String subjectName;
+ subjectName = pTrustCa->GetSubject();
+ AppLogTag(OSP_INSTALLER, "TrustAnchor subjectName = [%ls]", subjectName.GetPointer());
+ }
+
+ delete pTrustCa;
+ }
+
+ return true;
+}
+
+bool
+SignatureManager::AddCertificate(X509CertificatePath* pCertPath, IList* pCertChain)
+{
+ TryReturn(pCertChain, false, "[osp-installer] pCertChain is null.");
+
+ bool ret = true;
+ X509Certificate* pCertificate = null;
+
+ for (int i = 0; i < pCertChain->GetCount(); i++)
+ {
+ Osp::Base::ByteBuffer* pByteBuffer = dynamic_cast <ByteBuffer*>(pCertChain->GetAt(i));
+
+ if (pByteBuffer)
+ {
+ AppLogTag(OSP_INSTALLER, "[cert][%d]", i);
+
+ result r = E_SUCCESS;
+
+ pCertificate = new X509Certificate;
+ TryCatch(pCertificate, ret = false, "[osp-installer] pCertificate is null.");
+
+ r = pCertificate->Construct(*pByteBuffer);
+ TryCatch(!IsFailed(r), ret = false, "[osp-installer] pCertificate->Construct() is failed.");
+
+ r = pCertPath->AddCertificate(*pCertificate);
+ TryCatch(!IsFailed(r), ret = false, "[osp-installer] AddCertificate is failed.");
+
+ delete pCertificate;
+ pCertificate = null;
+ }
+ }
+
+CATCH:
+ delete pCertificate;
+ return ret;
+}
+
+bool
+SignatureManager::AddRootCertificate(X509CertificatePath* pCertPath, RootCertificateType certType)
+{
+ TryReturn(pCertPath, false, "[osp-installer] pCertPath is null.");
+
+ bool ret = true;
+ result r = E_SUCCESS;
+ ByteBuffer byteBuffer;
+ X509Certificate rootCert;
+ int length = 0;
+ const char* pRootCert = null;
+
+ if (certType == ROOT_CERTIFICATE_NORMAL)
+ {
+ pRootCert = "MIIBsjCCAVwCCQD5jiS4Q6a7qDANBgkqhkiG9w0BAQUFADBgMRYwFAYDVQQKDA1U"
+ "aXplbiBUZXN0IENBMSIwIAYDVQQLDBlUaXplbiBEaXN0cmlidXRvciBUZXN0IENB"
+ "MSIwIAYDVQQDDBlUaXplbiBEaXN0cmlidXRvciBSb290IENBMB4XDTEyMDgyOTA4"
+ "Mjc1NFoXDTIyMDgyNzA4Mjc1NFowYDEWMBQGA1UECgwNVGl6ZW4gVGVzdCBDQTEi"
+ "MCAGA1UECwwZVGl6ZW4gRGlzdHJpYnV0b3IgVGVzdCBDQTEiMCAGA1UEAwwZVGl6"
+ "ZW4gRGlzdHJpYnV0b3IgUm9vdCBDQTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCr"
+ "rnWCo3PuzKK/K16AglIFCSrwDLTM09i8SRvDDwJ1edF1qbwVM98otkFNzABc6TY2"
+ "C/25PCJN7czuEBgD4CBvAgMBAAEwDQYJKoZIhvcNAQEFBQADQQAQxnxvYGO/pTmB"
+ "FZc9EvxIGgoFy8EQGIvlY5RjknFnn4OmKDmBNdnchF1kJTaazxddW+MZVh5GWU40"
+ "/sHxMAY0";
+ }
+ else if (certType == ROOT_CERTIFICATE_PARTNER)
+ {
+ pRootCert = "MIIBwjCCAWwCCQDb4CukLXIwPDANBgkqhkiG9w0BAQUFADBoMRYwFAYDVQQKDA1U"
+ "aXplbiBUZXN0IENBMSIwIAYDVQQLDBlUaXplbiBEaXN0cmlidXRvciBUZXN0IENB"
+ "MSowKAYDVQQDDCFUaXplbiBQYXJ0bmVyIERpc3RyaWJ1dG9yIFJvb3QgQ0EwHhcN"
+ "MTIwOTAzMTA0NjExWhcNMjIwOTAxMTA0NjExWjBoMRYwFAYDVQQKDA1UaXplbiBU"
+ "ZXN0IENBMSIwIAYDVQQLDBlUaXplbiBEaXN0cmlidXRvciBUZXN0IENBMSowKAYD"
+ "VQQDDCFUaXplbiBQYXJ0bmVyIERpc3RyaWJ1dG9yIFJvb3QgQ0EwXDANBgkqhkiG"
+ "9w0BAQEFAANLADBIAkEA60SphdcNgCjT+kU/vrYl38u5JEMP4F7VqfBnb6SPNysn"
+ "O+AGwroauYXfPPmBcUIqu+BzfQE4ZITbPZrZG9yOowIDAQABMA0GCSqGSIb3DQEB"
+ "BQUAA0EA3biplInRqcYvhmWPyh06Db+QPYmDhk3RvJiCVdQyW4c5DGKHBM6+9t5r"
+ "ULlD7UoqK38PfVNJ6E/GEubQ5170GA==";
+ }
+ else if (certType == ROOT_CERTIFICATE_DEVELOPER)
+ {
+ pRootCert = "MIIBqjCCAVQCCQCVqUeH46cT3zANBgkqhkiG9w0BAQUFADBcMRYwFAYDVQQKDA1U"
+ "aXplbiBUZXN0IENBMSAwHgYDVQQLDBdUaXplbiBEZXZlbG9wZXIgVGVzdCBDQTEg"
+ "MB4GA1UEAwwXVGl6ZW4gRGV2ZWxvcGVyIFJvb3QgQ0EwHhcNMTIwODI5MDgxODEw"
+ "WhcNMjIwODI3MDgxODEwWjBcMRYwFAYDVQQKDA1UaXplbiBUZXN0IENBMSAwHgYD"
+ "VQQLDBdUaXplbiBEZXZlbG9wZXIgVGVzdCBDQTEgMB4GA1UEAwwXVGl6ZW4gRGV2"
+ "ZWxvcGVyIFJvb3QgQ0EwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAqLhBbLpcF/sQ"
+ "c9/v0pejQC+IG8z+KKmgQ5NXNKx7fEFN3Y7CVSNtyvGHek/4BaCmTV4e118FwiZ5"
+ "LPDbwLnfEwIDAQABMA0GCSqGSIb3DQEBBQUAA0EAUz2Oe9Jyql5iJIW2sa89Ic0T"
+ "YGvdzyc7Kb7CtHUly7ja4rtRN3+pVUxiFPiyR59oZbh39NZyFwxBHpIm6BJ37A==";
+ }
+ else
+ {
+ pRootCert = "NeedToAddCert";
+ }
+
+ length = strlen(pRootCert);
+ byteBuffer.Construct(length);
+
+ r = byteBuffer.SetArray((byte*)pRootCert, 0, length);
+ TryCatch(!IsFailed(r), ret = false, "[osp-installer] SetArray() is failed.");
+
+ byteBuffer.Flip();
+
+ r = rootCert.Construct(byteBuffer);
+ TryCatch(!IsFailed(r), ret = false, "[osp-installer] rootCert.Construct() is failed.");
+
+ r = pCertPath->AddCertificate(rootCert);
+ TryCatch(!IsFailed(r), ret = false, "[osp-installer] AddCertificate(rootCert) is failed.");
+
+CATCH:
+ return ret;
+}
diff --git a/src/Manager/SignatureManager.h b/src/Manager/SignatureManager.h
new file mode 100755
index 0000000..be036db
--- /dev/null
+++ b/src/Manager/SignatureManager.h
@@ -0,0 +1,69 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file SignatureManager.h
+ * @brief This is the header file for the %SignatureManager class.
+ *
+ * This header file contains the declarations of the %SignatureManager class.
+ */
+#ifndef _SIGNATURE_MANAGER_H_
+#define _SIGNATURE_MANAGER_H_
+
+#include <FSecCertX509CertificatePath.h>
+
+#include "InstallationContext.h"
+#include "SignatureHandler.h"
+
+/**
+ * @class SignatureManager
+ * @brief This class represents the class of SignatureManager.
+ * @since 1.0
+ *
+ * This class represents the class of SignatureManager.
+ *
+ */
+
+class SignatureManager
+{
+public:
+ SignatureManager(void);
+ virtual ~SignatureManager(void);
+
+ bool Construct(InstallationContext *pConext);
+ bool SetSignature();
+ bool AddCert(RootCertificateType certType);
+ bool VerifyChain(RootCertificateType certType);
+ //bool VerifySignature();
+
+private:
+ SignatureManager(const SignatureManager& value);
+ SignatureManager& operator =(const SignatureManager& source);
+
+ bool Validate(Osp::Security::Cert::X509CertificatePath* pCertPath);
+ bool AddCertificate(Osp::Security::Cert::X509CertificatePath* pCertPath, Osp::Base::Collection::IList* pCertChain);
+ bool AddRootCertificate(Osp::Security::Cert::X509CertificatePath* pCertPath, RootCertificateType certType);
+
+private:
+ InstallationContext* __pContext;
+ SignatureHandler* __pSignature;
+ Osp::Security::Cert::X509CertificatePath* __pAuthorCertPath;
+ Osp::Security::Cert::X509CertificatePath* __pDistributorCertPath;
+
+
+}; // SignatureManager
+
+#endif // _SIGNATURE_MANAGER_H_
diff --git a/src/Step/DrmStep.cpp b/src/Step/DrmStep.cpp
new file mode 100755
index 0000000..7e2db6c
--- /dev/null
+++ b/src/Step/DrmStep.cpp
@@ -0,0 +1,161 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file DrmStep.cpp
+ * @brief This is the implementation file for %ApplicationXmlStep class.
+ */
+
+#include "InstallationContext.h"
+#include "DrmStep.h"
+
+DrmStep::DrmStep(void)
+:__state(STATE_DRM_CHECKING)
+,__pContext(null)
+{
+}
+
+DrmStep::~DrmStep(void)
+{
+}
+
+InstallerError
+DrmStep::Run(InstallationContext* pContext)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "DrmStep - START");
+
+ __pContext = pContext;
+
+ while (true)
+ {
+ switch (__state)
+ {
+ case STATE_DRM_CHECKING:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DRM_CHECKING");
+ error = OnDrmChecking();
+ break;
+
+ case STATE_DRM_PURCHASE_REQUEST:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DRM_PURCHASE_REQUEST");
+ error = OnPurchaseRequest();
+ break;
+
+ case STATE_DRM_LICENSE_REQUEST:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DRM_LICENSE_REQUEST");
+ error = OnLicenseRequest();
+ break;
+
+ case STATE_DRM_LICENSE_RESPONSE:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DRM_LICENSE_RESPONSE");
+ error = OnLicenseResponse();
+ break;
+
+ case STATE_DRM_DECRYPT:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DRM_DECRYPT");
+ error = OnDecryptPackage();
+ break;
+
+ case STATE_DONE:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DONE");
+ error = OnStateDone();
+ break;
+
+ default:
+ break;
+ }
+
+ if (error != INSTALLER_ERROR_NONE)
+ {
+ fprintf(stderr, "DrmStep::Run - ErrorType [%d]\n", error);
+ break;
+ }
+
+ if (__state > STATE_DONE)
+ {
+ AppLogTag(OSP_INSTALLER, "DrmStep - END");
+ break;
+ }
+ }
+
+ return error;
+}
+
+void
+DrmStep::GoNextState(void)
+{
+ __state++;
+}
+
+InstallerError
+DrmStep::OnDrmChecking(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "DrmStep::OnDrmChecking()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+DrmStep::OnPurchaseRequest(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "DrmStep::OnPurchaseRequest()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+DrmStep::OnLicenseRequest(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "DrmStep::OnLicenseRequest()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+DrmStep::OnLicenseResponse(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "DrmStep::OnLicenseResponse()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+DrmStep::OnDecryptPackage(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "DrmStep::OnDecryptPackage()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+DrmStep::OnStateDone(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "DrmStep::OnStateDone()");
+
+ GoNextState();
+ return error;
+}
diff --git a/src/Step/DrmStep.h b/src/Step/DrmStep.h
new file mode 100644
index 0000000..0de8124
--- /dev/null
+++ b/src/Step/DrmStep.h
@@ -0,0 +1,70 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file DrmStep.h
+ * @brief This is the header file for the %DrmStep class.
+ *
+ * This header file contains the declarations of the %DrmStep class.
+ */
+#ifndef _DRM_STEP_H_
+#define _DRM_STEP_H_
+
+#include "IInstallationStep.h"
+
+/**
+ * @class DrmStep
+ * @brief This class represents the class of DrmStep.
+ * @since 1.0
+ *
+ * This class represents the class of DrmStep.
+ *
+ */
+class DrmStep
+ : public IInstallationStep
+{
+public:
+ DrmStep(void);
+ virtual ~DrmStep(void);
+
+ virtual InstallerError Run(InstallationContext* pContext);
+
+private:
+ enum
+ {
+ STATE_DRM_CHECKING,
+ STATE_DRM_PURCHASE_REQUEST,
+ STATE_DRM_LICENSE_REQUEST,
+ STATE_DRM_LICENSE_RESPONSE,
+ STATE_DRM_DECRYPT,
+ STATE_DONE
+ };
+
+ void GoNextState(void);
+ InstallerError OnDrmChecking(void);
+ InstallerError OnPurchaseRequest(void);
+ InstallerError OnLicenseRequest(void);
+ InstallerError OnLicenseResponse(void);
+ InstallerError OnDecryptPackage(void);
+ InstallerError OnStateDone(void);
+
+private:
+ int __state;
+ InstallationContext* __pContext;
+
+}; // DrmStep
+
+#endif //_DRM_STEP_H_
diff --git a/src/Step/IInstallationStep.cpp b/src/Step/IInstallationStep.cpp
new file mode 100644
index 0000000..e101bfb
--- /dev/null
+++ b/src/Step/IInstallationStep.cpp
@@ -0,0 +1,30 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file IInstallationStep.cpp
+ * @brief This is the implementation file for %IInstallationStep class.
+ */
+
+#include "IInstallationStep.h"
+
+IInstallationStep::IInstallationStep(void)
+{
+}
+
+IInstallationStep::~IInstallationStep(void)
+{
+}
diff --git a/src/Step/IInstallationStep.h b/src/Step/IInstallationStep.h
new file mode 100644
index 0000000..a90dd82
--- /dev/null
+++ b/src/Step/IInstallationStep.h
@@ -0,0 +1,49 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file IInstallationStep.h
+ * @brief This is the header file for the %IInstallationStep class.
+ *
+ * This header file contains the declarations of the %IInstallationStep class.
+ */
+#ifndef _IINSTALLATION_STEP_H_
+#define _IINSTALLATION_STEP_H_
+
+#include "InstallerDefs.h"
+
+class InstallationContext;
+
+/**
+ * @class IInstallationStep
+ * @brief This class represents the class of IInstallationStep.
+ * @since 1.0
+ *
+ * This class represents the class of IInstallationStep.
+ *
+ */
+
+class IInstallationStep
+{
+public:
+ IInstallationStep(void);
+ virtual ~IInstallationStep(void);
+
+ virtual InstallerError Run(InstallationContext* pContext) = 0;
+
+}; // IInstallationStep
+
+#endif // _IINSTALLATION_STEP_H_
diff --git a/src/Step/LicenseStep.cpp b/src/Step/LicenseStep.cpp
new file mode 100755
index 0000000..a1a55d1
--- /dev/null
+++ b/src/Step/LicenseStep.cpp
@@ -0,0 +1,101 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file LicenseStep.cpp
+ * @brief This is the implementation file for %LicenseStep class.
+ */
+
+#include "InstallationContext.h"
+#include "LicenseStep.h"
+
+LicenseStep::LicenseStep(void)
+:__state(STATE_LICENSE_VERIFICATION)
+,__pContext(null)
+{
+}
+
+LicenseStep::~LicenseStep(void)
+{
+}
+
+InstallerError
+LicenseStep::Run(InstallationContext* pContext)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "LicenseStep - START");
+
+ __pContext = pContext;
+
+ while (true)
+ {
+ switch (__state)
+ {
+ case STATE_LICENSE_VERIFICATION:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_LICENSE_VERIFICATION");
+ error = OnStateLicenseVerification();
+ break;
+
+ case STATE_DONE:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DONE");
+ error = OnStateDone();
+ break;
+
+ default:
+ break;
+ }
+
+ if (error != INSTALLER_ERROR_NONE)
+ {
+ fprintf(stderr, "LicenseStep::Run - ErrorType [%d]\n", error);
+ break;
+ }
+
+ if (__state > STATE_DONE)
+ {
+ AppLogTag(OSP_INSTALLER, "LicenseStep - END");
+ break;
+ }
+ }
+
+ return error;
+}
+
+void
+LicenseStep::GoNextState(void)
+{
+ __state++;
+}
+
+InstallerError
+LicenseStep::OnStateLicenseVerification(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "LicenseStep::OnStateLicenseVerification()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+LicenseStep::OnStateDone(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "LicenseStep::OnStateDone()");
+
+ GoNextState();
+ return error;
+}
diff --git a/src/Step/LicenseStep.h b/src/Step/LicenseStep.h
new file mode 100644
index 0000000..0bb1ee4
--- /dev/null
+++ b/src/Step/LicenseStep.h
@@ -0,0 +1,62 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file LicenseStep.h
+ * @brief This is the header file for the %LicenseStep class.
+ *
+ * This header file contains the declarations of the %LicenseStep class.
+ */
+#ifndef _LICENSE_STEP_H_
+#define _LICENSE_STEP_H_
+
+#include "IInstallationStep.h"
+
+/**
+ * @class LicenseStep
+ * @brief This class represents the class of LicenseStep.
+ * @since 1.0
+ *
+ * This class represents the class of LicenseStep.
+ *
+ */
+class LicenseStep
+ : public IInstallationStep
+{
+public:
+ LicenseStep(void);
+ virtual ~LicenseStep(void);
+
+ virtual InstallerError Run(InstallationContext* pContext);
+
+private:
+ enum
+ {
+ STATE_LICENSE_VERIFICATION,
+ STATE_DONE
+ };
+
+ void GoNextState(void);
+ InstallerError OnStateLicenseVerification(void);
+ InstallerError OnStateDone(void);
+
+private:
+ int __state;
+ InstallationContext* __pContext;
+
+}; // LicenseStep
+
+#endif //_LICENSE_STEP_H_
diff --git a/src/Step/ManifestXmlStep.cpp b/src/Step/ManifestXmlStep.cpp
new file mode 100755
index 0000000..3737437
--- /dev/null
+++ b/src/Step/ManifestXmlStep.cpp
@@ -0,0 +1,175 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file ManifestStep.cpp
+ * @brief This is the implementation file for %ManifestStep class.
+ */
+
+#include <FIoFile.h>
+
+#include <FBase_StringConverter.h>
+#include <FApp_PackageInfoImpl.h>
+
+#include "InstallationContext.h"
+#include "ManifestHandler.h"
+#include "ManifestXmlStep.h"
+
+using namespace Osp::Base;
+using namespace Osp::App;
+using namespace Osp::Io;
+
+ManifestXmlStep::ManifestXmlStep(void)
+:__state(STATE_MANIFEST_XML)
+,__pContext(null)
+{
+}
+
+ManifestXmlStep::~ManifestXmlStep(void)
+{
+}
+
+InstallerError
+ManifestXmlStep::Run(InstallationContext* pContext)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "ManifestXmlStep - START");
+
+ __pContext = pContext;
+
+ while (true)
+ {
+ switch (__state)
+ {
+ case STATE_MANIFEST_XML:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_MANIFEST");
+ error = OnStateManifestXml();
+ break;
+
+ case STATE_DONE:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DONE");
+ error = OnStateDone();
+ break;
+
+ default:
+ break;
+ }
+
+ if (error != INSTALLER_ERROR_NONE)
+ {
+ fprintf(stderr, "ManifestXmlStep::Run - ErrorType [%d]\n", error);
+ break;
+ }
+
+ if (__state > STATE_DONE)
+ {
+ AppLogTag(OSP_INSTALLER, "ManifestXmlStep- END");
+ break;
+ }
+ }
+
+ return error;
+}
+
+void
+ManifestXmlStep::GoNextState(void)
+{
+ __state++;
+}
+
+InstallerError
+ManifestXmlStep::OnStateManifestXml(void)
+{
+ AppLogTag(OSP_INSTALLER, "ManifestXmlStep::OnStateManifest()");
+
+ InstallerError error = INSTALLER_ERROR_NONE;
+ bool ret = false;
+ char *pFilepath = null;
+ _PackageInfoImpl *pPackageInfoImpl = null;
+ File file;
+ const int bufSize = 32*1024;
+ char *p = new char[bufSize];
+ memset(p, 0, sizeof(bufSize));
+ result r = E_SUCCESS;
+ int size = 0;
+
+ pFilepath = _StringConverter::CopyToCharArrayN(__pContext->GetManifestXmlPath());
+
+ r = file.Construct(__pContext->GetManifestXmlPath(), L"r");
+ if (r != E_SUCCESS)
+ {
+ fprintf(stderr, "OnStateManifestXml - file.Construct is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
+ AppLogTag(OSP_INSTALLER, "OnStateManifestXml - file.Construct is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
+ }
+
+ FileAttributes attr;
+ r = File::GetAttributes(__pContext->GetManifestXmlPath(), attr);
+ if (r != E_SUCCESS)
+ {
+ fprintf(stderr, "OnStateManifestXml - File::GetAttributes is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
+ AppLogTag(OSP_INSTALLER, "OnStateManifestXml - File::GetAttributes is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
+ }
+ TryCatch(!IsFailed(r), error = INSTALLER_ERROR_INVALID_PACKAGE, "[osp-installer] File::GetAttributes() failed");
+
+ size = file.Read(p, bufSize);
+ if (size <= 0)
+ {
+ fprintf(stderr, "OnStateManifestXml - file.Read is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
+ AppLogTag(OSP_INSTALLER, "OnStateManifestXml - file.Read is failed. [%ls]\n", __pContext->GetManifestXmlPath().GetPointer());
+ }
+
+ if (strstr(p, "<Apps>") != null)
+ {
+ AppLogTag(OSP_INSTALLER, "ManifestXmlStep::OnStateManifest() - new manifest!");
+
+ ManifestHandler manifestHandler;
+ manifestHandler.Construct(__pContext);
+ ret = manifestHandler.Parse(pFilepath);
+ if (ret == false)
+ {
+ fprintf(stderr, "OnStateManifestXml - manifestHandler.Parse is failed. [%s]\n", pFilepath);
+ }
+ TryCatch(ret == true, error = INSTALLER_ERROR_INVALID_MANIFEST, "[osp-installer] manifestHandler.Parse() failed");
+
+ pPackageInfoImpl = __pContext->GetPackageInfoImpl();
+ TryCatch(pPackageInfoImpl, error = INSTALLER_ERROR_INVALID_MANIFEST, "[osp-installer] pPackageInfoImpl is null");
+ __pContext->SetAppId(pPackageInfoImpl->GetAppId());
+ }
+ else
+ {
+ fprintf(stderr, "ManifestXmlStep::OnStateManifestXml - old manifest!! \n");
+ AppLogTag(OSP_INSTALLER, "ManifestXmlStep::OnStateManifest() - error(INSTALLER_ERROR_INVALID_MANIFEST)");
+ error = INSTALLER_ERROR_INVALID_MANIFEST;
+ }
+
+CATCH:
+ delete[] p;
+
+ GoNextState();
+
+ delete[] pFilepath;
+ return error;
+}
+
+InstallerError
+ManifestXmlStep::OnStateDone(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "ManifestXmlStep::OnStateDone()");
+
+ GoNextState();
+ return error;
+}
diff --git a/src/Step/ManifestXmlStep.h b/src/Step/ManifestXmlStep.h
new file mode 100644
index 0000000..08d2975
--- /dev/null
+++ b/src/Step/ManifestXmlStep.h
@@ -0,0 +1,62 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file ManifestXmlStep.h
+ * @brief This is the header file for the %ManifestXmlStep class.
+ *
+ * This header file contains the declarations of the %ManifestXmlStep class.
+ */
+#ifndef _MANIFEST_XML_STEP_H_
+#define _MANIFEST_XML_STEP_H_
+
+#include "IInstallationStep.h"
+
+/**
+ * @class ManifestXmlStep
+ * @brief This class represents the class of ManifestXmlStep.
+ * @since 1.0
+ *
+ * This class represents the class of ManifestXmlStep.
+ *
+ */
+class ManifestXmlStep
+ : public IInstallationStep
+{
+public:
+ ManifestXmlStep(void);
+ virtual ~ManifestXmlStep(void);
+
+ virtual InstallerError Run(InstallationContext* pContext);
+
+private:
+ enum
+ {
+ STATE_MANIFEST_XML,
+ STATE_DONE
+ };
+
+ void GoNextState(void);
+ InstallerError OnStateManifestXml(void);
+ InstallerError OnStateDone(void);
+
+private:
+ int __state;
+ InstallationContext* __pContext;
+
+}; // ManifestXmlStep
+
+#endif //_MANIFEST_XML_STEP_H_
diff --git a/src/Step/PackageCheckStep.cpp b/src/Step/PackageCheckStep.cpp
new file mode 100755
index 0000000..5a3d8df
--- /dev/null
+++ b/src/Step/PackageCheckStep.cpp
@@ -0,0 +1,137 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file PackageCheckStep.cpp
+ * @brief This is the implementation file for %PackageCheckStep class.
+ */
+
+#include <FIoFile.h>
+#include <FIoDirectory.h>
+
+#include "InstallationContext.h"
+#include "PackageCheckStep.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Utility;
+using namespace Osp::Io;
+
+PackageCheckStep::PackageCheckStep(void)
+:__state(STATE_PACKAGE_CHECK)
+,__pContext(null)
+{
+}
+
+PackageCheckStep::~PackageCheckStep(void)
+{
+}
+
+InstallerError
+PackageCheckStep::Run(InstallationContext* pContext)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "PackageCheckStep - START");
+
+ __pContext = pContext;
+
+ while (true)
+ {
+ switch (__state)
+ {
+ case STATE_PACKAGE_CHECK:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_PACKAGE_CHECK");
+ error = OnStatePackageCheck();
+ break;
+
+ case STATE_DONE:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DONE");
+ error = OnStateDone();
+ break;
+
+ default:
+ break;
+ }
+
+ if (error != INSTALLER_ERROR_NONE)
+ {
+ fprintf(stderr, "PackageCheckStep::Run - ErrorType [%d]\n", error);
+ break;
+ }
+
+ if (__state > STATE_DONE)
+ {
+ AppLogTag(OSP_INSTALLER, "PackageCheckStep - END");
+ break;
+ }
+ }
+
+ return error;
+}
+
+void
+PackageCheckStep::GoNextState(void)
+{
+ __state++;
+}
+
+InstallerError
+PackageCheckStep::OnStatePackageCheck(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "SignatureStep::OnStatePackageCheck()");
+
+ String tempDir;
+
+ if (__pContext->GetInstallationStorage() == InstallationContext::INSTALLATION_STORAGE_INTERNAL)
+ {
+ tempDir = DIR_OSP_APPLICATIONS_TEMP;
+ }
+ else
+ {
+ tempDir = DIR_MEMORYCARD_OSP_APPLICATIONS_TEMP;
+ }
+
+ __pContext->SetTemporaryDir(tempDir);
+ __pContext->SetInstallDir(tempDir);
+
+ if (File::IsFileExist(DIR_OSP_APPLICATIONS_TEMP) == false)
+ {
+ result r = E_SUCCESS;
+ r = Directory::Create(DIR_OSP_APPLICATIONS_TEMP, false);
+ TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Directory::Create() failed");
+ }
+
+ FileUnzipper unzipper;
+ unzipper.Construct(__pContext->GetPackagePath());
+
+ AppLogTag(OSP_INSTALLER, "UnzipTo(manifest.xml) - START");
+ unzipper.UnzipTo(tempDir, L"info/manifest.xml");
+ unzipper.UnzipTo(tempDir, L"signature1.xml");
+ AppLogTag(OSP_INSTALLER, "UnzipTo(manifest.xml) - END");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+PackageCheckStep::OnStateDone(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "PackageCheckStep::OnStateDone()");
+
+ GoNextState();
+ return error;
+}
diff --git a/src/Step/PackageCheckStep.h b/src/Step/PackageCheckStep.h
new file mode 100644
index 0000000..b39ef44
--- /dev/null
+++ b/src/Step/PackageCheckStep.h
@@ -0,0 +1,62 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file PackageCheckStep.h
+ * @brief This is the header file for the %PackageCheckStep class.
+ *
+ * This header file contains the declarations of the %PackageCheckStep class.
+ */
+#ifndef _PACKAGE_CHECK_STEP_H_
+#define _PACKAGE_CHECK_STEP_H_
+
+#include "IInstallationStep.h"
+
+/**
+ * @class PackageCheckStep
+ * @brief This class represents the class of PackageCheckStep.
+ * @since 1.0
+ *
+ * This class represents the class of PackageCheckStep.
+ *
+ */
+class PackageCheckStep
+ : public IInstallationStep
+{
+public:
+ PackageCheckStep(void);
+ virtual ~PackageCheckStep(void);
+
+ virtual InstallerError Run(InstallationContext* pContext);
+
+private:
+ enum
+ {
+ STATE_PACKAGE_CHECK,
+ STATE_DONE
+ };
+
+ void GoNextState(void);
+ InstallerError OnStatePackageCheck(void);
+ InstallerError OnStateDone(void);
+
+private:
+ int __state;
+ InstallationContext* __pContext;
+
+}; // PackageCheckStep
+
+#endif //_PACKAGE_CHECK_STEP_H_
diff --git a/src/Step/SignatureStep.cpp b/src/Step/SignatureStep.cpp
new file mode 100755
index 0000000..186b2d0
--- /dev/null
+++ b/src/Step/SignatureStep.cpp
@@ -0,0 +1,219 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file SignatureStep.cpp
+ * @brief This is the implementation file for %SignatureStep class.
+ */
+
+#include <FIoFile.h>
+#include <FApp_PackageInfoImpl.h>
+#include <FBase_StringConverter.h>
+
+#include "InstallationContext.h"
+#include "PrivilegeHandler.h"
+#include "SignatureHandler.h"
+#include "SignatureStep.h"
+
+using namespace Osp::App;
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::Io;
+
+SignatureStep::SignatureStep(void)
+:__state(STATE_SIGNER_CERT)
+,__pContext(null)
+,__pSignatureManager(null)
+{
+}
+
+SignatureStep::~SignatureStep(void)
+{
+ delete __pSignatureManager;
+}
+
+InstallerError
+SignatureStep::Run(InstallationContext* pContext)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "SignatureStep - START");
+
+ __pContext = pContext;
+
+ // signature.xml for beta
+ FileAttributes attr;
+ result r = E_SUCCESS;
+
+ r = File::GetAttributes(__pContext->GetSignatureXmlPath(), attr);
+ if (r != E_SUCCESS)
+ {
+ AppLogTag(OSP_INSTALLER, "Signature file is not existing. [%ls]\n", __pContext->GetSignatureXmlPath().GetPointer());
+ return INSTALLER_ERROR_NONE;
+ }
+
+ while (true)
+ {
+ switch (__state)
+ {
+ case STATE_SIGNER_CERT:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_SIGNER_CERT");
+ error = OnStateSignerCert();
+ break;
+
+ case STATE_CERT_CHAIN:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_CERT_CHAIN");
+ error = OnStateCertChain();
+ break;
+
+ case STATE_ROOT_CERT:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_ROOT_CERT");
+ error = OnStateRootCert();
+ break;
+
+ case STATE_DONE:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DONE");
+ error = OnStateDone();
+ break;
+
+ default:
+ break;
+ }
+
+ if (error != INSTALLER_ERROR_NONE)
+ {
+ AppLogTag(OSP_INSTALLER, "SignatureStep::Run - ErrorType [%d]\n", error);
+ //fprintf(stderr, "SignatureStep::Run - ErrorType [%d]\n", error);
+ break;
+ }
+
+ if (__state > STATE_DONE)
+ {
+ AppLogTag(OSP_INSTALLER, "SignatureStep - END");
+ break;
+ }
+ }
+
+ return error;
+}
+
+void
+SignatureStep::GoNextState(void)
+{
+ __state++;
+}
+
+InstallerError
+SignatureStep::OnStateSignerCert(void)
+{
+ AppLogTag(OSP_INSTALLER, "SignatureStep::OnStateSignerCert()");
+
+ InstallerError error = INSTALLER_ERROR_NONE;
+ bool ret = true;
+
+ __pSignatureManager = new SignatureManager();
+ TryCatch(__pSignatureManager, error = INSTALLER_ERROR_MEMORY, "[osp-installer] __pSignatureManager is null.");
+
+ ret = __pSignatureManager->Construct(__pContext);
+ TryCatch(ret == true, error = INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Construct() failed");
+
+ ret = __pSignatureManager->SetSignature();
+ TryCatch(ret == true, error = INSTALLER_ERROR_INVALID_SIGNATURE, "[osp-installer] SetSignature() failed");
+
+CATCH:
+ GoNextState();
+ return error;
+}
+
+InstallerError
+SignatureStep::OnStateCertChain(void)
+{
+ AppLogTag(OSP_INSTALLER, "SignatureStep::OnStateCertChain()");
+
+ InstallerError error = INSTALLER_ERROR_NONE;
+ bool ret = true;
+ int rootCert = ROOT_CERTIFICATE_NORMAL;
+
+ ret = __pSignatureManager->AddCert(ROOT_CERTIFICATE_DEVELOPER);
+ TryCatch(ret == true, error = INSTALLER_ERROR_INVALID_SIGNATURE, "[osp-installer] AddCert(DEVELOPER_ROOT_CERTIFICATE) failed");
+
+ ret = __pSignatureManager->VerifyChain(ROOT_CERTIFICATE_DEVELOPER);
+ TryCatch(ret == true, error = INSTALLER_ERROR_INVALID_SIGNATURE, "[osp-installer] VerifyChain(DEVELOPER_ROOT_CERTIFICATE) failed");
+
+ for(rootCert = ROOT_CERTIFICATE_NORMAL; rootCert <= ROOT_CERTIFICATE_PRIVATE; rootCert++)
+ {
+ ret = __pSignatureManager->AddCert((RootCertificateType)rootCert);
+ TryCatch(ret == true, error = INSTALLER_ERROR_INVALID_SIGNATURE, "[osp-installer] AddCert() failed");
+
+ ret = __pSignatureManager->VerifyChain((RootCertificateType)rootCert);
+ if (ret == true)
+ {
+ AppLogTag(OSP_INSTALLER, "VerifyChain() success(Cert = [%d])", rootCert);
+ __pContext->SetRootCertType((RootCertificateType)rootCert);
+ error = INSTALLER_ERROR_NONE;
+ break;
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "VerifyChain() fail(Cert = [%d])", rootCert);
+ error = INSTALLER_ERROR_INVALID_SIGNATURE;
+ }
+ }
+
+CATCH:
+ GoNextState();
+ return error;
+}
+
+InstallerError
+SignatureStep::OnStateRootCert(void)
+{
+ AppLogTag(OSP_INSTALLER, "SignatureStep::OnStateRootCert()");
+
+ InstallerError error = INSTALLER_ERROR_NONE;
+ result r = E_SUCCESS;
+ String privileges;
+ String hmacPrivileges;
+
+ const ArrayList* pPrivilegeList = __pContext->GetPrivilegeList();
+ RootCertificateType certType = __pContext->GetRootCertType();
+ _PackageInfoImpl* pPackageInfoImpl = __pContext->GetPackageInfoImpl();
+ String appId = pPackageInfoImpl->GetAppId();
+
+ AppLogTag(OSP_INSTALLER, "AppId = [%ls], CertType = [%d]", appId.GetPointer(), certType);
+
+ r = PrivilegeHandler::GenerateCipherPrivilege(appId, *pPrivilegeList, certType, privileges, hmacPrivileges);
+ if (IsFailed(r))
+ {
+ fprintf(stderr, "PrivilegeHandler::GenerateCipherPrivilege is failded. [%ls][%ls][%ls]\n", appId.GetPointer(), privileges.GetPointer(), hmacPrivileges.GetPointer());
+ }
+ TryCatch(!IsFailed(r), error = INSTALLER_ERROR_PRIVILEGE, "[osp-installer] privMgr.GeneratePrivilegeString() failed");
+
+ pPackageInfoImpl->SetPrivilegesValue(privileges, hmacPrivileges);
+
+CATCH:
+ GoNextState();
+ return error;
+}
+
+InstallerError
+SignatureStep::OnStateDone(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "SignatureStep::OnStateDone()");
+
+ GoNextState();
+ return error;
+}
diff --git a/src/Step/SignatureStep.h b/src/Step/SignatureStep.h
new file mode 100755
index 0000000..25d912b
--- /dev/null
+++ b/src/Step/SignatureStep.h
@@ -0,0 +1,68 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file SignatureStep.h
+ * @brief This is the header file for the %SignatureStep class.
+ *
+ * This header file contains the declarations of the %SignatureStep class.
+ */
+#ifndef _SIGNATURE_STEP_H_
+#define _SIGNATURE_STEP_H_
+
+#include "IInstallationStep.h"
+#include "SignatureManager.h"
+
+/**
+ * @class SignatureStep
+ * @brief This class represents the class of SignatureStep.
+ * @since 1.0
+ *
+ * This class represents the class of SignatureStep.
+ *
+ */
+class SignatureStep
+ : public IInstallationStep
+{
+public:
+ SignatureStep(void);
+ virtual ~SignatureStep(void);
+
+ virtual InstallerError Run(InstallationContext* pContext);
+
+private:
+ enum
+ {
+ STATE_SIGNER_CERT,
+ STATE_CERT_CHAIN,
+ STATE_ROOT_CERT,
+ STATE_DONE
+ };
+
+ void GoNextState(void);
+ InstallerError OnStateSignerCert(void);
+ InstallerError OnStateCertChain(void);
+ InstallerError OnStateRootCert(void);
+ InstallerError OnStateDone(void);
+
+private:
+ int __state;
+ InstallationContext* __pContext;
+ SignatureManager* __pSignatureManager;
+
+}; // SignatureStep
+
+#endif //_SIGNATURE_STEP_H_
diff --git a/src/Step/SystemCheckStep.cpp b/src/Step/SystemCheckStep.cpp
new file mode 100755
index 0000000..6c59417
--- /dev/null
+++ b/src/Step/SystemCheckStep.cpp
@@ -0,0 +1,134 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file SystemCheckStep.cpp
+ * @brief This is the implementation file for %SystemCheckStep class.
+ */
+
+#include "InstallationContext.h"
+#include "SystemCheckStep.h"
+
+SystemCheckStep::SystemCheckStep(void)
+:__state(STATE_SYSTEM_CHECK)
+,__pContext(null)
+{
+}
+
+SystemCheckStep::~SystemCheckStep(void)
+{
+}
+
+InstallerError
+SystemCheckStep::Run(InstallationContext* pContext)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "SystemCheckStep - START");
+
+ __pContext = pContext;
+
+ while (true)
+ {
+ switch (__state)
+ {
+ case STATE_SYSTEM_CHECK:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_SYSTEM_CHECK");
+ error = OnStateSystemCheck();
+ break;
+
+ case STATE_AGENT_CHECK:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_AGENT_CHECK");
+ error = OnStateAgentCheck();
+ break;
+
+ case STATE_AGENT_TIMER:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_AGENT_TIMER");
+ error = OnStateAgentTimer();
+ break;
+
+ case STATE_DONE:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DONE");
+ error = OnStateDone();
+ break;
+
+ default:
+ break;
+ }
+
+ if (error != INSTALLER_ERROR_NONE)
+ {
+ fprintf(stderr, "SystemCheckStep::Run - ErrorType [%d]\n", error);
+ break;
+ }
+
+ if (__state > STATE_DONE)
+ {
+ AppLogTag(OSP_INSTALLER, "SystemCheckStep - END");
+ break;
+ }
+ }
+
+ return error;
+}
+
+void
+SystemCheckStep::GoNextState(void)
+{
+ __state++;
+}
+
+InstallerError
+SystemCheckStep::OnStateSystemCheck(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "SystemCheckStep::OnStateSystemCheck()");
+
+ // Check preferred storage
+ __pContext->SetInstallationStorage(InstallationContext::INSTALLATION_STORAGE_INTERNAL);
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+SystemCheckStep::OnStateAgentCheck(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "SystemCheckStep::OnStateAgentCheck()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+SystemCheckStep::OnStateAgentTimer(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "SystemCheckStep::OnStateStartTimer()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+SystemCheckStep::OnStateDone(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "SystemCheckStep::OnStateDone()");
+
+ GoNextState();
+ return error;
+}
diff --git a/src/Step/SystemCheckStep.h b/src/Step/SystemCheckStep.h
new file mode 100644
index 0000000..506f587
--- /dev/null
+++ b/src/Step/SystemCheckStep.h
@@ -0,0 +1,66 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file SystemCheckStep.h
+ * @brief This is the header file for the %SystemCheckStep class.
+ *
+ * This header file contains the declarations of the %SystemCheckStep class.
+ */
+#ifndef _SYSTEM_CHECK_STEP_H_
+#define _SYSTEM_CHECK_STEP_H_
+
+#include "IInstallationStep.h"
+
+/**
+ * @class SystemCheckStep
+ * @brief This class represents the class of SystemCheckStep.
+ * @since 1.0
+ *
+ * This class represents the class of SystemCheckStep.
+ *
+ */
+class SystemCheckStep
+ : public IInstallationStep
+{
+public:
+ SystemCheckStep(void);
+ virtual ~SystemCheckStep(void);
+
+ virtual InstallerError Run(InstallationContext* pContext);
+
+private:
+ enum
+ {
+ STATE_SYSTEM_CHECK,
+ STATE_AGENT_CHECK,
+ STATE_AGENT_TIMER,
+ STATE_DONE
+ };
+
+ void GoNextState(void);
+ InstallerError OnStateSystemCheck(void);
+ InstallerError OnStateAgentCheck(void);
+ InstallerError OnStateAgentTimer(void);
+ InstallerError OnStateDone(void);
+
+private:
+ int __state;
+ InstallationContext* __pContext;
+
+}; // SystemCheckStep
+
+#endif //_SYSTEM_CHECK_STEP_H_
diff --git a/src/Step/UninstallStep.cpp b/src/Step/UninstallStep.cpp
new file mode 100755
index 0000000..9d53904
--- /dev/null
+++ b/src/Step/UninstallStep.cpp
@@ -0,0 +1,227 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file UninstallStep.cpp
+ * @brief This is the implementation file for %UninstallStep class.
+ */
+
+#include <FIoDirectory.h>
+#include <FIo_FileImpl.h>
+#include <FApp_PackageManagerImpl.h>
+#include <FApp_PackageInfoImpl.h>
+#include <FApp_AppInfoImpl.h>
+
+#include "InstallationContext.h"
+#include "UninstallStep.h"
+#include "InstallerUtil.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::App;
+using namespace Osp::Io;
+
+UninstallStep::UninstallStep(void)
+:__state(STATE_GET_PACKAGEINFO)
+,__pContext(null)
+{
+}
+
+UninstallStep::~UninstallStep(void)
+{
+}
+
+InstallerError
+UninstallStep::Run(InstallationContext* pContext)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UninstallStep - START");
+
+ __pContext = pContext;
+
+ while (true)
+ {
+ switch (__state)
+ {
+ case STATE_GET_PACKAGEINFO:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_GET_PACKAGEINFO");
+ error = OnStateGetPackageInfo();
+ break;
+
+ case STATE_CHECK_APP_RUNNING:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_CHECK_APP_RUNNING");
+ error = OnStateCheckAppRunning();
+ break;
+
+ case STATE_TERMINATE_APP:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_TERMINATE_APP");
+ error = OnStateTerminateApp();
+ break;
+
+ case STATE_START_TIMER:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_START_TIMER");
+ error = OnStateStartTimer();
+ break;
+
+ case STATE_DELETE_DIR:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DELETE_DIR");
+ error = OnStateRemoveDir();
+ break;
+
+ case STATE_DONE:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DONE");
+ error = OnStateDone();
+ break;
+
+ default:
+ break;
+ }
+
+ if (error != INSTALLER_ERROR_NONE)
+ {
+ fprintf(stderr, "UninstallStep::Run - ErrorType [%d]\n", error);
+ break;
+ }
+
+ if (__state > STATE_DONE)
+ {
+ AppLogTag(OSP_INSTALLER, "UninstallStep - END");
+ break;
+ }
+ }
+
+ return error;
+}
+
+void
+UninstallStep::GoNextState(void)
+{
+ __state++;
+}
+
+InstallerError
+UninstallStep::OnStateGetPackageInfo(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UninstallStep::OnStateCheckAppRunning()");
+
+ String appId;
+ appId = __pContext->GetAppId();
+
+ AppLogTag(OSP_INSTALLER, "appId = %S", appId.GetPointer());
+
+ _PackageInfoImpl* pPackageInfoImpl = __pContext->GetPackageInfoImpl();
+ TryReturn(pPackageInfoImpl, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pPackageInfoImpl is null");
+
+ pPackageInfoImpl->Construct(appId);
+
+ ArrayList* pList = pPackageInfoImpl->GetAppInfoListN();
+ TryReturn(pList, INSTALLER_ERROR_DATABASE, "[osp-installer] pList is null.");
+
+ for (int i = 0; i < pList->GetCount(); i++)
+ {
+ _PackageAppInfoImpl* pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pList->GetAt(i));
+ if (pAppInfoImpl)
+ {
+ pPackageInfoImpl->AddAppInfo(*pAppInfoImpl);
+ pAppInfoImpl = null;
+ }
+ }
+
+ __state = STATE_DELETE_DIR;
+
+ return error;
+}
+
+
+InstallerError
+UninstallStep::OnStateCheckAppRunning(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UninstallStep::OnStateCheckAppRunning()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+UninstallStep::OnStateTerminateApp(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UninstallStep::OnStateTerminateApp()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+UninstallStep::OnStateStartTimer(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UninstallStep::OnStateStartTimer()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+UninstallStep::OnStateRemoveDir(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UninstallStep::OnStateRemoveDir()");
+
+ _PackageInfoImpl* pPackageInfoImpl = __pContext->GetPackageInfoImpl();
+ TryReturn(pPackageInfoImpl, INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] pPackageInfoImpl is null");
+
+ String rootPath;
+ rootPath = pPackageInfoImpl->GetAppRootPath();
+ AppLogTag(OSP_INSTALLER, "rootPath[%ls]", rootPath.GetPointer());
+
+ AppLogTag(OSP_INSTALLER, "Directory::Remove - START");
+ InstallerUtil::Remove(rootPath);
+
+ _PackageAppInfoImpl* pAppInfoImpl = null;
+ ArrayList* pAppList = null;
+
+ pAppList = pPackageInfoImpl->GetAppInfoList();
+ for (int i = 0 ; i < pAppList->GetCount(); i++)
+ {
+ pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
+ if (pAppInfoImpl)
+ {
+ String packageName = pAppInfoImpl->GetPackageName();
+ String destPath;
+ destPath.Format(1024, L"%S/%S", SLP_APP_PATH, packageName.GetPointer());
+ AppLogTag(OSP_INSTALLER, "destPath[%ls]", destPath.GetPointer());
+
+ InstallerUtil::Remove(destPath);
+ }
+ }
+ AppLogTag(OSP_INSTALLER, "Directory::Remove - END");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+UninstallStep::OnStateDone(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UninstallStep::OnStateDone()");
+
+ GoNextState();
+ return error;
+}
diff --git a/src/Step/UninstallStep.h b/src/Step/UninstallStep.h
new file mode 100644
index 0000000..ca97334
--- /dev/null
+++ b/src/Step/UninstallStep.h
@@ -0,0 +1,70 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file UninstallStep.h
+ * @brief This is the header file for the %UninstallStep class.
+ *
+ * This header file contains the declarations of the %UninstallStep class.
+ */
+#ifndef _UNINSTALL_STEP_H_
+#define _UNINSTALL_STEP_H_
+
+#include "IInstallationStep.h"
+
+/**
+ * @class UninstallStep
+ * @brief This class represents the class of UninstallStep.
+ * @since 1.0
+ *
+ * This class represents the class of UninstallStep.
+ *
+ */
+class UninstallStep
+ : public IInstallationStep
+{
+public:
+ UninstallStep(void);
+ virtual ~UninstallStep(void);
+
+ virtual InstallerError Run(InstallationContext* pContext);
+
+private:
+ enum
+ {
+ STATE_GET_PACKAGEINFO,
+ STATE_CHECK_APP_RUNNING,
+ STATE_TERMINATE_APP,
+ STATE_START_TIMER,
+ STATE_DELETE_DIR,
+ STATE_DONE
+ };
+
+ void GoNextState(void);
+ InstallerError OnStateGetPackageInfo(void);
+ InstallerError OnStateCheckAppRunning(void);
+ InstallerError OnStateTerminateApp(void);
+ InstallerError OnStateStartTimer(void);
+ InstallerError OnStateRemoveDir(void);
+ InstallerError OnStateDone(void);
+
+private:
+ int __state;
+ InstallationContext* __pContext;
+
+}; // UninstallStep
+
+#endif //_UNINSTALL_STEP_H_
diff --git a/src/Step/UnpackStep.cpp b/src/Step/UnpackStep.cpp
new file mode 100755
index 0000000..f79feba
--- /dev/null
+++ b/src/Step/UnpackStep.cpp
@@ -0,0 +1,288 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file UnpackStep.cpp
+ * @brief This is the implementation file for %UnpackStep class.
+ */
+
+#include <FIoFile.h>
+#include <FIoDirectory.h>
+#include <FBaseResult.h>
+#include <FBaseUtilFileUnzipper.h>
+#include <FApp_PackageInfoImpl.h>
+
+#include "InstallationContext.h"
+#include "UnpackStep.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Utility;
+using namespace Osp::App;
+using namespace Osp::Io;
+
+UnpackStep::UnpackStep(void)
+:__state(STATE_UNZIP)
+,__pContext(null)
+{
+}
+
+UnpackStep::~UnpackStep(void)
+{
+}
+
+InstallerError
+UnpackStep::Run(InstallationContext* pContext)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UnpackStep - START");
+
+ __pContext = pContext;
+
+ while (true)
+ {
+ switch (__state)
+ {
+ case STATE_UNZIP:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_UNZIP");
+ error = OnUnzip();
+ break;
+
+ case STATE_VERSION_CHECK:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_VERSION_CHECK");
+ error = OnStateVersionCheck();
+ break;
+
+ case STATE_FILE_MOVE:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_FILE_MOVE");
+ error = OnStateFileMove();
+ break;
+
+ case STATE_CREATE_DIR:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_CREATE_DIR");
+ error = OnCreateDir();
+ break;
+
+ case STATE_DONE:
+ AppLogTag(OSP_INSTALLER, "[State] STATE_DONE");
+ error = OnStateDone();
+ break;
+
+ default:
+ break;
+ }
+
+ if (error != INSTALLER_ERROR_NONE)
+ {
+ fprintf(stderr, "UnpackStep::Run - ErrorType [%d]\n", error);
+ break;
+ }
+
+ if (__state > STATE_DONE)
+ {
+ AppLogTag(OSP_INSTALLER, "UnpackStep - END");
+ break;
+ }
+ }
+
+ return error;
+}
+
+void
+UnpackStep::GoNextState(void)
+{
+ __state++;
+}
+
+InstallerError
+UnpackStep::OnUnzip(void)
+{
+ // String tempDir;
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "OnUnzip()");
+ _PackageInfoImpl *pPackageInfoImpl = null;
+
+#if 0
+ FileUnzipper unzFile;
+ String packagePath = __pContext->GetPackagePath();
+ AppLogTag(OSP_INSTALLER, "packagePath = [%S]", packagePath.GetPointer());
+
+
+ if (!File::IsFileExist(packagePath))
+ {
+ AppLogException(" ##UnpackStep::OnUnzip packagePath=[%S] does not exist", packagePath.GetPointer());
+ }
+ else
+ {
+ AppLogException(" ##UnpackStep::OnUnzip packagePath=[%S] exists", packagePath.GetPointer());
+ }
+
+ r = unzFile.Construct(packagePath);
+
+ if (r != E_SUCCESS)
+ {
+ AppLogException(" ##UnpackStep::OnUnzip Fail to construct, err=[%s]", GetErrorMessage(r));
+ }
+ else
+ {
+ AppLogException(" ##UnpackStep::OnUnzip Success to construct, err=[%s]", GetErrorMessage(r));
+ }
+
+ if (__pContext->IsMmc())
+ {
+ tempDir = DIR_OSP_APPLICATION_MMC;
+ }
+ else
+ {
+ tempDir = DIR_OSP_APPLICATION_PHONE;
+ }
+
+ tempDir.Append(DIR_OSP_APPLICATION_TMP);
+
+ if (File::IsFileExist(tempDir))
+ {
+ Directory::Remove(tempDir, true);
+ }
+
+ __pContext->SetTemporaryDir(tempDir);
+ CreateDefaultDir();
+
+ AppLogException(" ##UnpackStep::OnUnzip UnzipTo path=[%S]", tempDir.GetPointer());
+
+ // r = unzFile.UnzipTo(tempDir);
+ // temp
+
+ // Unzip(packagePath, tempDir);
+
+
+ if (r != E_SUCCESS)
+ {
+ AppLogException(" ##UnpackStep::OnUnzip Fail to UnzipTo path=[%S], err=[%s].", tempDir.GetPointer(), GetErrorMessage(r));
+ }
+ else
+ {
+ AppLogException(" ##UnpackStep::OnUnzip Success to UnzipTo path=[%S], err=[%s].", tempDir.GetPointer(), GetErrorMessage(r));
+ }
+ // r = unzFile.UnzipTo(tempDir.GetPointer(), "EntryName");
+#endif
+
+ String installPath;
+ installPath = SLP_APP_PATH;
+ installPath += "/";
+
+ if (__pContext->GetPackageNameType() == INSTALLER_PREFIX_TYPE_ORG)
+ {
+ installPath += PACKAGE_NAME_PREFIX_ORG;
+ }
+
+ installPath += __pContext->GetAppId();
+ __pContext->SetInstallDir(installPath);
+
+ if (File::IsFileExist(installPath) == false)
+ {
+ result r = E_SUCCESS;
+ r = Directory::Create(installPath, false);
+ TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Directory::Create() failed");
+ }
+
+ pPackageInfoImpl = __pContext->GetPackageInfoImpl();
+ pPackageInfoImpl->SetAppRootPath(installPath);
+
+ AppLogTag(OSP_INSTALLER, "UnzipTo - START");
+ FileUnzipper unzipper;
+ unzipper.Construct(__pContext->GetPackagePath());
+ unzipper.UnzipTo(installPath);
+ AppLogTag(OSP_INSTALLER, "UnzipTo - END");
+
+ // GoNextState();
+ __state = STATE_DONE;
+ return error;
+}
+
+InstallerError
+UnpackStep::OnStateVersionCheck(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UnpackStep::OnStateVersionCheck()");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+UnpackStep::OnStateFileMove(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UnpackStep::OnStateFileMove()");
+// result r = E_SUCCESS;
+
+//
+// String workingDir = __pContext->GetWorkingDir();
+// String installDir = __pContext->GetInstallDir();
+//
+// r = File::Remove(installDir);
+// if (r != E_SUCCESS)
+// {
+// AppLogException(" ##UnpackStep::OnCreateDir Fail to remove installdir, []", installDir.GetPointer());
+// }
+// else
+// {
+// AppLogException(" ##UnpackStep::OnCreateDir Success to remove installdir, []", installDir.GetPointer());
+// }
+//
+// r = File::Move(workingDir, installDir);
+// if (r != E_SUCCESS)
+// {
+// AppLogException(" ##UnpackStep::OnCreateDir Failed, srcpath=[%S], dstpath=[%S]", workingDir.GetPointer(), installDir.GetPointer());
+// }
+// else
+// {
+// AppLogException(" ##UnpackStep::OnCreateDir Success, srcpath=[%S], dstpath=[%S]", workingDir.GetPointer(), installDir.GetPointer());
+// }
+//
+ GoNextState();
+ return error;
+}
+
+InstallerError
+UnpackStep::OnCreateDir(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UnpackStep::OnCreateDir()");
+
+ //Directory::Create(path, true); // Share, TrustShare, Data under InstallDir
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
+UnpackStep::OnStateDone(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+ AppLogTag(OSP_INSTALLER, "UnpackStep::OnStateDone()");
+
+ GoNextState();
+ return error;
+}
+
+bool
+UnpackStep::CreateDefaultDir(void)
+{
+ // Directory::Create(DIR_OSP_APPLICATION_PHONE, true);
+ // Directory::Create(DIR_OSP_APPLICATION_MMC, true);
+
+ return true;
+}
diff --git a/src/Step/UnpackStep.h b/src/Step/UnpackStep.h
new file mode 100644
index 0000000..d67d7fd
--- /dev/null
+++ b/src/Step/UnpackStep.h
@@ -0,0 +1,71 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file UnpackStep.h
+ * @brief This is the header file for the %UnpackStep class.
+ *
+ * This header file contains the declarations of the %UnpackStep class.
+ */
+#ifndef _UNPACK_STEP_H_
+#define _UNPACK_STEP_H_
+
+#include "IInstallationStep.h"
+
+/**
+ * @class UnpackStep
+ * @brief This class represents the class of UnpackStep.
+ * @since 1.0
+ *
+ * This class represents the class of UnpackStep.
+ *
+ */
+class UnpackStep
+ : public IInstallationStep
+{
+public:
+ UnpackStep(void);
+ virtual ~UnpackStep(void);
+
+ virtual InstallerError Run(InstallationContext* pContext);
+
+private:
+ enum
+ {
+ STATE_UNZIP,
+ STATE_VERSION_CHECK,
+ STATE_FILE_MOVE,
+ STATE_CREATE_DIR,
+ STATE_DONE
+ };
+
+ void GoNextState(void);
+ InstallerError OnUnzip(void);
+ InstallerError OnStateVersionCheck(void);
+ InstallerError OnStateFileMove(void);
+ InstallerError OnCreateDir(void);
+ InstallerError OnStateDone(void);
+
+ bool CreateDefaultDir(void);
+ bool Unzip(const Osp::Base::String& srcZipFile, const Osp::Base::String& desDirPath);
+
+private:
+ int __state;
+ InstallationContext* __pContext;
+
+}; // UnpackStep
+
+#endif //_UNPACK_STEP_H_
diff --git a/src/Util/InstallerUtil.cpp b/src/Util/InstallerUtil.cpp
new file mode 100755
index 0000000..d059812
--- /dev/null
+++ b/src/Util/InstallerUtil.cpp
@@ -0,0 +1,86 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file InstallerUtil.cpp
+ * @brief This is the implementation file for %InstallerUtil class.
+ */
+
+#include <sys/stat.h>
+#include <dirent.h>
+#include <unistd.h>
+
+#include <FBaseErrorDefine.h>
+#include <FIoFile.h>
+#include <FIoDirectory.h>
+#include <FBase_StringConverter.h>
+
+#include "InstallerDefs.h"
+#include "InstallerUtil.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::App;
+using namespace Osp::Io;
+
+InstallerUtil::InstallerUtil(void)
+{
+}
+
+InstallerUtil::~InstallerUtil(void)
+{
+}
+
+bool
+InstallerUtil::Remove(const Osp::Base::String& filePath)
+{
+ bool res = false;
+ char* pFilePath = null;
+ struct stat fileinfo;
+ int err = 0;
+ result r = E_SUCCESS;
+
+ pFilePath = _StringConverter::CopyToCharArrayN(filePath);
+ TryCatch(pFilePath, r = GetLastResult(), "[osp-installer] pFilePath is null");
+
+ err = lstat(pFilePath, &fileinfo);
+ TryCatch(err >= 0, res = false, "[osp-installer] lstat() failed, pFilePath=%s", pFilePath);
+
+ if (S_ISLNK(fileinfo.st_mode))
+ {
+ AppLogTag(OSP_INSTALLER, "remove symlink, pFilePath=%s", pFilePath);
+ err = unlink(pFilePath);
+ TryCatch(err >= 0, res = false, "[osp-installer] unlink() failed, pFilePath=%s", pFilePath);
+ }
+ else if (S_ISDIR(fileinfo.st_mode))
+ {
+ AppLogTag(OSP_INSTALLER, "remove directory, filePath=%ls", filePath.GetPointer());
+ r = Directory::Remove(filePath, true);
+ TryCatch(!IsFailed(r), res = false, "[osp-installer] Directory::Remove() failed, filePath=%ls", filePath.GetPointer());
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "remove file, filePath=%ls", filePath.GetPointer());
+ r = File::Remove(filePath);
+ TryCatch(!IsFailed(r), res = false, "[osp-installer] File::Remove() failed, filePath=%ls", filePath.GetPointer());
+ }
+
+ res = true;
+
+CATCH:
+ delete [] pFilePath;
+ return res;
+}
diff --git a/src/Util/InstallerUtil.h b/src/Util/InstallerUtil.h
new file mode 100755
index 0000000..e3c9e58
--- /dev/null
+++ b/src/Util/InstallerUtil.h
@@ -0,0 +1,55 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file InstallerUtil.h
+ * @brief This is the header file for the %InstallerUtil class.
+ *
+ * This header file contains the declarations of the %InstallerUtil class.
+ */
+#ifndef _INSTALLER_UTIL_H_
+#define _INSTALLER_UTIL_H_
+
+namespace Osp { namespace Base
+{
+class String;
+}}
+
+/**
+ * @class InstallerUtil
+ * @brief This class represents the class of InstallerUtil.
+ * @since 1.0
+ *
+ * This class represents the class of InstallerUtil.
+ *
+ */
+class InstallerUtil
+{
+public:
+ InstallerUtil(void);
+ virtual ~InstallerUtil(void);
+
+ static bool Remove(const Osp::Base::String& filePath);
+
+private:
+ InstallerUtil(const InstallerUtil& value);
+ InstallerUtil& operator =(const InstallerUtil& source);
+
+private:
+
+}; // InstallerUtil
+
+#endif // _INSTALLER_UTIL_H_
diff --git a/src/XmlHandler/ManifestGenerator.cpp b/src/XmlHandler/ManifestGenerator.cpp
new file mode 100755
index 0000000..1b5f422
--- /dev/null
+++ b/src/XmlHandler/ManifestGenerator.cpp
@@ -0,0 +1,346 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file ManifestGenerator.cpp
+ * @brief This is the implementation file for %ManifestGenerator class.
+ */
+
+#include <FLclLocale.h>
+#include <FApp_PackageInfoImpl.h>
+
+#include "ManifestGenerator.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::App;
+using namespace Osp::Locales;
+
+ManifestGenerator::ManifestGenerator(void)
+:__pContext(null)
+,__pPackageInfoImpl(null)
+,__pWriter(null)
+{
+}
+
+ManifestGenerator::~ManifestGenerator(void)
+{
+ delete __pWriter;
+ __pWriter = null;
+}
+
+bool
+ManifestGenerator::Construct(InstallationContext* pContext)
+{
+ __pContext = pContext;
+ __pPackageInfoImpl = pContext->GetPackageInfoImpl();
+
+ __pWriter = new XmlWriter;
+ TryReturn(__pWriter, false, "[osp-installer] __pWriter is null.");
+
+ return true;
+}
+
+bool
+ManifestGenerator::Write()
+{
+ bool preload = false; //__pContext->IsPreloaded();
+ String xmlPath;
+ String package;
+ String location;
+ _PackageInfoImpl *pPackageInfoImpl = null;
+ pPackageInfoImpl = __pContext->GetPackageInfoImpl();
+ TryReturn(pPackageInfoImpl, false, "[osp-installer] pPackageInfoImpl is null.");
+
+ if (preload == true)
+ {
+ xmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, __pContext->GetAppId().GetPointer());
+ location = L"internal-only";
+ }
+ else
+ {
+ xmlPath.Format(1024, DIR_RW_PACKAGE_SYSTEM_MANIFEST, __pContext->GetAppId().GetPointer());
+ location = L"auto";
+ }
+
+ package = __pContext->GetAppId();
+
+ __pWriter->Construct(xmlPath);
+
+ __pWriter->StartElement("manifest");
+ __pWriter->WriteAttribute("xmlns", "http://tizen.org/ns/packages");
+ __pWriter->WriteAttribute("package", package);
+ __pWriter->WriteAttribute("type", "tpk");
+ __pWriter->WriteAttribute("version", pPackageInfoImpl->GetAppVersion());
+ __pWriter->WriteAttribute("install-location", location);
+
+ __pWriter->StartElement("label");
+ __pWriter->WriteString(pPackageInfoImpl->GetAppName());
+ __pWriter->EndElement();
+
+ __pWriter->StartElement("author");
+ __pWriter->EndElement();
+
+ __pWriter->StartElement("description");
+ __pWriter->WriteString(pPackageInfoImpl->GetAppDescription());
+ __pWriter->EndElement();
+
+ _PackageAppInfoImpl* pAppInfoImpl = null;
+ ArrayList* pAppList = null;
+ pAppList = pPackageInfoImpl->GetAppInfoList();
+
+ for (int i = 0 ; i < pAppList->GetCount(); i++)
+ {
+ pAppInfoImpl = dynamic_cast<_PackageAppInfoImpl*>(pAppList->GetAt(i));
+
+ if (pAppInfoImpl)
+ {
+ IMap* pNameList = pAppInfoImpl->GetNameList();
+ String label("label");
+ String type("c++app");
+ String binaryPath;
+ binaryPath.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_BIN, pAppInfoImpl->GetName().GetPointer());
+
+ if (pAppInfoImpl->GetDefault() == L"True")
+ {
+ WriteLanguageValue(pNameList, label);
+
+ if (pAppInfoImpl->GetMainmenuIcon().IsEmpty() == false)
+ {
+ String iconPath;
+ iconPath.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_ICONS, pAppInfoImpl->GetMainmenuIcon().GetPointer());
+
+ __pWriter->StartElement("icon");
+ __pWriter->WriteString(iconPath);
+ __pWriter->EndElement();
+ }
+ }
+
+ // temp
+ String nodisplay("true");
+ String taskmanage("false");
+
+ if (pAppInfoImpl->GetType() == L"UiApp")
+ {
+ taskmanage = "true";
+
+ if (pAppInfoImpl->IsMainmenuVisible() == true)
+ {
+ nodisplay = "false";
+ }
+ else
+ {
+ nodisplay = "true";
+ }
+ }
+
+ __pWriter->StartElement("ui-application");
+ __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
+ __pWriter->WriteAttribute("exec", binaryPath);
+ __pWriter->WriteAttribute("nodisplay", nodisplay);
+ __pWriter->WriteAttribute("taskmanage", taskmanage);
+ __pWriter->WriteAttribute("multiple", "false");
+ __pWriter->WriteAttribute("type", type);
+
+#if 0
+ if (pAppInfoImpl->GetType() == L"UiApp")
+ {
+ String nodisplay;
+
+ if (pAppInfoImpl->IsMainmenuVisible() == true)
+ {
+ nodisplay = "false";
+ }
+ else
+ {
+ nodisplay = "true";
+ }
+
+ __pWriter->StartElement("ui-application");
+ __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
+ __pWriter->WriteAttribute("exec", binaryPath);
+ __pWriter->WriteAttribute("nodisplay", nodisplay);
+ __pWriter->WriteAttribute("taskmanage", "true");
+ __pWriter->WriteAttribute("multiple", "false");
+ __pWriter->WriteAttribute("type", type);
+ }
+ else if (pAppInfoImpl->GetType() == L"ServiceApp")
+ {
+ ArrayList* pFeatureList = pAppInfoImpl->GetAppFeatureList();
+ String onBoot("false");
+ String autoRestart("false");
+
+ if (FindFeatureValue(pFeatureList, "LaunchOnBoot", "True") == true)
+ {
+ onBoot = L"true";
+ }
+
+ if (FindFeatureValue(pFeatureList, "AutoRestart", "True") == true)
+ {
+ autoRestart = L"true";
+ }
+
+ __pWriter->StartElement("service-application");
+ __pWriter->WriteAttribute("appid", pAppInfoImpl->GetPackageName());
+ __pWriter->WriteAttribute("exec", binaryPath);
+ __pWriter->WriteAttribute("type", type);
+ __pWriter->WriteAttribute("on-boot", onBoot);
+ __pWriter->WriteAttribute("auto-restart", autoRestart);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "Type is invalid! [%ls]", pAppInfoImpl->GetType().GetPointer());
+ return false;
+ }
+#endif
+
+ WriteLanguageValue(pNameList, label);
+
+ if (pAppInfoImpl->GetMainmenuIcon().IsEmpty() == false)
+ {
+ String iconPath;
+ iconPath.Format(1024, L"%ls%ls/%ls", pPackageInfoImpl->GetAppRootPath().GetPointer(), DIR_ICONS, pAppInfoImpl->GetMainmenuIcon().GetPointer());
+
+ __pWriter->StartElement("icon");
+ __pWriter->WriteString(iconPath);
+ __pWriter->EndElement();
+ }
+
+ ArrayList* pAppControlImplList = pAppInfoImpl->GetAppControlList();
+ if (pAppControlImplList)
+ {
+ _AppControlInfoImpl* pAppControl = dynamic_cast<_AppControlInfoImpl*>(pAppControlImplList->GetAt(0));
+ if (pAppControl)
+ {
+ ArrayList* pCapabilityList = pAppControl->GetCapabilityList();
+ if (pCapabilityList)
+ {
+ _AppControlCapabilityInfoImpl* pCapability = dynamic_cast<_AppControlCapabilityInfoImpl*>(pCapabilityList->GetAt(0));
+ if (pCapability)
+ {
+ String operationId = pCapability->GetOperationId();
+
+ __pWriter->StartElement("application-service");
+
+ __pWriter->StartElement("operation");
+ __pWriter->WriteAttribute("name", operationId);
+ __pWriter->EndElement();
+
+ ArrayList* pResolutionList = pCapability->GetResolutionList();
+ if (pResolutionList)
+ {
+ _AppControlResolutionInfoImpl* pResolution = dynamic_cast <_AppControlResolutionInfoImpl*>(pResolutionList->GetAt(0));
+ if (pResolution)
+ {
+ String* pUriScheme = pResolution->GetUriScheme();
+ if (pUriScheme->IsEmpty() == false)
+ {
+ __pWriter->StartElement("uri");
+ __pWriter->WriteAttribute("name", *pUriScheme);
+ __pWriter->EndElement();
+ }
+
+ String* pMimeType = pResolution->GetMimeType();
+ if (pMimeType->IsEmpty() == false)
+ {
+ __pWriter->StartElement("mime");
+ __pWriter->WriteAttribute("name", *pMimeType);
+ __pWriter->EndElement();
+ }
+ }
+ }
+ __pWriter->EndElement();
+ }
+ }
+ }
+ }
+
+ __pWriter->EndElement();
+ }
+ }
+
+ __pWriter->EndElement();
+
+ return true;
+}
+
+bool
+ManifestGenerator::FindFeatureValue(ArrayList* pFeatureList, const String& feature, const String& value) const
+{
+ TryReturn(pFeatureList, false, "[osp-installer] pFeatureList is null.");
+
+ _AppFeatureInfoImpl* pFeature = null;
+
+ for (int i = 0 ; i < pFeatureList->GetCount(); i++)
+ {
+ pFeature = dynamic_cast<_AppFeatureInfoImpl*>(pFeatureList->GetAt(i));
+ if (pFeature)
+ {
+ if ((pFeature->GetName() == feature) && (pFeature->GetValue() == value))
+ {
+ AppLogTag(OSP_INSTALLER, "Find - feature=[%ls], value=[%ls]", feature.GetPointer(), value.GetPointer());
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool
+ManifestGenerator::WriteLanguageValue(IMap* pList, const String& element) const
+{
+ TryReturn(pList, false, "[osp-installer] pNameList is null.");
+
+ IMapEnumerator* pMapEnum = pList->GetMapEnumeratorN();
+ while (pMapEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pLanguage = null;
+ String* pValue = null;
+ String threeLetterCode;
+ String countryCode;
+ String launguage;
+
+ pLanguage = static_cast<String*> (pMapEnum->GetKey());
+ pValue = static_cast<String*> (pMapEnum->GetValue());
+
+ pLanguage->SubString(0, 3, threeLetterCode);
+ pLanguage->SubString(4, 2, countryCode);
+
+ LanguageCode code = Locale::StringToLanguageCode(threeLetterCode);
+ String twoLetterLanguage = Locale::LanguageCodeToTwoLetterLanguageCodeString(code);
+
+ launguage = twoLetterLanguage + L"-" + countryCode;
+ launguage.ToLowerCase();
+
+ if (((*pLanguage) == L"eng-GB") || ((*pLanguage) == L"eng-US"))
+ {
+ __pWriter->StartElement(element);
+ __pWriter->WriteString(*pValue);
+ __pWriter->EndElement();
+ }
+
+ __pWriter->StartElement(element);
+ __pWriter->WriteAttribute("xml:lang", launguage);
+ __pWriter->WriteString(*pValue);
+ __pWriter->EndElement();
+
+ AppLogTag(OSP_INSTALLER, "Lang [%ls]->[%ls], value=[%ls]", pLanguage->GetPointer(), launguage.GetPointer(), pValue->GetPointer());
+ }
+
+ delete pMapEnum;
+ return true;
+}
diff --git a/src/XmlHandler/ManifestGenerator.h b/src/XmlHandler/ManifestGenerator.h
new file mode 100644
index 0000000..46b9536
--- /dev/null
+++ b/src/XmlHandler/ManifestGenerator.h
@@ -0,0 +1,62 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file ManifestGenerator.h
+ * @brief This is the header file for the %ManifestGenerator class.
+ *
+ * This header file contains the declarations of the %ManifestGenerator class.
+ */
+#ifndef _MANIFEST_GENERATOR_H_
+#define _MANIFEST_GENERATOR_H_
+
+#include <FAppPackageInfo.h>
+
+#include "InstallationContext.h"
+#include "XmlWriter.h"
+
+/**
+ * @class ManifestGenerator
+ * @brief This class represents the class of ManifestGenerator.
+ * @since 1.0
+ *
+ * This class represents the class of ManifestGenerator.
+ *
+ */
+class ManifestGenerator
+{
+public:
+ ManifestGenerator(void);
+ virtual ~ManifestGenerator(void);
+
+ bool Construct(InstallationContext *pConext);
+ bool Write(void);
+
+private:
+ ManifestGenerator(const ManifestGenerator& value);
+ ManifestGenerator& operator =(const ManifestGenerator& source);
+
+ bool FindFeatureValue(Osp::Base::Collection::ArrayList* pFeatureList, const Osp::Base::String& feature, const Osp::Base::String& value) const;
+ bool WriteLanguageValue(Osp::Base::Collection::IMap* pList, const Osp::Base::String& label) const;
+
+private:
+ InstallationContext* __pContext;
+ Osp::App::_PackageInfoImpl* __pPackageInfoImpl;
+ XmlWriter* __pWriter;
+
+}; // ManifestGenerator
+
+#endif // _MANIFEST_GENERATOR_H_
diff --git a/src/XmlHandler/ManifestHandler.cpp b/src/XmlHandler/ManifestHandler.cpp
new file mode 100755
index 0000000..3bfaaa2
--- /dev/null
+++ b/src/XmlHandler/ManifestHandler.cpp
@@ -0,0 +1,1164 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file ManifestHandler.cpp
+ * @brief This is the implementation file for %ManifestHandler class.
+ */
+
+#include <FIoFile.h>
+#include <FSys_SystemInfoImpl.h>
+#include <FApp_PackageInfoImpl.h>
+#include <FBase_StringConverter.h>
+
+#include "ManifestHandler.h"
+#include "PrivilegeHandler.h"
+
+
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::Base::Utility;
+using namespace Osp::App;
+using namespace Osp::Io;
+using namespace Osp::System;
+
+ManifestHandler::ManifestHandler(void)
+:__pContext(null)
+,__pPrivilegeList(null)
+,__pPackageInfoImpl(null)
+,__pPackageAppInfoImpl(null)
+,__pAppControlInfoImpl(null)
+,__pAppControlCapabilityInfoImpl(null)
+,__pAppControlResolutionInfoImpl(null)
+,__pDataControlInfoImpl(null)
+,__pDataControlTypeImpl(null)
+,__pLaunchConditionImpl(null)
+,__pNotificationImpl(null)
+,__pDefaultIconType(null)
+,__isDefaultMainmenu(false)
+,__isDefaultSetting(false)
+,__isDefaultTicker(false)
+,__isDefaultQuickpanel(false)
+,__isDefaultLaunchImage(false)
+,__isDefaultName(false)
+,__isDefaultAppDetected(false)
+{
+}
+
+ManifestHandler::~ManifestHandler(void)
+{
+ if (__pPackageAppInfoImpl)
+ {
+ delete __pPackageAppInfoImpl;
+ __pPackageAppInfoImpl = null;
+ }
+}
+
+bool
+ManifestHandler::Construct(InstallationContext* pContext)
+{
+ __pContext = pContext;
+ __pPackageInfoImpl = pContext->GetPackageInfoImpl();
+
+ return true;
+}
+
+bool
+ManifestHandler::Parse(const char *pFilepath)
+{
+ return ParseDocument(pFilepath);
+}
+
+bool
+ManifestHandler::OnStartElement(const char *pName)
+{
+ TryReturn(pName, true, "[osp-installer] pName is null.");
+
+ bool status = true;
+
+ if (strcasecmp(pName, "Manifest") == 0)
+ {
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "manifest.xml");
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "<%s>", pName);
+ }
+ else if (strcasecmp(pName, "UiApp") == 0)
+ {
+ status = OnUiAppElement();
+ }
+ else if (strcasecmp(pName, "ServiceApp") == 0)
+ {
+ status = OnServiceAppElement();
+ }
+ else if (strcasecmp(pName, "DataControl") == 0)
+ {
+ status = OnDataControlElement();
+ }
+ else if (strcasecmp(pName, "AppControl") == 0)
+ {
+ status = OnAppControlElement();
+ }
+ else if (strcasecmp(pName, "Capability") == 0)
+ {
+ status = OnCapabilityElement();
+ }
+ else if (strcasecmp(pName, "Resolution") == 0)
+ {
+ status = OnResolutionElement();
+ }
+ else if (strcasecmp(pName, "Privileges") == 0)
+ {
+ status = OnPrivilegesElement();
+ }
+ else if (strcasecmp(pName, "UiScalability") == 0)
+ {
+ status = OnUiScalabilityElement();
+ }
+ else if (strcasecmp(pName, "UiTheme") == 0)
+ {
+ status = OnUiThemeElement();
+ }
+ else if (strcasecmp(pName, "Icons") == 0)
+ {
+ status = OnIconsElement();
+ }
+
+ if (!status)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool
+ManifestHandler::OnEndElement(const char *pName)
+{
+ TryReturn(pName, true, "[osp-installer] pName is null.");
+
+ bool status = true;
+
+ if (strcasecmp(pName, "Privileges") == 0)
+ {
+ status = OnPrivilegesEndElement();
+ }
+ else if (strcasecmp(pName, "UiApp") == 0)
+ {
+ __pPackageInfoImpl->AddAppInfo(*__pPackageAppInfoImpl);
+ __pPackageAppInfoImpl = null;
+
+ __isDefaultName = false;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+ else if (strcasecmp(pName, "ServiceApp") == 0)
+ {
+ __pPackageInfoImpl->AddAppInfo(*__pPackageAppInfoImpl);
+ __pPackageAppInfoImpl = null;
+
+ __isDefaultName = false;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+
+ else if (strcasecmp(pName, "AppControl") == 0)
+ {
+ __pPackageAppInfoImpl->AddAppControl(__pAppControlInfoImpl);
+ __pAppControlInfoImpl = null;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+ else if (strcasecmp(pName, "DataControl") == 0)
+ {
+ __pPackageAppInfoImpl->AddDataControl(__pDataControlInfoImpl);
+ __pDataControlInfoImpl = null;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+ else if (strcasecmp(pName, "DataControlType") == 0)
+ {
+ __pDataControlInfoImpl->AddControlType(__pDataControlTypeImpl);
+ __pDataControlTypeImpl = null;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+ else if (strcasecmp(pName, "Condition") == 0)
+ {
+ __pPackageAppInfoImpl->AddLaunchCondition(*__pLaunchConditionImpl);
+ __pLaunchConditionImpl = null;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+ else if (strcasecmp(pName, "Notification") == 0)
+ {
+ __pPackageAppInfoImpl->AddNotification(*__pNotificationImpl);
+ __pNotificationImpl = null;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+ else if (strcasecmp(pName, "Capability") == 0)
+ {
+ if (__pAppControlInfoImpl)
+ {
+ __pAppControlInfoImpl->AddCapability(__pAppControlCapabilityInfoImpl);
+ __pAppControlCapabilityInfoImpl = null;
+ }
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+ else if (strcasecmp(pName, "Resolution") == 0)
+ {
+ __pAppControlCapabilityInfoImpl->AddResolution(__pAppControlResolutionInfoImpl);
+ __pAppControlResolutionInfoImpl = null;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+ else if (strcasecmp(pName, "Apps") == 0)
+ {
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ if (__isDefaultAppDetected == false)
+ {
+ fprintf(stderr, "__isDefaultAppDetected is false.\n");
+ }
+ TryReturn(__isDefaultAppDetected, false, "[osp-installer][Error] Default App is not detected...");
+ }
+ else if (strcasecmp(pName, "UiScalability") == 0)
+ {
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+ else if (strcasecmp(pName, "Icons") == 0)
+ {
+ delete[] __pDefaultIconType;
+ __pDefaultIconType = null;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+
+ if (!status)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool
+ManifestHandler::OnCharacters(const char *pCharacters)
+{
+ bool status = true;
+ char *pName = 0;
+
+ pName = GetElementName();
+ TryReturn(pName, false, "[osp-installer] pName is null.");
+
+ if (strcasecmp(pName, "Id") == 0)
+ {
+ status = OnIdValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "Version") == 0)
+ {
+ status = OnVersionValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "Type") == 0)
+ {
+ status = OnTypeValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "Url") == 0)
+ {
+ status = OnUrlValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "ApiVersion") == 0)
+ {
+ status = OnApiVersionValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "Secret") == 0)
+ {
+ status = OnSecretValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "Privilege") == 0)
+ {
+ status = OnPrivilegeValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "Name") == 0)
+ {
+ status = OnNameValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "Vendor") == 0)
+ {
+ status = OnVendorValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "Description") == 0)
+ {
+ status = OnDescriptionValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "Icon") == 0)
+ {
+ status = OnIconValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "DataControlType") == 0)
+ {
+ status = OnDataControlTypeValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "Condition") == 0)
+ {
+ status = OnConditionValue(pCharacters);
+ }
+ else if (strcasecmp(pName, "Notification") == 0)
+ {
+ status = OnNotificationValue(pCharacters);
+ }
+
+ if (!status)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool
+ManifestHandler::OnPrivilegesElement(void)
+{
+ __pPrivilegeList = new ArrayList;
+ TryReturn(__pPrivilegeList, false, "[osp-installer] __pPrivilegeList is null");
+
+ AppLogTag(OSP_INSTALLER, "<Privileges>");
+
+ return true;
+}
+
+bool
+ManifestHandler::OnPrivilegesEndElement(void)
+{
+ // signature.xml for beta
+ FileAttributes attr;
+ result r = E_SUCCESS;
+
+ r = File::GetAttributes(__pContext->GetSignatureXmlPath(), attr);
+ if (r != E_SUCCESS)
+ {
+ AppLogTag(OSP_INSTALLER, "Signature file is not existing. [%ls]\n", __pContext->GetSignatureXmlPath().GetPointer());
+
+ String privileges;
+ String hmacPrivileges;
+ String appId = __pPackageInfoImpl->GetAppId();
+ r = PrivilegeHandler::GenerateCipherPrivilege(appId, *__pPrivilegeList, privileges, hmacPrivileges);
+ if (IsFailed(r))
+ {
+ fprintf(stderr, "PrivilegeHandler::GenerateCipherPrivilege is failded. [%ls][%ls][%ls]\n", appId.GetPointer(), privileges.GetPointer(), hmacPrivileges.GetPointer());
+ }
+ TryReturn(!IsFailed(r), false, "[osp-installer] privMgr.GeneratePrivilegeString() failed");
+
+ __pPackageInfoImpl->SetPrivilegesValue(privileges, hmacPrivileges);
+ }
+
+ __pContext->SetPrivilegeList(__pPrivilegeList);
+
+ AppLogTag(OSP_INSTALLER, "</Privileges>");
+
+ return true;
+}
+
+bool
+ManifestHandler::OnUiScalabilityElement(void)
+{
+ XmlAttribute *pAttr = null;
+ char *pCoordinateSystem = null;
+ char *pBaseScreenSize = null;
+ char *pLogicalCoordinate = null;
+
+ AppLogTag(OSP_INSTALLER, "<UiScalability>");
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pCoordinateSystem = pAttr->Find("CoordinateSystem");
+ if (pCoordinateSystem)
+ {
+ _AppFeatureInfoImpl* pAppFeatureInfo = new _AppFeatureInfoImpl;
+ TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null");
+
+ pAppFeatureInfo->SetName("CoordinateSystem");
+ pAppFeatureInfo->SetValue(pCoordinateSystem);
+
+ __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo);
+
+ AppLogTag(OSP_INSTALLER, "<CoordinateSystem=%s>", pCoordinateSystem);
+ }
+
+ pBaseScreenSize = pAttr->Find("BaseScreenSize");
+ if (pBaseScreenSize)
+ {
+ _AppFeatureInfoImpl* pAppFeatureInfo = new _AppFeatureInfoImpl;
+ TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null");
+
+ pAppFeatureInfo->SetName("BaseScreenSize");
+ pAppFeatureInfo->SetValue(pBaseScreenSize);
+
+ __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo);
+
+ AppLogTag(OSP_INSTALLER, "<BaseScreenSize=%s>", pBaseScreenSize);
+ }
+
+ pLogicalCoordinate = pAttr->Find("LogicalCoordinate");
+ if (pLogicalCoordinate)
+ {
+ _AppFeatureInfoImpl* pAppFeatureInfo = new _AppFeatureInfoImpl;
+ TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null");
+
+ pAppFeatureInfo->SetName("LogicalCoordinate");
+ pAppFeatureInfo->SetValue(pLogicalCoordinate);
+
+ __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo);
+
+ AppLogTag(OSP_INSTALLER, "<LogicalCoordinate=%s>", pLogicalCoordinate);
+ }
+
+ return true;
+}
+
+bool
+ManifestHandler::OnUiThemeElement(void)
+{
+ XmlAttribute *pAttr = null;
+ char *pSystemTheme = null;
+ char *pUserDefinedTheme = null;
+
+ AppLogTag(OSP_INSTALLER, "<UiTheme>");
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pSystemTheme = pAttr->Find("SystemTheme");
+ if (pSystemTheme)
+ {
+ _AppFeatureInfoImpl* pAppFeatureInfo = new _AppFeatureInfoImpl;
+ TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null");
+
+ pAppFeatureInfo->SetName("SystemTheme");
+ pAppFeatureInfo->SetValue(pSystemTheme);
+
+ __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo);
+
+ AppLogTag(OSP_INSTALLER, "<SystemTheme=%s>", pSystemTheme);
+ }
+
+ pUserDefinedTheme = pAttr->Find("UserDefinedTheme");
+ if (pUserDefinedTheme)
+ {
+ _AppFeatureInfoImpl* pAppFeatureInfo = new _AppFeatureInfoImpl;
+ TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null");
+
+ pAppFeatureInfo->SetName("UserDefinedTheme");
+ pAppFeatureInfo->SetValue(pUserDefinedTheme);
+
+ __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo);
+
+ AppLogTag(OSP_INSTALLER, "<UserDefinedTheme=%s>", pUserDefinedTheme);
+ }
+
+ return true;
+}
+
+bool
+ManifestHandler::OnIconsElement(void)
+{
+ result r = E_SUCCESS;
+ int width = 0;
+ String defaultIconType;
+
+ AppLogTag(OSP_INSTALLER, "<Icons>");
+
+ r = _SystemInfoImpl::GetSysInfo(L"ScreenWidth", width);
+ if (IsFailed(r))
+ {
+ defaultIconType = L"Xhigh";
+ }
+ else
+ {
+ if (width == 480)
+ {
+ defaultIconType = L"High";
+ }
+ else
+ {
+ defaultIconType = L"Xhigh";
+ }
+ }
+
+ AppLogTag(OSP_INSTALLER, "ScreenWidth = [%d]", width);
+
+ __pDefaultIconType = _StringConverter::CopyToCharArrayN(defaultIconType);
+ TryReturn(__pDefaultIconType, false, "[osp-installer] __pDefaultIconType is null.");
+
+ AppLogTag(OSP_INSTALLER, "DefaultIconType = [%s]", __pDefaultIconType);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnIdValue(const char *pCharacters)
+{
+ __pPackageInfoImpl->SetAppId(pCharacters);
+ AppLogTag(OSP_INSTALLER, "<Id>%s</Id>", pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnVersionValue(const char *pCharacters)
+{
+ __pPackageInfoImpl->SetAppVersion(pCharacters);
+ AppLogTag(OSP_INSTALLER, "<Version>%s</Version>", pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnTypeValue(const char *pCharacters)
+{
+ __pPackageInfoImpl->SetAppType(pCharacters);
+ AppLogTag(OSP_INSTALLER, "<Type>%s</Type>", pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnUrlValue(const char *pCharacters)
+{
+ __pPackageInfoImpl->SetAppUrl(pCharacters);
+ AppLogTag(OSP_INSTALLER, "<Url>%s</Url>", pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnSecretValue(const char *pCharacters)
+{
+ __pPackageInfoImpl->SetAppSecret(pCharacters);
+ AppLogTag(OSP_INSTALLER, "<Secret>%s</Secret>", pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnApiVersionValue(const char *pCharacters)
+{
+ __pPackageInfoImpl->SetAppApiVersion(pCharacters);
+ AppLogTag(OSP_INSTALLER, "<ApiVersion>%s</ApiVersion>", pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnIconValue(const char *pCharacters)
+{
+ XmlAttribute *pAttr = 0;
+ char *pAttrValue1 = 0;
+ char *pAttrValue2 = 0;
+ char *pTypeValue = 0;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pAttrValue1 = pAttr->Find("Section");
+ TryReturn(pAttrValue1, true, "[osp-installer] pAttrValue1 is null");
+
+ pAttrValue2 = pAttr->Find("Size");
+ //TryReturn(pAttrValue2, true, "[osp-installer] pAttrValue2 is null");
+
+ pTypeValue = pAttr->Find("Type");
+ //TryReturn(pTypeValue, true, "[osp-installer] pTypeValue is null");
+
+ if (pTypeValue != null)
+ {
+ char icon[1024] = {0,};
+
+ if (strcasecmp(pTypeValue, "Xhigh") == 0)
+ {
+ snprintf(icon, sizeof(icon), "%s/%s", "screen-density-xhigh", pCharacters);
+ }
+ else if (strcasecmp(pTypeValue, "High") == 0)
+ {
+ snprintf(icon, sizeof(icon), "%s/%s", "screen-density-high", pCharacters);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "Invalid Type [%s]", __pDefaultIconType);
+ return false;
+ }
+
+ if (strcasecmp(pAttrValue1, "MainMenu") == 0)
+ {
+ if (__isDefaultMainmenu == false)
+ {
+ __pPackageAppInfoImpl->SetMainmenuIcon(icon);
+ }
+
+ if (strcasecmp(pTypeValue, __pDefaultIconType) == 0)
+ {
+ __isDefaultMainmenu = true;
+ }
+ }
+ else if (strcasecmp(pAttrValue1, "Setting") == 0)
+ {
+ if (__isDefaultSetting == false)
+ {
+ __pPackageAppInfoImpl->SetSettingIcon(icon);
+ }
+
+ if (strcasecmp(pTypeValue, __pDefaultIconType) == 0)
+ {
+ __isDefaultSetting = true;
+ }
+ }
+ else if (strcasecmp(pAttrValue1, "Notification") == 0)
+ {
+ if (__isDefaultQuickpanel == false)
+ {
+ __pPackageAppInfoImpl->SetQuickpanelIcon(icon);
+ }
+
+ if (strcasecmp(pTypeValue, __pDefaultIconType) == 0)
+ {
+ __isDefaultQuickpanel = true;
+ }
+ }
+
+ AppLogTag(OSP_INSTALLER, "<Icon Section=\"%s\" Type=\"%s\">%s</Icon>", pAttrValue1, pTypeValue, pCharacters);
+ }
+ else if (pAttrValue2 != null)
+ {
+ AppLogTag(OSP_INSTALLER, "Old Spec!! Icon spec is changed.");
+
+ if (strcasecmp(pAttrValue1, "MainMenu") == 0)
+ {
+ if (__isDefaultMainmenu == false)
+ {
+ __pPackageAppInfoImpl->SetMainmenuIcon(pCharacters);
+ }
+
+ if (strcasecmp(pAttrValue2, "type4") == 0)
+ {
+ __isDefaultMainmenu = true;
+ }
+ }
+ else if (strcasecmp(pAttrValue1, "Setting") == 0)
+ {
+ if (__isDefaultSetting == false)
+ {
+ __pPackageAppInfoImpl->SetSettingIcon(pCharacters);
+ }
+
+ if (strcasecmp(pAttrValue2, "type4") == 0)
+ {
+ __isDefaultSetting = true;
+ }
+ }
+ else if (strcasecmp(pAttrValue1, "Ticker") == 0)
+ {
+ if (__isDefaultTicker == false)
+ {
+ __pPackageAppInfoImpl->SetTickerIcon(pCharacters);
+ }
+
+ if (strcasecmp(pAttrValue2, "type4") == 0)
+ {
+ __isDefaultTicker = true;
+ }
+ }
+ else if (strcasecmp(pAttrValue1, "QuickPanel") == 0)
+ {
+ if (__isDefaultQuickpanel == false)
+ {
+ __pPackageAppInfoImpl->SetQuickpanelIcon(pCharacters);
+ }
+
+ if (strcasecmp(pAttrValue2, "type4") == 0)
+ {
+ __isDefaultQuickpanel = true;
+ }
+ }
+ else if (strcasecmp(pAttrValue1, "LaunchImage") == 0)
+ {
+ if (__isDefaultLaunchImage == false)
+ {
+ __pPackageAppInfoImpl->SetLaunchImageIcon(pCharacters);
+ }
+
+ if (strcasecmp(pAttrValue2, "type4") == 0)
+ {
+ __isDefaultLaunchImage = true;
+ }
+ }
+
+ AppLogTag(OSP_INSTALLER, "<Icon Section=\"%s\" Size=\"%s\">%s</Icon>", pAttrValue1, pAttrValue2, pCharacters);
+ }
+
+ return true;
+}
+
+bool
+ManifestHandler::OnPrivilegeValue(const char *pCharacters)
+{
+ __pPrivilegeList->Add(*new String(pCharacters));
+ AppLogTag(OSP_INSTALLER, "<Privilege>%s</Privilege>", pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnNameValue(const char *pCharacters)
+{
+ XmlAttribute *pAttr = 0;
+ char *pAttrValue = 0;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pAttrValue = pAttr->Find("Locale");
+ TryReturn(pAttrValue, true, "[osp-installer] pAttrValue is null");
+
+ if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
+ {
+ if (__isDefaultName == true)
+ {
+ __pPackageInfoImpl->SetAppName(pCharacters);
+ }
+ }
+
+ if (__pPackageAppInfoImpl)
+ {
+ String* pValue = new String;
+ StringUtil::Utf8ToString(pCharacters, *pValue);
+ __pPackageAppInfoImpl->AddName(*(new String(pAttrValue)), *pValue);
+ }
+
+ AppLogTag(OSP_INSTALLER, "<Name Locale=\"%s\">%s</Name>", pAttrValue, pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnVendorValue(const char *pCharacters)
+{
+ XmlAttribute *pAttr = 0;
+ char *pAttrValue = 0;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pAttrValue = pAttr->Find("Locale");
+ TryReturn(pAttrValue, true, "[osp-installer] pAttrValue is null");
+
+ if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
+ {
+ // Set default name
+ __pPackageInfoImpl->SetAppVendor(pCharacters);
+ }
+
+ AppLogTag(OSP_INSTALLER, "<Vendor Locale=\"%s\">%s</Vendor>", pAttrValue, pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnDescriptionValue(const char *pCharacters)
+{
+ XmlAttribute *pAttr = 0;
+ char *pAttrValue = 0;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pAttrValue = pAttr->Find("Locale");
+ TryReturn(pAttrValue, true, "[osp-installer] pAttrValue is null");
+
+ if (strcasecmp(pAttrValue, "eng-GB") == 0 || strcasecmp(pAttrValue, "eng-US") == 0)
+ {
+ // Set default name
+ __pPackageInfoImpl->SetAppDescription(pCharacters);
+ }
+
+ AppLogTag(OSP_INSTALLER, "<Description Locale=\"%s\">%s</Description>", pAttrValue, pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnDataControlTypeValue(const char *pCharacters)
+{
+ XmlAttribute *pAttr = null;
+ char *pAccessValue = null;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pAccessValue = pAttr->Find("Access");
+ TryReturn(pAccessValue, true, "[osp-installer] pAccessValue is null");
+
+ __pDataControlTypeImpl = new _DataControlTypeImpl;
+ TryReturn(__pDataControlTypeImpl, false, "[osp-installer] __pDataControlTypeImpl is null");
+
+ __pDataControlTypeImpl->SetType(pCharacters);
+ __pDataControlTypeImpl->SetAccess(pAccessValue);
+
+ AppLogTag(OSP_INSTALLER, "<DataControlType Access=\"%s\", Type=\"%s\">", pAccessValue, pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnConditionValue(const char *pCharacters)
+{
+ XmlAttribute *pAttr = null;
+ char *pName = null;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pName = pAttr->Find("Name");
+ TryReturn(pName, true, "[osp-installer] pName is null");
+
+ __pLaunchConditionImpl = new _LaunchConditionInfoImpl;
+ TryReturn(__pLaunchConditionImpl, false, "[osp-installer] __pLaunchConditionImpl is null");
+
+ __pLaunchConditionImpl->SetName(pName);
+ __pLaunchConditionImpl->SetValue(pCharacters);
+
+ AppLogTag(OSP_INSTALLER, "<LaunchCondition Name=\"%s\", Value=\"%s\">", pName, pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnNotificationValue(const char *pCharacters)
+{
+ XmlAttribute *pAttr = null;
+ char *pName = null;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pName = pAttr->Find("Name");
+ TryReturn(pName, true, "[osp-installer] pName is null");
+
+ __pNotificationImpl = new _NotificationInfoImpl;
+ TryReturn(__pNotificationImpl, false, "[osp-installer] __pNotificationImpl is null");
+
+ __pNotificationImpl->SetName(pName);
+ __pNotificationImpl->SetValue(pCharacters);
+
+ AppLogTag(OSP_INSTALLER, "<Notification Name=\"%s\", Value=\"%s\">", pName, pCharacters);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnAppControlElement(void)
+{
+ XmlAttribute *pAttr = null;
+ char *pAttrValue1 = null;
+ char *pAttrValue2 = null;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pAttrValue1 = pAttr->Find("ProviderId");
+ TryReturn(pAttrValue1, true, "[osp-installer] pAttrValue1 is null");
+
+ pAttrValue2 = pAttr->Find("Category");
+ TryReturn(pAttrValue2, true, "[osp-installer] pAttrValue2 is null");
+
+ __pAppControlInfoImpl = new _AppControlInfoImpl;
+ TryReturn(__pAppControlInfoImpl, false, "[osp-installer] __pAppControlInfoImpl is null");
+
+ __pAppControlInfoImpl->SetProviderId(pAttrValue1);
+ __pAppControlInfoImpl->SetCategory(pAttrValue2);
+
+ AppLogTag(OSP_INSTALLER, "<AppControl ProviderId=\"%s\" Category=\"%s\">", pAttrValue1, pAttrValue2);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnCapabilityElement(void)
+{
+ XmlAttribute *pAttr = null;
+ char *pAttrValue = null;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pAttrValue = pAttr->Find("OperationId");
+ TryReturn(pAttrValue, true, "[osp-installer] pAttrValue1 is null");
+
+ __pAppControlCapabilityInfoImpl = new _AppControlCapabilityInfoImpl;
+ TryReturn(__pAppControlCapabilityInfoImpl, false, "[osp-installer] __pAppControlCapabilityInfoImpl is null");
+
+ __pAppControlCapabilityInfoImpl->SetOperationId(pAttrValue);
+
+ AppLogTag(OSP_INSTALLER, "<Capability OperationId=\"%s\">", pAttrValue);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnResolutionElement(void)
+{
+ XmlAttribute *pAttr = null;
+ char *pAttrValue1 = null;
+ char *pAttrValue2 = null;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pAttrValue1 = pAttr->Find("MimeType");
+ pAttrValue2 = pAttr->Find("UriScheme");
+
+ __pAppControlResolutionInfoImpl = new _AppControlResolutionInfoImpl;
+ TryReturn(__pAppControlResolutionInfoImpl, false, "[osp-installer] __pAppControlResolutionInfoImpl is null");
+
+ if (pAttrValue1)
+ {
+ String* pMimeType = new String(pAttrValue1);
+ __pAppControlResolutionInfoImpl->SetMimeType(pMimeType);
+ }
+
+ if (pAttrValue2)
+ {
+ String* pUriScheme = new String(pAttrValue2);
+ __pAppControlResolutionInfoImpl->SetUriScheme(pUriScheme);
+ }
+
+ AppLogTag(OSP_INSTALLER, "<Resolution MimeType=\"%s\" UriScheme=\"%s\">", pAttrValue1, pAttrValue2);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnDataControlElement(void)
+{
+ XmlAttribute *pAttr = null;
+ char *pProviderId = null;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pProviderId = pAttr->Find("ProviderId");
+ TryReturn(pProviderId, true, "[osp-installer] pProviderId is null");
+
+ __pDataControlInfoImpl = new _DataControlInfoImpl;
+ TryReturn(__pDataControlInfoImpl, false, "[osp-installer] __pDataControlInfoImpl is null");
+
+ __pDataControlInfoImpl->SetProviderId(pProviderId);
+
+ AppLogTag(OSP_INSTALLER, "<DataControl ProviderId=\"%s\">", pProviderId);
+
+ return true;
+}
+
+bool
+ManifestHandler::OnUiAppElement(void)
+{
+ XmlAttribute *pAttr = null;
+ char *pExecutableName = null;
+ char *pDefault = null;
+ char *pMainmenuVisible = null;
+
+ __pPackageAppInfoImpl = new _PackageAppInfoImpl;
+ TryReturn(__pPackageAppInfoImpl, false, "[osp-installer] __pPackageAppInfoImpl is null");
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pExecutableName = pAttr->Find("ExecutableName");
+ if (pExecutableName == null)
+ {
+ pExecutableName = pAttr->Find("Name");
+ }
+ TryReturn(pExecutableName, true, "[osp-installer] pExecutableName is null");
+
+ __pPackageAppInfoImpl->SetName(pExecutableName);
+
+ pDefault = pAttr->Find("Default");
+ if (pDefault)
+ {
+ __pPackageAppInfoImpl->SetDefault(pDefault);
+
+ if (strcasecmp(pDefault, "True") == 0)
+ {
+ __isDefaultName = true;
+ __isDefaultAppDetected = true;
+ }
+ }
+ else
+ {
+ __pPackageAppInfoImpl->SetDefault("False");
+ }
+
+ __pPackageAppInfoImpl->SetType("UiApp");
+
+ pMainmenuVisible = pAttr->Find("MainmenuVisible");
+ if (pMainmenuVisible)
+ {
+ if (strcasecmp(pMainmenuVisible, "True") == 0)
+ {
+ __pPackageAppInfoImpl->SetMainmenuVisible(true);
+ }
+ else
+ {
+ __pPackageAppInfoImpl->SetMainmenuVisible(false);
+ }
+
+ _AppFeatureInfoImpl* pAppFeatureInfo = new _AppFeatureInfoImpl;
+ TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null");
+
+ pAppFeatureInfo->SetName("MainmenuVisible");
+ pAppFeatureInfo->SetValue(pMainmenuVisible);
+ __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo);
+
+ AppLogTag(OSP_INSTALLER, "<MainmenuVisible=%s>", pMainmenuVisible);
+ }
+
+ String app_id;
+
+ if (__pContext->GetPackageNameType() == INSTALLER_PREFIX_TYPE_ORG)
+ {
+ app_id.Format(1024, PACKAGE_NAME_RULE_ORG, __pPackageInfoImpl->GetAppId().GetPointer(), pExecutableName);
+ }
+ else
+ {
+ app_id.Format(1024, PACKAGE_NAME_RULE, __pPackageInfoImpl->GetAppId().GetPointer(), pExecutableName);
+ }
+
+ __pPackageAppInfoImpl->SetPackageName(app_id);
+
+ AppLogTag(OSP_INSTALLER, "app_id = %S", app_id.GetPointer());
+ AppLogTag(OSP_INSTALLER, "<UiApp Name=\"%s\" Default=\"%s\">", pExecutableName, pDefault ? pDefault:"False");
+
+ return true;
+}
+
+bool
+ManifestHandler::OnServiceAppElement(void)
+{
+ XmlAttribute *pAttr = null;
+ char *pExecutableName = null;
+ char *pDefault = null;
+ char *pMainmenuVisible = null;
+ char *pLaunchOnBoot = null;
+ char *pAutoRestart = null;
+ char *pRemoteUi = null;
+
+ __pPackageAppInfoImpl = new _PackageAppInfoImpl;
+ TryReturn(__pPackageAppInfoImpl, false, "[osp-installer] __pPackageAppInfoImpl is null");
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "pAttr is null");
+
+ pExecutableName = pAttr->Find("ExecutableName");
+ if (pExecutableName == null)
+ {
+ pExecutableName = pAttr->Find("Name");
+ }
+ TryReturn(pExecutableName, true, "[osp-installer] pExecutableName is null");
+
+ __pPackageAppInfoImpl->SetName(pExecutableName);
+
+ pDefault = pAttr->Find("Default");
+ if (pDefault)
+ {
+ __pPackageAppInfoImpl->SetDefault(pDefault);
+
+ if (strcasecmp(pDefault, "True") == 0)
+ {
+ __isDefaultName = true;
+ __isDefaultAppDetected = true;
+ }
+ }
+ else
+ {
+ __pPackageAppInfoImpl->SetDefault("False");
+ }
+
+ __pPackageAppInfoImpl->SetType("ServiceApp");
+ __pPackageAppInfoImpl->SetMainmenuVisible(false);
+
+ pMainmenuVisible = pAttr->Find("MainmenuVisible");
+ if (pMainmenuVisible)
+ {
+ _AppFeatureInfoImpl* pAppFeatureInfo = new _AppFeatureInfoImpl;
+ TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null");
+
+ pAppFeatureInfo->SetName("MainmenuVisible");
+ pAppFeatureInfo->SetValue(pMainmenuVisible);
+ __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo);
+
+ AppLogTag(OSP_INSTALLER, "<MainmenuVisible=%s>", pMainmenuVisible);
+ }
+
+ pLaunchOnBoot = pAttr->Find("LaunchOnBoot");
+ if (pLaunchOnBoot)
+ {
+ _AppFeatureInfoImpl* pAppFeatureInfo = new _AppFeatureInfoImpl;
+ TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null");
+
+ pAppFeatureInfo->SetName("LaunchOnBoot");
+ pAppFeatureInfo->SetValue(pLaunchOnBoot);
+
+ __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo);
+
+ AppLogTag(OSP_INSTALLER, "<LaunchOnBoot=%s>", pLaunchOnBoot);
+ }
+
+ pAutoRestart = pAttr->Find("AutoRestart");
+ if (pAutoRestart)
+ {
+ _AppFeatureInfoImpl* pAppFeatureInfo = new _AppFeatureInfoImpl;
+ TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null");
+
+ pAppFeatureInfo->SetName("AutoRestart");
+ pAppFeatureInfo->SetValue(pAutoRestart);
+
+ __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo);
+
+ AppLogTag(OSP_INSTALLER, "<AutoRestart=%s>", pAutoRestart);
+ }
+
+ pRemoteUi = pAttr->Find("RemoteUi");
+ if (pRemoteUi)
+ {
+ _AppFeatureInfoImpl* pAppFeatureInfo = new _AppFeatureInfoImpl;
+ TryReturn(pAppFeatureInfo, false, "[osp-installer] pAppFeatureInfo is null");
+
+ pAppFeatureInfo->SetName("RemoteUi");
+ pAppFeatureInfo->SetValue(pRemoteUi);
+
+ __pPackageAppInfoImpl->AddAppFeature(*pAppFeatureInfo);
+
+ AppLogTag(OSP_INSTALLER, "<RemoteUi=%s>", pRemoteUi);
+ }
+
+ String app_id;
+
+ if (__pContext->GetPackageNameType() == INSTALLER_PREFIX_TYPE_ORG)
+ {
+ app_id.Format(1024, PACKAGE_NAME_RULE_ORG, __pPackageInfoImpl->GetAppId().GetPointer(), pExecutableName);
+ }
+ else
+ {
+ app_id.Format(1024, PACKAGE_NAME_RULE, __pPackageInfoImpl->GetAppId().GetPointer(), pExecutableName);
+ }
+
+ __pPackageAppInfoImpl->SetPackageName(app_id);
+
+ AppLogTag(OSP_INSTALLER, "app_id = %S", app_id.GetPointer());
+ AppLogTag(OSP_INSTALLER, "<ServiceApp Name=\"%s\" Default=\"%s\">", pExecutableName, pDefault ? pDefault:"False");
+
+ return true;
+}
diff --git a/src/XmlHandler/ManifestHandler.h b/src/XmlHandler/ManifestHandler.h
new file mode 100755
index 0000000..af44055
--- /dev/null
+++ b/src/XmlHandler/ManifestHandler.h
@@ -0,0 +1,109 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file ManifestHandler.h
+ * @brief This is the header file for the %ManifestHandler class.
+ *
+ * This header file contains the declarations of the %ManifestHandler class.
+ */
+#ifndef _MANIFEST_HANDLER_H_
+#define _MANIFEST_HANDLER_H_
+
+#include <FAppPackageInfo.h>
+
+#include "XmlHandler.h"
+#include "InstallationContext.h"
+
+/**
+ * @class ManifestHandler
+ * @brief This class represents the class of ManifestHandler.
+ * @since 1.0
+ *
+ * This class represents the class of ManifestHandler.
+ *
+ */
+class ManifestHandler
+ : public XmlHandler
+{
+public:
+ ManifestHandler(void);
+ virtual ~ManifestHandler(void);
+
+ bool Construct(InstallationContext *pConext);
+ bool Parse(const char *pFilepath);
+
+private:
+ ManifestHandler(const ManifestHandler& value);
+ ManifestHandler& operator =(const ManifestHandler& source);
+
+ virtual bool OnStartElement(const char *pName);
+ virtual bool OnEndElement(const char *pName);
+ virtual bool OnCharacters(const char *pCharacters);
+ bool OnPrivilegesElement(void);
+ bool OnPrivilegesEndElement(void);
+ bool OnUiScalabilityElement(void);
+ bool OnUiThemeElement(void);
+ bool OnIconsElement(void);
+
+ bool OnIdValue(const char *pCharacters);
+ bool OnVersionValue(const char *pCharacters);
+ bool OnTypeValue(const char *pCharacters);
+ bool OnUrlValue(const char *pCharacters);
+ bool OnSecretValue(const char *pCharacters);
+ bool OnMimeTypeValue(const char *pCharacters);
+ bool OnApiVersionValue(const char *pCharacters);
+ bool OnIconValue(const char *pCharacters);
+ bool OnPrivilegeValue(const char *pCharacters);
+ bool OnNameValue(const char *pCharacters);
+ bool OnVendorValue(const char *pCharacters);
+ bool OnDescriptionValue(const char *pCharacters);
+ bool OnDataControlTypeValue(const char *pCharacters);
+ bool OnConditionValue(const char *pCharacters);
+ bool OnNotificationValue(const char *pCharacters);
+
+ bool OnAppControlElement(void);
+ bool OnCapabilityElement(void);
+ bool OnResolutionElement(void);
+ bool OnDataControlElement(void);
+ bool OnUiAppElement(void);
+ bool OnServiceAppElement(void);
+
+private:
+ InstallationContext* __pContext;
+ Osp::Base::Collection::ArrayList* __pPrivilegeList;
+ Osp::App::_PackageInfoImpl* __pPackageInfoImpl;
+ Osp::App::_PackageAppInfoImpl* __pPackageAppInfoImpl;
+ Osp::App::_AppControlInfoImpl* __pAppControlInfoImpl;
+ Osp::App::_AppControlCapabilityInfoImpl* __pAppControlCapabilityInfoImpl;
+ Osp::App::_AppControlResolutionInfoImpl* __pAppControlResolutionInfoImpl;
+ Osp::App::_DataControlInfoImpl* __pDataControlInfoImpl;
+ Osp::App::_DataControlTypeImpl* __pDataControlTypeImpl;
+ Osp::App::_LaunchConditionInfoImpl* __pLaunchConditionImpl;
+ Osp::App::_NotificationInfoImpl* __pNotificationImpl;
+ char* __pDefaultIconType;
+
+ bool __isDefaultMainmenu;
+ bool __isDefaultSetting;
+ bool __isDefaultTicker;
+ bool __isDefaultQuickpanel;
+ bool __isDefaultLaunchImage;
+ bool __isDefaultName;
+ bool __isDefaultAppDetected;
+
+}; // ManifestHandler
+
+#endif // _MANIFEST_HANDLER_H_
diff --git a/src/XmlHandler/PrivilegeHandler.cpp b/src/XmlHandler/PrivilegeHandler.cpp
new file mode 100755
index 0000000..9f8c216
--- /dev/null
+++ b/src/XmlHandler/PrivilegeHandler.cpp
@@ -0,0 +1,399 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file PrivilegeHandler.cpp
+ * @brief This is the implementation for the PrivilegeHandler class.
+ */
+
+#include <stdlib.h>
+
+#include <FBaseString.h>
+#include <FBaseSysLog.h>
+#include <FSecCryptoAesCipher.h>
+#include <FSecCryptoSha1Hmac.h>
+#include <FBase_StringConverter.h>
+#include <FSec_AccessControlTypes.h>
+#include <FSec_DeviceKeyGenerator.h>
+
+#include "PrivilegeHandler.h"
+
+using namespace Osp::App;
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::Base::Utility;
+using namespace Osp::Security;
+using namespace Osp::Security::Crypto;
+using namespace Osp::Text;
+
+result
+PrivilegeHandler::GenerateCipherPrivilege(const AppId& appId, const IList& privilegeList, String& encryptedPrivileges, String& checksum)
+{
+ result r = E_SUCCESS;
+ byte* pBitwisePrivilege = null;
+ int count = 0;
+
+ SysLog(NID_SEC, "Enter.");
+
+ encryptedPrivileges.Clear();
+ checksum.Clear();
+
+ count = privilegeList.GetCount();
+ if (count == 0)
+ {
+ goto CATCH;
+ }
+
+ pBitwisePrivilege = PackPrivilegeN(privilegeList);
+ SysTryReturnResult(NID_SEC, pBitwisePrivilege != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ r = GetEncryptedBitwise(pBitwisePrivilege, encryptedPrivileges);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ r = GetChecksum(appId, pBitwisePrivilege, checksum);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ // fall through
+
+CATCH:
+
+ if (pBitwisePrivilege)
+ {
+ free(pBitwisePrivilege);
+ }
+
+ SysLog(NID_SEC, "Exit.");
+ return r;
+}
+
+result
+PrivilegeHandler::GenerateCipherPrivilege(const AppId& appId, const IList& privilegeList, int visibilityLevel, String& encryptedPrivileges, String& checksum)
+{
+ result r = E_SUCCESS;
+ byte* pBitwisePrivilege = null;
+ int count = 0;
+
+ SysLog(NID_SEC, "Enter.");
+
+ encryptedPrivileges.Clear();
+ checksum.Clear();
+
+ count = privilegeList.GetCount();
+ if (count == 0)
+ {
+ goto CATCH;
+ }
+
+ r = PackPrivilegeN(privilegeList, visibilityLevel, &pBitwisePrivilege);
+ SysTryReturnResult(NID_SEC, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = GetEncryptedBitwise(pBitwisePrivilege, encryptedPrivileges);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ r = GetChecksum(appId, pBitwisePrivilege, checksum);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ // fall through
+
+CATCH:
+
+ if (pBitwisePrivilege)
+ {
+ free(pBitwisePrivilege);
+ }
+
+ SysLog(NID_SEC, "Exit.");
+ return r;
+}
+
+byte*
+PrivilegeHandler::PackPrivilegeN(const IList& privilegeList)
+{
+ result r = E_SUCCESS;
+ int index = 0;
+ int privilegeEnum = 0;
+ int position = 0;
+ bool validStringFlag = false;
+ bool resultFlag = true;
+ byte privilegeBit = 0;
+ byte* pResult = null;
+ byte* pBitwisePrivilege = null;
+ IEnumerator* pEnum = null;
+
+ SysLog(NID_SEC, "Enter.");
+ ClearLastResult();
+
+ pResult = (byte*) malloc(sizeof(byte) * MAX_BITWISE_PRIV_SIZE);
+ SysTryReturn(NID_SEC, pResult != null, null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ memset(pResult, 0, MAX_BITWISE_PRIV_SIZE);
+
+ pEnum = privilegeList.GetEnumeratorN();
+ SysTryCatch(NID_SEC, pEnum != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ validStringFlag = false;
+
+ String* pTempString = (String*) pEnum->GetCurrent();
+ for (index = 0; index < _MAX_PRIVILEGE_ENUM; index++)
+ {
+ if (wcscmp(privilegeListTable[index].privilegeString, pTempString->GetPointer()) == 0)
+ {
+ validStringFlag = true;
+ privilegeEnum = static_cast< int >(privilegeListTable[index].privilege);
+
+ position = privilegeEnum / _BITS_IN_BYTE;
+ privilegeBit = (byte) (privilegeEnum % _BITS_IN_BYTE);
+ pResult[position] = pResult[position] | (1 << privilegeBit);
+ break;
+ }
+ }
+
+ if (validStringFlag == false)
+ {
+ SysLogException(NID_SEC, E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", pTempString->GetPointer());
+ resultFlag = false;
+ }
+ }
+
+ SysTryCatch(NID_SEC, resultFlag == true, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] One of privilege string is invalid.");
+
+ pBitwisePrivilege = pResult;
+
+ delete pEnum;
+
+ SysLog(NID_SEC, "Exit.");
+ return pBitwisePrivilege;
+
+CATCH:
+
+ delete pEnum;
+
+ if (pResult)
+ {
+ free(pResult);
+ }
+
+ SysLog(NID_SEC, "Exit.");
+ return null;
+}
+
+result
+PrivilegeHandler::PackPrivilegeN(const IList& privilegeList, int visibilityLevel, byte** ppBitwisePrivilege)
+{
+ result r = E_SUCCESS;
+ int index = 0;
+ int privilegeEnum = 0;
+ int position = 0;
+ bool validStringFlag = false;
+ bool validLevelFlag = true;
+ bool resultFlag = true;
+ byte privilegeBit = 0;
+ byte* pResult = null;
+ IEnumerator* pEnum = null;
+
+ SysLog(NID_SEC, "Enter.");
+ ClearLastResult();
+
+ pResult = (byte*) malloc(sizeof(byte) * MAX_BITWISE_PRIV_SIZE);
+ SysTryReturn(NID_SEC, pResult != null, null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ memset(pResult, 0, MAX_BITWISE_PRIV_SIZE);
+
+ pEnum = privilegeList.GetEnumeratorN();
+ SysTryCatch(NID_SEC, pEnum != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ validStringFlag = false;
+ validLevelFlag = true;
+
+ String* pTempString = (String*) pEnum->GetCurrent();
+ for (index = 0; index < _MAX_PRIVILEGE_ENUM; index++)
+ {
+ if (wcscmp(privilegeListTable[index].privilegeString, pTempString->GetPointer()) == 0)
+ {
+ validStringFlag = true;
+ privilegeEnum = static_cast< int >(privilegeListTable[index].privilege);
+
+ if (visibilityLevel != _VSB_LEVEL_NONE)
+ {
+ if (visibilityLevelListTable[privilegeEnum][_PRV_API_VER_3_0] > visibilityLevel)
+ {
+ validLevelFlag = false;
+ break;
+ }
+ }
+
+ position = privilegeEnum / _BITS_IN_BYTE;
+ privilegeBit = (byte) (privilegeEnum % _BITS_IN_BYTE);
+ pResult[position] = pResult[position] | (1 << privilegeBit);
+ break;
+ }
+ }
+
+ if (validStringFlag == false)
+ {
+ SysLogException(NID_SEC, E_INVALID_ARG, "[E_INVALID_ARG] Invalid privilege string : %ls", pTempString->GetPointer());
+ resultFlag = false;
+ }
+
+ if (validLevelFlag == false)
+ {
+ SysLogException(NID_SEC, E_INVALID_ARG, "[E_INVALID_ARG] The application does not have the privilege to register %ls", pTempString->GetPointer());
+ resultFlag = false;
+ }
+ }
+
+ SysTryCatch(NID_SEC, resultFlag == true, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] One of privilege string is invalid.");
+
+ *ppBitwisePrivilege = pResult;
+
+ delete pEnum;
+
+ SysLog(NID_SEC, "Exit.");;
+ return r;
+
+CATCH:
+
+ delete pEnum;
+
+ if (pResult)
+ {
+ free(pResult);
+ }
+
+ SysLog(NID_SEC, "Exit.");
+ return r;
+}
+
+
+result
+PrivilegeHandler::GetEncryptedBitwise(byte* pBitwisePrivilege, String& encryptedPrivileges)
+{
+ result r = E_SUCCESS;
+ ISecretKey* pKey = null;
+ ByteBuffer ivByte;
+ ByteBuffer* pEncryptedBitwisePrivilege = null;
+ ByteBuffer* pTempBitwisePrivilege = null;
+ AesCipher cipherEnc;
+ const byte ivector[_IV_LEN] = { 0x3E, 0xB5, 0x01, 0x45, 0xE4, 0xF8, 0x75, 0x3F, 0x08, 0x9D, 0x9F, 0x57, 0x3B, 0x63, 0xEF, 0x4B};
+
+ SysLog(NID_SEC, "Enter.");
+
+ pTempBitwisePrivilege = new (std::nothrow) ByteBuffer();
+ SysTryReturnResult(NID_SEC, pTempBitwisePrivilege != null, E_OUT_OF_MEMORY, "Memory allocation is failed.");
+
+ r = pTempBitwisePrivilege->Construct(MAX_BITWISE_PRIV_SIZE);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ r = ivByte.Construct(_IV_LEN);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ r = ivByte.SetArray(ivector, 0, _IV_LEN);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+ ivByte.Flip();
+
+ r = pTempBitwisePrivilege->SetArray(pBitwisePrivilege, 0, MAX_BITWISE_PRIV_SIZE);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+ pTempBitwisePrivilege->Flip();
+
+ r = cipherEnc.Construct(L"CBC/128/PKCS7PADDING", CIPHER_ENCRYPT);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ pKey = _DeviceKeyGenerator::GenerateDeviceKeyN(_KEY_LEN);
+ SysTryCatch(NID_SEC, pKey != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ r = cipherEnc.SetKey(*pKey);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ r = cipherEnc.SetInitialVector(ivByte);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ pEncryptedBitwisePrivilege = cipherEnc.EncryptN(*pTempBitwisePrivilege);
+ SysTryCatch(NID_SEC, pEncryptedBitwisePrivilege != null, r = E_SYSTEM, E_SYSTEM,
+ "[E_SYSTEM] An unexpected system error occurred.");
+
+ r = StringUtil::EncodeToBase64String(*pEncryptedBitwisePrivilege, encryptedPrivileges);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ // fall through
+
+CATCH:
+
+ delete pTempBitwisePrivilege;
+ delete pKey;
+ delete pEncryptedBitwisePrivilege;
+
+ SysLog(NID_SEC, "Exit.");
+ return r;
+}
+
+result
+PrivilegeHandler::GetChecksum(AppId appId, byte* pBitwisePrivilege, String& checksum)
+{
+ result r = E_SUCCESS;
+ byte tempChecksumString[MAX_BITWISE_PRIV_SIZE + MAX_APP_ID_SIZE];
+
+ ISecretKey* pKey = null;
+ ByteBuffer ivByte;
+ ByteBuffer input;
+ IHmac* pHmac = null;
+ ByteBuffer* pChecksumByteBuffer = null;
+ char* pAppId = null;
+
+ pAppId = (char*) _StringConverter::CopyToCharArrayN(appId);
+ SysTryCatch(NID_SEC, pAppId != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ memcpy(tempChecksumString, pAppId, MAX_APP_ID_SIZE);
+ memcpy(tempChecksumString + MAX_APP_ID_SIZE, pBitwisePrivilege, MAX_BITWISE_PRIV_SIZE);
+
+ delete[] pAppId;
+ pAppId = null;
+
+ r = input.Construct(MAX_APP_ID_SIZE + MAX_BITWISE_PRIV_SIZE);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ r = input.SetArray(tempChecksumString, 0, MAX_APP_ID_SIZE + MAX_BITWISE_PRIV_SIZE);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+ input.Flip();
+
+ pHmac = new (std::nothrow) Sha1Hmac();
+ SysTryCatch(NID_SEC, pHmac != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed.");
+
+ pKey = _DeviceKeyGenerator::GenerateDeviceKeyN(_KEY_LEN);
+ SysTryCatch(NID_SEC, pKey != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ r = pHmac->SetKey(*pKey);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ pChecksumByteBuffer = pHmac->GetHmacN(input);
+ SysTryCatch(NID_SEC, pChecksumByteBuffer != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ r = StringUtil::EncodeToBase64String(*pChecksumByteBuffer, checksum);
+ SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
+
+ // fall through
+
+CATCH:
+
+ delete pKey;
+ delete pHmac;
+ delete pChecksumByteBuffer;
+
+ return r;
+}
diff --git a/src/XmlHandler/PrivilegeHandler.h b/src/XmlHandler/PrivilegeHandler.h
new file mode 100644
index 0000000..af88ccb
--- /dev/null
+++ b/src/XmlHandler/PrivilegeHandler.h
@@ -0,0 +1,61 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file PrivilegeHandler.h
+ * @brief This is the header file for the PrivilegeHandler class.
+ *
+ * This header file contains the declarations of the PrivilegeHandler class.
+ */
+
+#ifndef _PRIVILEGE_HANDLER_H_
+#define _PRIVILEGE_HANDLER_H_
+
+#include <FSec_AccessControlTypes.h>
+
+namespace Osp { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Osp { namespace Base
+{
+class String;
+}}
+
+/**
+ * @class PrivilegeHandler
+ * @brief This class represents the class of PrivilegeHandler.
+ * @since 3.0
+ *
+ * This class represents the class of PrivilegeHandler.
+ *
+ */
+class PrivilegeHandler
+{
+
+public:
+ static result GenerateCipherPrivilege(const Osp::App::AppId& appId, const Osp::Base::Collection::IList& privilegeList, Osp::Base::String& encryptedPrivileges, Osp::Base::String& checksum);
+ static result GenerateCipherPrivilege(const Osp::App::AppId& appId, const Osp::Base::Collection::IList& privilegeList, int visibilityLevel, Osp::Base::String& encryptedPrivileges, Osp::Base::String& checksum);
+private:
+ static byte* PackPrivilegeN(const Osp::Base::Collection::IList& privilegeList);
+ static result PackPrivilegeN(const Osp::Base::Collection::IList& privilegeList, int visibilityLevel, byte** ppBitwisePrivilege);
+ static result GetEncryptedBitwise(byte* __bitwisePrivilege, Osp::Base::String& encryptedPrivileges);
+ static result GetChecksum(Osp::App::AppId appId, byte* __bitwisePrivilege, Osp::Base::String& checksum);
+
+}; // PrivilegeHandler
+
+#endif // _PRIVILEGE_HANDLER_H_
diff --git a/src/XmlHandler/SignatureHandler.cpp b/src/XmlHandler/SignatureHandler.cpp
new file mode 100755
index 0000000..0b60282
--- /dev/null
+++ b/src/XmlHandler/SignatureHandler.cpp
@@ -0,0 +1,222 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file SignatureHandler.cpp
+ * @brief This is the implementation file for %SignatureHandler class.
+ */
+
+#include "SignatureHandler.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+
+SignatureHandler::SignatureHandler(void)
+:__pContext(null)
+,__pAuthorCertChain(null)
+,__pDistributorCertChain(null)
+,__isAuthorSignature(false)
+,__isDistributorSignature(false)
+{
+}
+
+SignatureHandler::~SignatureHandler(void)
+{
+ if (__pAuthorCertChain)
+ {
+ __pAuthorCertChain->RemoveAll(true);
+ delete __pAuthorCertChain;
+ }
+
+ if (__pDistributorCertChain)
+ {
+ __pDistributorCertChain->RemoveAll(true);
+ delete __pDistributorCertChain;
+ }
+}
+
+bool
+SignatureHandler::Construct(InstallationContext* pContext)
+{
+ __pContext = pContext;
+
+ return true;
+}
+
+bool
+SignatureHandler::Parse(const char *pFilepath)
+{
+ return ParseNormalizedDocument(pFilepath);
+}
+
+bool
+SignatureHandler::OnStartElement(const char *pName)
+{
+ TryReturn(pName, true, "[osp-installer] pName is null.");
+
+ bool status = true;
+
+ if (strcasecmp(pName, "Signature") == 0)
+ {
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "signature.xml");
+ AppLogTag(OSP_INSTALLER, "------------------------------------------");
+ AppLogTag(OSP_INSTALLER, "<%s>", pName);
+ status = OnSignatureElement();
+ }
+
+ if (!status)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool
+SignatureHandler::OnEndElement(const char *pName)
+{
+ TryReturn(pName, true, "[osp-installer] pName is null.");
+
+ if (strcasecmp(pName, "Signature") == 0)
+ {
+ __isDistributorSignature = false;
+ __isAuthorSignature = false;
+ AppLogTag(OSP_INSTALLER, "</%s>", pName);
+ }
+
+ return true;
+}
+
+bool
+SignatureHandler::OnCharacters(const char *pCharacters)
+{
+ bool status = true;
+ char *pName = 0;
+
+ pName = GetElementName();
+ TryReturn(pName, false, "[osp-installer] pName is null.");
+
+ if (strcasecmp(pName, "X509Certificate") == 0)
+ {
+ status = OnCertificateValue(pCharacters);
+ }
+
+ if (!status)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+bool
+SignatureHandler::OnSignatureElement(void)
+{
+ XmlAttribute *pAttr = null;
+ char *pId = null;
+
+ pAttr = GetAttribute();
+ TryReturn(pAttr, true, "[osp-installer] pAttr is null");
+
+ pId = pAttr->Find("Id");
+ if (pId)
+ {
+ AppLogTag(OSP_INSTALLER, "<Id = %s>", pId);
+
+ if (strcasecmp(pId, "AuthorSignature") == 0)
+ {
+ __isAuthorSignature = true;
+ }
+ else if (strcasecmp(pId, "DistributorSignature") == 0)
+ {
+ __isDistributorSignature = true;
+ }
+ }
+
+ return true;
+}
+
+bool
+SignatureHandler::OnCertificateValue(const char *pCharacters)
+{
+ AppLogTag(OSP_INSTALLER, "<X509Certificate>%s</X509Certificate>", pCharacters);
+
+ result r = E_SUCCESS;
+ bool res = true;
+ ByteBuffer* pByteBuffer = null;
+
+ if (__isAuthorSignature == true)
+ {
+ if (__pAuthorCertChain == null)
+ {
+ __pAuthorCertChain = new ArrayList;
+ TryCatch(__pAuthorCertChain, res = false, "[osp-installer] __pAuthorCertChain is null");
+ }
+
+ pByteBuffer = new ByteBuffer;
+ TryCatch(pByteBuffer, res = false, "[osp-installer] pByteBuffer is null");
+
+ int length = strlen(pCharacters);
+ pByteBuffer->Construct(length);
+
+ r = pByteBuffer->SetArray((byte*)pCharacters, 0, length);
+ TryCatch(!IsFailed(r), res = false, "[osp-installer] SetArray() is failed.");
+
+ pByteBuffer->Flip();
+
+ __pAuthorCertChain->Add(*pByteBuffer);
+ pByteBuffer = null;
+ }
+ else if (__isDistributorSignature == true)
+ {
+ if (__pDistributorCertChain == null)
+ {
+ __pDistributorCertChain = new ArrayList;
+ TryCatch(__pDistributorCertChain, res = false, "[osp-installer] __pDistributorCertChain is null");
+ }
+
+ pByteBuffer = new ByteBuffer;
+ TryCatch(pByteBuffer, res = false, "[osp-installer] pByteBuffer is null");
+
+ int length = strlen(pCharacters);
+ pByteBuffer->Construct(length);
+
+ r = pByteBuffer->SetArray((byte*)pCharacters, 0, length);
+ TryCatch(!IsFailed(r), res = false, "[osp-installer] SetArray() is failed.");
+
+ pByteBuffer->Flip();
+
+ __pDistributorCertChain->Add(*pByteBuffer);
+ pByteBuffer = null;
+ }
+
+CATCH:
+ delete pByteBuffer;
+ return res;
+}
+
+ArrayList*
+SignatureHandler::GetAuthorCertChain(void)
+{
+ return __pAuthorCertChain;
+}
+
+ArrayList*
+SignatureHandler::GetDistributorCertChain(void)
+{
+ return __pDistributorCertChain;
+}
diff --git a/src/XmlHandler/SignatureHandler.h b/src/XmlHandler/SignatureHandler.h
new file mode 100755
index 0000000..fb52a1b
--- /dev/null
+++ b/src/XmlHandler/SignatureHandler.h
@@ -0,0 +1,72 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file SignatureHandler.h
+ * @brief This is the header file for the %SignatureHandler class.
+ *
+ * This header file contains the declarations of the %SignatureHandler class.
+ */
+#ifndef _SIGNATURE_HANDLER_H_
+#define _SIGNATURE_HANDLER_H_
+
+#include "XmlHandler.h"
+#include "InstallationContext.h"
+
+/**
+ * @class SignatureHandler
+ * @brief This class represents the class of SignatureHandler.
+ * @since 1.0
+ *
+ * This class represents the class of SignatureHandler.
+ *
+ */
+class SignatureHandler
+ : public XmlHandler
+{
+public:
+ SignatureHandler(void);
+ virtual ~SignatureHandler(void);
+
+ bool Construct(InstallationContext *pConext);
+ bool Parse(const char *pFilepath);
+
+ Osp::Base::Collection::ArrayList* GetAuthorCertChain(void);
+ Osp::Base::Collection::ArrayList* GetDistributorCertChain(void);
+
+private:
+ SignatureHandler(const SignatureHandler& value);
+ SignatureHandler& operator =(const SignatureHandler& source);
+
+ virtual bool OnStartElement(const char *pName);
+ virtual bool OnEndElement(const char *pName);
+ virtual bool OnCharacters(const char *pCharacters);
+
+ bool OnSignatureElement(void);
+ bool OnCertificateValue(const char *pCharacters);
+
+
+private:
+ InstallationContext* __pContext;
+ Osp::Base::Collection::ArrayList* __pAuthorCertChain;
+ Osp::Base::Collection::ArrayList* __pDistributorCertChain;
+ bool __isAuthorSignature;
+ bool __isDistributorSignature;
+
+
+}; // SignatureHandler
+
+#endif // _SIGNATURE_HANDLER_H_
diff --git a/src/XmlHandler/XmlAttribute.cpp b/src/XmlHandler/XmlAttribute.cpp
new file mode 100755
index 0000000..3b4985d
--- /dev/null
+++ b/src/XmlHandler/XmlAttribute.cpp
@@ -0,0 +1,115 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file XmlAttribute.cpp
+ * @brief This is the implementation file for %XmlAttribute class.
+ */
+
+#include <string.h>
+
+#include <FBaseLog.h>
+#include <FBaseDataType.h>
+
+#include "InstallerDefs.h"
+#include "XmlAttribute.h"
+
+XmlAttribute::XmlAttribute(void)
+:__pName(null)
+,__pValue(null)
+,__pNext(null)
+{
+}
+
+XmlAttribute::~XmlAttribute(void)
+{
+ delete[] __pName;
+ delete[] __pValue;
+ delete __pNext;
+}
+
+bool
+XmlAttribute::Construct(const char *pName, const char *pValue)
+{
+ if (pName == 0 || pValue == 0)
+ {
+ return true;
+ }
+
+ __pName = new char[strlen(pName)+1];
+ TryReturn(__pName, false, "[osp-installer] __pName is null");
+ strcpy(__pName, pName);
+
+ __pValue = new char[strlen(pValue)+1];
+ TryReturn(__pValue, false, "[osp-installer] __pValue is null");
+ strcpy(__pValue, pValue);
+
+ return true;
+}
+
+char*
+XmlAttribute::Find(const char *pName)
+{
+ if (pName == 0)
+ {
+ return null;
+ }
+
+ if (__pName == 0 || __pValue == 0)
+ {
+ return null;
+ }
+
+ if (strcasecmp(pName, __pName) == 0)
+ {
+ return __pValue;
+ }
+
+ if (__pNext)
+ {
+ return __pNext->Find(pName);
+ }
+
+ return null;
+}
+
+bool
+XmlAttribute::Add(const char *pName, const char *pValue)
+{
+ if (pName == 0 || pValue == 0)
+ {
+ return true;
+ }
+
+ if (__pNext)
+ {
+ XmlAttribute *pNext = __pNext;
+ while (pNext->__pNext)
+ {
+ pNext = pNext->__pNext;
+ }
+ return pNext->Add(pName, pValue);
+ }
+ else
+ {
+ __pNext = new XmlAttribute();
+ TryReturn(__pNext, false, "[osp-installer] __pNext is null");
+
+ __pNext->Construct(pName, pValue);
+ }
+
+ return true;
+}
diff --git a/src/XmlHandler/XmlAttribute.h b/src/XmlHandler/XmlAttribute.h
new file mode 100755
index 0000000..b35daac
--- /dev/null
+++ b/src/XmlHandler/XmlAttribute.h
@@ -0,0 +1,54 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file XmlAttribute.h
+ * @brief This is the header file for the %XmlAttribute class.
+ *
+ * This header file contains the declarations of the %XmlAttribute class.
+ */
+#ifndef _XML_ATTRIBUTE_H_
+#define _XML_ATTRIBUTE_H_
+
+/**
+ * @class XmlAttribute
+ * @brief This class represents the class of XmlAttribute.
+ * @since 1.0
+ *
+ * This class represents the class of XmlAttribute.
+ *
+ */
+class XmlAttribute
+{
+public:
+ XmlAttribute(void);
+ bool Construct(const char *pName, const char *pValue);
+ virtual ~XmlAttribute(void);
+
+ char* Find(const char *pName);
+ bool Add(const char *pName, const char *pValue);
+
+private:
+ XmlAttribute(const XmlAttribute& value);
+ XmlAttribute& operator =(const XmlAttribute& source);
+
+ char* __pName;
+ char* __pValue;
+ XmlAttribute* __pNext;
+
+}; // XmlAttribute
+
+#endif // _XML_ATTRIBUTE_H_
diff --git a/src/XmlHandler/XmlHandler.cpp b/src/XmlHandler/XmlHandler.cpp
new file mode 100755
index 0000000..635fc9e
--- /dev/null
+++ b/src/XmlHandler/XmlHandler.cpp
@@ -0,0 +1,425 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file XmlHandler.cpp
+ * @brief This is the implementation file for %XmlHandler class.
+ */
+
+#include <new>
+#include <libxml/parser.h>
+#include <libxml/parserInternals.h>
+#include <libxml/tree.h>
+#include <libxml/xmlstring.h>
+
+#include <FBaseLog.h>
+#include <FIoFile.h>
+
+#include "InstallerDefs.h"
+#include "XmlHandler.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::Io;
+
+XmlHandler::XmlHandler(void)
+:__pAttr(null)
+,__pElementName(null)
+,__error(false)
+{
+}
+
+XmlHandler::~XmlHandler(void)
+{
+ delete[] __pElementName;
+ __pElementName = null;
+
+ delete __pAttr;
+ __pAttr = null;
+}
+
+bool
+XmlHandler::OnStartDocument(void)
+{
+ AppLogTag(OSP_INSTALLER, "OnStartDocument()");
+ return true;
+}
+
+bool
+XmlHandler::OnEndDocument(void)
+{
+ AppLogTag(OSP_INSTALLER, "OnEndDocument()");
+ return true;
+}
+
+bool
+XmlHandler::OnStartElement(const char *pName)
+{
+ AppLogTag(OSP_INSTALLER, "OnStartElement()");
+ return true;
+}
+
+bool
+XmlHandler::OnEndElement(const char *pName)
+{
+ AppLogTag(OSP_INSTALLER, "OnEndElement()");
+
+ return true;
+}
+
+bool
+XmlHandler::OnCharacters(const char *pCharacters)
+{
+ AppLogTag(OSP_INSTALLER, "OnCharacters()");
+ return true;
+}
+
+void
+XmlHandler::StartElement(void *ctx, const xmlChar *name, const xmlChar **atts)
+{
+ XmlHandler *pHandler = null;
+ pHandler = (XmlHandler *)ctx;
+ bool xmlResult = false;
+
+ if (name == 0)
+ {
+ return;
+ }
+
+ pHandler->SetElementName((const char *)name);
+ // AppLogTag(OSP_INSTALLER, "<%s>", (const char*)name);
+
+ if (atts)
+ {
+ XmlAttribute *pAttr = 0;
+
+ if (atts[0] != null && atts[1] != null)
+ {
+ pAttr = new (std::nothrow) XmlAttribute();
+ TryReturnVoid(pAttr, "pAttr is null");
+ pAttr->Construct((const char *)atts[0], (const char *)atts[1]);
+
+ // log
+ //if (atts[0][0] && atts[1][0])
+ //{
+ // AppLogTag(OSP_INSTALLER, "%s=\"%s\"", (const char*)atts[0], (const char*)atts[1]);
+ //}
+
+ atts = &atts[2];
+ }
+
+ while (atts != null && atts[0] != null && atts[1] != null)
+ {
+ pAttr->Add((const char *)atts[0], (const char *)atts[1]);
+
+ // log
+ //if (atts[0][0] && atts[1][0])
+ //{
+ // AppLogTag(OSP_INSTALLER, "%s=\"%s\"", (const char*)atts[0], (const char*)atts[1]);
+ //}
+
+ atts = &atts[2];
+ }
+
+ pHandler->SetAttribute(pAttr);
+ }
+
+ xmlResult = pHandler->OnStartElement((const char *)name);
+ if (xmlResult == false)
+ {
+ pHandler->SetError();
+ }
+}
+
+void
+XmlHandler::EndElement(void *ctx, const xmlChar *name)
+{
+ XmlHandler *pHandler = null;
+ pHandler = (XmlHandler *)ctx;
+ bool xmlResult = false;
+
+ xmlResult = pHandler->OnEndElement((const char *)name);
+ if (xmlResult == false)
+ {
+ pHandler->SetError();
+ }
+
+ // AppLogTag(OSP_INSTALLER, "</%s>", name);
+
+ pHandler->DeleteElement();
+ pHandler->DeleteAttribute();
+}
+
+void
+XmlHandler::Characters(void *ctx, const xmlChar *ch, int len)
+{
+ XmlHandler *pHandler = null;
+ pHandler = (XmlHandler *)ctx;
+ char *pCharacters = null;
+ bool xmlResult = false;
+
+ TryReturnVoid(ch, "ch is null.");
+
+ if (ch[0] == 0x20 || ch[0] == 0x09 || ch[0] == 0x0D || ch[0] == 0x0A)
+ {
+ return;
+ }
+
+ pCharacters = new (std::nothrow) char[len+1];
+ TryReturnVoid(pCharacters, "pCharacters is null.");
+
+ strncpy(pCharacters, (const char *)ch, len);
+ pCharacters[len] = 0;
+
+ xmlResult = pHandler->OnCharacters(pCharacters);
+ if (xmlResult == false)
+ {
+ pHandler->SetError();
+ }
+
+ // AppLogTag(OSP_INSTALLER, "%s", pCharacters);
+ delete[] pCharacters;
+}
+
+bool
+XmlHandler::ParseDocument(const char *pFilepath)
+{
+ xmlSAXHandler *pSAXHandler = null;
+ xmlParserCtxtPtr ctxt = 0;
+ bool ret = true;
+ File file;
+ FileAttributes attr;
+ result r = E_SUCCESS;
+ char* pBuf = null;
+ int size = 0;
+ int readSize = 0;
+
+ r = file.Construct(pFilepath, L"r");
+ TryCatch(r == E_SUCCESS, ret = false, "[osp-installer] file.Construct is failed. [%s]", pFilepath);
+
+ r = file.GetAttributes(pFilepath, attr);
+ TryCatch(IsFailed(r) == false, ret = false, "[osp-installer] file.GetAttributes is failed. [%s]", pFilepath);
+
+ size = (int)attr.GetFileSize();
+ TryCatch(size > 0, ret = false, "[osp-installer] size is invalid. [%s]", pFilepath);
+
+ pBuf = new (std::nothrow) char[size+1];
+ TryCatch(pBuf, ret = false, "[osp-installer] pBuf is null");
+
+ memset(pBuf, 0, size+1);
+
+ readSize = file.Read(pBuf, size);
+ TryCatch(readSize > 0, ret = false, "[osp-installer] file.Read is failed. [%s][%d]", pFilepath, readSize);
+
+ ctxt = xmlCreateMemoryParserCtxt(pBuf, size+1);
+ TryCatch(ctxt, ret = false, "[osp-installer] invalid xml file, %s", pFilepath);
+
+ pSAXHandler = new (std::nothrow) xmlSAXHandler;
+ TryCatch(pSAXHandler, ret = false, "[osp-installer] pSAXHandler is null");
+ memset(pSAXHandler, 0, sizeof(xmlSAXHandler));
+
+ ctxt->userData = (void *)this;
+
+ pSAXHandler->startElement = XmlHandler::StartElement;
+ pSAXHandler->endElement = XmlHandler::EndElement;
+ pSAXHandler->characters = XmlHandler::Characters;
+
+ ctxt->sax = pSAXHandler;
+
+ xmlParseDocument(ctxt);
+ xmlFreeParserCtxt(ctxt);
+
+ TryCatch(GetError() != true, ret = false, "[osp-installer] xml parsing error is occurred.");
+
+CATCH:
+ delete[] pBuf;
+
+ return ret;
+}
+
+bool
+XmlHandler::ParseNormalizedDocument(const char* pFilepath)
+{
+ xmlSAXHandler *pSAXHandler = null;
+ xmlParserCtxtPtr ctxt = 0;
+ bool ret = true;
+ File file;
+ FileAttributes attr;
+ result r = E_SUCCESS;
+ char* pBuf = null;
+ char* pNormalizedBuf = null;
+ int size = 0;
+ int normalizedSize = 0;
+ int readSize = 0;
+
+ r = file.Construct(pFilepath, L"r");
+ TryCatch(r == E_SUCCESS, ret = false, "[osp-installer] file.Construct is failed. [%s]", pFilepath);
+
+ r = file.GetAttributes(pFilepath, attr);
+ TryCatch(IsFailed(r) == false, ret = false, "[osp-installer] file.GetAttributes is failed. [%s]", pFilepath);
+
+ size = (int)attr.GetFileSize();
+ TryCatch(size > 0, ret = false, "[osp-installer] size is invalid. [%s]", pFilepath);
+
+ pBuf = new (std::nothrow) char[size+1];
+ TryCatch(pBuf, ret = false, "[osp-installer] pBuf is null");
+
+ pNormalizedBuf = new (std::nothrow) char[size+1];
+ TryCatch(pNormalizedBuf, ret = false, "[osp-installer] pNormalizedBuf is null");
+
+ memset(pBuf, 0, size+1);
+ memset(pNormalizedBuf, 0, size+1);
+
+ readSize = file.Read(pBuf, size);
+ TryCatch(readSize > 0, ret = false, "[osp-installer] file.Read is failed. [%s][%d]", pFilepath, readSize);
+
+ normalizedSize = Normalize(pBuf, size, pNormalizedBuf);
+ TryCatch(normalizedSize > 0, ret = false, "[osp-installer] normalizedSize [%d]", readSize);
+
+ ctxt = xmlCreateMemoryParserCtxt(pNormalizedBuf, normalizedSize);
+ TryCatch(ctxt, ret = false, "[osp-installer] invalid xml file, %s", pFilepath);
+
+ pSAXHandler = new (std::nothrow) xmlSAXHandler;
+ TryCatch(pSAXHandler, ret = false, "[osp-installer] pSAXHandler is null");
+ memset(pSAXHandler, 0, sizeof(xmlSAXHandler));
+
+ ctxt->userData = (void *)this;
+
+ pSAXHandler->startElement = XmlHandler::StartElement;
+ pSAXHandler->endElement = XmlHandler::EndElement;
+ pSAXHandler->characters = XmlHandler::Characters;
+
+ ctxt->sax = pSAXHandler;
+
+ xmlParseDocument(ctxt);
+ xmlFreeParserCtxt(ctxt);
+
+ TryCatch(GetError() != true, ret = false, "[osp-installer] xml parsing error is occurred.");
+
+CATCH:
+ delete[] pBuf;
+ delete[] pNormalizedBuf;
+
+ return ret;
+}
+
+int
+XmlHandler::Normalize(const char* pBuf, int size, char* pNormalizedBuf)
+{
+ int idx = 0;
+ int normalizedIdx = 0;
+
+ while (pBuf[idx] && idx < size)
+ {
+ if (pBuf[idx] == 0x0D)
+ {
+ if (pBuf[idx + 1] == 0x0A)
+ {
+ idx++;
+ }
+ pNormalizedBuf[normalizedIdx] = 0x0A;
+ normalizedIdx++;
+ }
+ else
+ {
+ pNormalizedBuf[normalizedIdx] = pBuf[idx];
+ normalizedIdx++;
+ }
+
+ idx++;
+ }
+
+ return normalizedIdx;
+}
+
+bool
+XmlHandler::SetElementName(const char *pElementName)
+{
+ TryReturn(pElementName, false, "[osp-installer] pElementName is null");
+
+ if (__pElementName)
+ {
+ delete[] __pElementName;
+ __pElementName = null;
+ }
+
+ __pElementName = new char[strlen(pElementName)+1];
+ TryReturn(__pElementName, false, "[osp-installer] __pElementName is null");
+ strcpy(__pElementName, pElementName);
+
+ __elementStack.Push(*new String(pElementName));
+
+ return true;
+}
+
+char*
+XmlHandler::GetElementName(void)
+{
+ return __pElementName;
+}
+
+void
+XmlHandler::DeleteElement(void)
+{
+ delete[]__pElementName;
+ __pElementName = 0;
+
+ __elementStack.Pop();
+}
+
+void
+XmlHandler::SetAttribute(XmlAttribute *pAttr)
+{
+ __pAttr = pAttr;
+}
+
+XmlAttribute*
+XmlHandler::GetAttribute(void)
+{
+ return __pAttr;
+}
+
+void
+XmlHandler::DeleteAttribute(void)
+{
+ delete __pAttr;
+ __pAttr = null;
+}
+
+IEnumerator*
+XmlHandler::GetElementEnumeratorN(void)
+{
+ return __elementStack.GetEnumeratorN();
+}
+
+int
+XmlHandler::GetElementCount(void)
+{
+ return __elementStack.GetCount();
+}
+
+void
+XmlHandler::SetError(void)
+{
+ __error = true;
+}
+
+bool
+XmlHandler::GetError(void)
+{
+ return __error;
+}
+
diff --git a/src/XmlHandler/XmlHandler.h b/src/XmlHandler/XmlHandler.h
new file mode 100755
index 0000000..c1227e2
--- /dev/null
+++ b/src/XmlHandler/XmlHandler.h
@@ -0,0 +1,101 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file XmlHandler.h
+ * @brief This is the header file for the %XmlHandler class.
+ *
+ * This header file contains the declarations of the %XmlHandler class.
+ */
+#ifndef _XML_HANDLER_H_
+#define _XML_HANDLER_H_
+
+#include <libxml/xmlstring.h>
+
+#include <FBaseColStack.h>
+
+#include "XmlAttribute.h"
+
+namespace Osp { namespace Base { namespace Collection
+{
+class IEnumerator;
+}}}
+
+/**
+ * @class XmlHandler
+ * @brief This class represents the class of XmlHandler.
+ * @since 1.0
+ *
+ * This class represents the class of XmlHandler.
+ *
+ */
+class XmlHandler
+{
+public:
+ XmlHandler(void);
+ bool Construct(void);
+ virtual ~XmlHandler(void);
+
+ virtual bool OnStartDocument(void);
+ virtual bool OnEndDocument(void);
+ virtual bool OnStartElement(const char *pName);
+ virtual bool OnEndElement(const char *pName);
+ virtual bool OnCharacters(const char *pCharacters);
+ // virtual bool OnXmlDecl(char *version, char *encoding, char *standalone, CXmlElement* pElement);
+ // virtual bool OnPi(char *pi, char *ins, CXmlElement* pElement);
+ // virtual bool OnDocType(char *name, char *docType, CXmlElement* pElement);
+ // virtual bool OnComment(char *comment, CXmlElement* pElement);
+ // virtual bool OnCData(char *data, CXmlElement* pElement);
+
+ void SetError(void);
+ bool GetError(void);
+
+protected:
+ bool ParseDocument(const char *pFilepath);
+ bool ParseNormalizedDocument(const char* pFilepath);
+
+ int Normalize(const char* pBuf, int size, char* pNormalizedBuf);
+
+ bool SetElementName(const char *pElementName);
+ char* GetElementName(void);
+ void DeleteElement(void);
+
+ void SetAttribute(XmlAttribute *pAttr);
+ XmlAttribute* GetAttribute(void);
+ void DeleteAttribute(void);
+
+ Osp::Base::Collection::IEnumerator* GetElementEnumeratorN(void);
+ int GetElementCount(void);
+
+private:
+ XmlHandler(const XmlHandler& value);
+ XmlHandler& operator =(const XmlHandler& source);
+
+ static void StartDocument(void *ctx);
+ static void EndDocument(void *ctx);
+ static void StartElement(void *ctx, const xmlChar *name, const xmlChar **atts);
+ static void EndElement(void *ctx, const xmlChar *name);
+ static void Characters(void *ctx, const xmlChar *ch, int len);
+
+ XmlAttribute* __pAttr;
+ char* __pElementName;
+ Osp::Base::Collection::Stack __elementStack;
+
+ bool __error;
+
+}; // XmlHandler
+
+#endif // _XML_HANDLER_H_
diff --git a/src/XmlHandler/XmlWriter.cpp b/src/XmlHandler/XmlWriter.cpp
new file mode 100644
index 0000000..7f17474
--- /dev/null
+++ b/src/XmlHandler/XmlWriter.cpp
@@ -0,0 +1,175 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file XmlWriter.cpp
+ * @brief This is the implementation file for %XmlWriter class.
+ */
+
+#include <new>
+#include <libxml/parser.h>
+#include <libxml/parserInternals.h>
+#include <libxml/tree.h>
+#include <libxml/xmlstring.h>
+
+#include <FBaseLog.h>
+#include <FBaseUtilStringUtil.h>
+#include <FIoFile.h>
+
+#include "InstallerDefs.h"
+#include "XmlWriter.h"
+
+using namespace Osp::Base;
+using namespace Osp::Base::Collection;
+using namespace Osp::Base::Utility;
+using namespace Osp::Io;
+
+XmlWriter::XmlWriter(void)
+:__pXmlWriter(null), __pXmlBuffer(null)
+{
+ AppLogTag(OSP_INSTALLER, "Xml Generator Start");
+}
+
+XmlWriter::~XmlWriter(void)
+{
+ result r = E_SUCCESS;
+
+ xmlTextWriterEndDocument(__pXmlWriter);
+
+ File file;
+ r = file.Construct(__xmlFilePath, "w");
+ if (IsFailed(r))
+ {
+ AppLogTag(OSP_INSTALLER, "file.Construct() failed, __xmlFilePath=[%ls]", __xmlFilePath.GetPointer());
+ }
+ else
+ {
+ r = file.Write((char *)__pXmlBuffer->content, __pXmlBuffer->use);
+ if (IsFailed(r))
+ {
+ AppLogTag(OSP_INSTALLER, "file.Write() failed, __xmlFilePath=[%ls]", __xmlFilePath.GetPointer());
+ }
+
+ AppLogTag(OSP_INSTALLER, "Xml File is generated... \n\n%s", __pXmlBuffer->content);
+ }
+
+ if (__pXmlWriter)
+ {
+ xmlFreeTextWriter(__pXmlWriter);
+ }
+
+ if (__pXmlBuffer)
+ {
+ xmlBufferFree(__pXmlBuffer);
+ }
+
+ AppLogTag(OSP_INSTALLER, "Xml Generator End");
+}
+
+bool
+XmlWriter::Construct(const Osp::Base::String& filepath)
+{
+ bool res = false;
+ int err = 0;
+ AppLogTag(OSP_INSTALLER, "Construct()");
+
+ __pXmlBuffer = xmlBufferCreate();
+ TryCatch(__pXmlBuffer, res = false, "[osp-installer] __pXmlBuffer is null");
+
+ __xmlFilePath = filepath;
+
+ __pXmlWriter = xmlNewTextWriterMemory(__pXmlBuffer, 0);
+ TryCatch(__pXmlWriter, res = false, "[osp-installer] __pXmlWriter is null");
+
+ xmlTextWriterSetIndent(__pXmlWriter, 1);
+
+ err = xmlTextWriterStartDocument(__pXmlWriter, null, null, null);
+ TryCatch(err == 0, res = false, "[osp-installer] err is %d", err);
+
+ return true;
+CATCH:
+
+ if (__pXmlWriter)
+ {
+ xmlFreeTextWriter(__pXmlWriter);
+ __pXmlWriter = null;
+ }
+
+ if (__pXmlBuffer)
+ {
+ xmlBufferFree(__pXmlBuffer);
+ __pXmlBuffer = null;
+ }
+
+ return res;
+}
+
+bool
+XmlWriter::StartElement(const Osp::Base::String& name)
+{
+ ByteBuffer* pNameBuf = null;
+
+ pNameBuf = StringUtil::StringToUtf8N(name);
+ if (pNameBuf)
+ {
+ xmlTextWriterStartElement(__pXmlWriter, (xmlChar *)pNameBuf->GetPointer());
+ }
+
+ delete pNameBuf;
+ return true;
+}
+
+bool
+XmlWriter::WriteAttribute(const Osp::Base::String& name, const Osp::Base::String& content)
+{
+ ByteBuffer* pNameBuf = null;
+ ByteBuffer* pContentBuf = null;
+
+ pNameBuf = StringUtil::StringToUtf8N(name);
+ pContentBuf = StringUtil::StringToUtf8N(content);
+
+ if (pNameBuf && pContentBuf)
+ {
+ xmlTextWriterWriteAttribute(__pXmlWriter, (xmlChar *)pNameBuf->GetPointer(), (xmlChar *)pContentBuf->GetPointer());
+ }
+
+ delete pNameBuf;
+ delete pContentBuf;
+ return true;
+}
+
+bool
+XmlWriter::WriteString(const Osp::Base::String& content)
+{
+ ByteBuffer* pContentBuf = null;
+
+ pContentBuf = StringUtil::StringToUtf8N(content);
+ if (pContentBuf)
+ {
+ xmlTextWriterWriteString(__pXmlWriter, (xmlChar *)pContentBuf->GetPointer());
+ }
+
+ delete pContentBuf;
+ return true;
+}
+
+bool
+XmlWriter::EndElement(void)
+{
+ xmlTextWriterEndElement(__pXmlWriter);
+ return true;
+}
+
diff --git a/src/XmlHandler/XmlWriter.h b/src/XmlHandler/XmlWriter.h
new file mode 100755
index 0000000..677dbf6
--- /dev/null
+++ b/src/XmlHandler/XmlWriter.h
@@ -0,0 +1,62 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file XmlWriter.h
+ * @brief This is the header file for the %XmlWriter class.
+ *
+ * This header file contains the declarations of the %XmlWriter class.
+ */
+#ifndef _XML_WRITER_H_
+#define _XML_WRITER_H_
+
+// #include <libxml/xmlstring.h>
+#include <libxml/xmlwriter.h>
+
+#include "XmlAttribute.h"
+
+/**
+ * @class XmlWriter
+ * @brief This class represents the class of XmlWriter.
+ * @since 1.0
+ *
+ * This class represents the class of XmlWriter.
+ *
+ */
+class XmlWriter
+{
+public:
+ XmlWriter(void);
+ virtual ~XmlWriter(void);
+ bool Construct(const Osp::Base::String& filepath);
+
+ bool StartElement(const Osp::Base::String& name);
+ bool WriteAttribute(const Osp::Base::String& name, const Osp::Base::String& content);
+ bool WriteString(const Osp::Base::String& content);
+ bool EndElement(void);
+
+private:
+ XmlWriter(const XmlWriter& value);
+ XmlWriter& operator =(const XmlWriter& source);
+
+ // bool __error;
+ xmlTextWriterPtr __pXmlWriter;
+ xmlBufferPtr __pXmlBuffer;
+ Osp::Base::String __xmlFilePath;
+
+}; // XmlWriter
+
+#endif // _XML_WRITER_H_
diff --git a/src/backend/backend.cpp b/src/backend/backend.cpp
new file mode 100755
index 0000000..588eded
--- /dev/null
+++ b/src/backend/backend.cpp
@@ -0,0 +1,249 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file backend.cpp
+ */
+
+#include <new>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <pkgmgr_installer.h>
+
+#include <FBase_StringConverter.h>
+
+#include "InstallerManager.h"
+#include "InstallerDefs.h"
+
+using namespace Osp::Base;
+
+extern "C" void Osp_Initialize();
+static bool __osp_installer_report_result(const String& appId, int errorType);
+
+static pkgmgr_installer *_pi = null;
+
+int
+main(int argc, char **argv)
+{
+ int ret = 0;
+ const char *pkg_info = NULL;
+ char* pkg_path = NULL;
+ String path;
+ String appId;
+ int errorType = 0;
+ InstallerManager manager;
+
+ Osp_Initialize();
+
+ AppLogTag(OSP_INSTALLER, "\n\n\n\n\n\n");
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+ AppLogTag(OSP_INSTALLER, " # %s", OSP_INSTALLER_VERSION);
+ AppLogTag(OSP_INSTALLER, " # argc = %d", argc);
+
+ if (argc == TEST_ARG_COUNT)
+ {
+ errorType = manager.ReqeustByTest();
+ return errorType;
+ }
+ else if (argc == COMMAND_ARG_COUNT)
+ {
+ errorType = manager.RequestByCommand(argc, argv);
+ return errorType;
+ }
+
+ pkgmgr_installer *pi = pkgmgr_installer_new();
+ _pi = pi;
+
+ pkgmgr_installer_receive_request(pi, argc, argv);
+
+ int req_type = pkgmgr_installer_get_request_type(pi);
+ if (PKGMGR_REQ_INVALID >= req_type)
+ {
+ goto CATCH;
+ }
+
+ pkg_info = pkgmgr_installer_get_request_info(pi);
+ pkg_path = (const_cast<char*>(pkg_info));
+ AppLogTag(OSP_INSTALLER, "osp-installer is called. pkg_path = %s", pkg_path);
+
+ path = pkg_path;
+
+ switch (req_type)
+ {
+ case PKGMGR_REQ_INSTALL:
+ {
+ // path
+ // /opt/apps/PKGS/org.tizen.qik37po9ck-1.0.0.tpk
+ // /opt/apps/PKGS/qik37po9ck-1.0.0.tpk
+ ret = manager.Request(path, INSTALLER_OPERATION_INSTALL, REQUESTER_TYPE_NORMAL, appId, errorType);
+
+ if (_pi != 0)
+ {
+ char resultBuf[128] = {0};
+ snprintf(resultBuf, sizeof(resultBuf), "%ls", appId.GetPointer());
+ pkgmgr_installer_send_signal(_pi, "tpk", resultBuf, "start", "install");
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "_pi is null");
+ }
+
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+ AppLogTag(OSP_INSTALLER, " # appId = [%ls], error = [%d]\n", appId.GetPointer(), errorType);
+
+ if (errorType != 0)
+ {
+ AppLogTag(OSP_INSTALLER, " # result = [Installation][failure]");
+ manager.RemoveGarbage(pkg_path);
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, " # result = [Installation][success]");
+ }
+
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+
+ __osp_installer_report_result(appId, errorType);
+ }
+ break;
+
+ case PKGMGR_REQ_UNINSTALL:
+ {
+ // org.tizen.qik37po9ck#BasicApp : by UI
+ // qik37po9ck.BasicApp : by UI
+ // qik37po9ck : by API
+ String requestAppId;
+
+ if (path.Contains(PACKAGE_NAME_PREFIX_ORG) == true)
+ {
+ String prefixPackage(PACKAGE_NAME_PREFIX_ORG);
+ path.SubString(prefixPackage.GetLength(), APPID_LENGTH, requestAppId);
+ }
+ else
+ {
+ path.SubString(0, APPID_LENGTH, requestAppId);
+ }
+
+ AppLogTag(OSP_INSTALLER, "requestAppId = %ls", requestAppId.GetPointer());
+ ret = manager.Request(requestAppId, INSTALLER_OPERATION_UNINSTALL, REQUESTER_TYPE_NORMAL, appId, errorType);
+
+ if (_pi != 0)
+ {
+ char resultBuf[128] = {0};
+ snprintf(resultBuf, sizeof(resultBuf), "%ls", appId.GetPointer());
+ pkgmgr_installer_send_signal(_pi, "tpk", resultBuf, "start", "uninstall");
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, "_pi is null");
+ }
+
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+ AppLogTag(OSP_INSTALLER, " # appId = [%ls], error = [%d]", appId.GetPointer(), errorType);
+
+ if (errorType != 0)
+ {
+ AppLogTag(OSP_INSTALLER, " # result = [Uninstallation][failure]");
+ }
+ else
+ {
+ AppLogTag(OSP_INSTALLER, " # result = [Uninstallation][success]");
+ }
+
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+
+ __osp_installer_report_result(appId, errorType);
+ }
+ break;
+
+ default:
+ ret = -1;
+ break;
+ }
+
+ if (ret == -1)
+ {
+ goto CATCH;
+ }
+
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+ return errorType;
+
+CATCH:
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------");
+ pkgmgr_installer_send_signal(_pi, "sample", "abcd", "end", "ok");
+ return errorType;
+}
+
+bool
+__osp_installer_report_result(const String& appId, int errorType)
+{
+ int ret = 0;
+ char resultBuf[128] = {0};
+ const char* pAppId = null;
+ InstallerManager manager;
+
+ AppLogTag(OSP_INSTALLER, "__result_callback: request_type = [%d], request_info = [%s], session_id = [%s]\n",
+ pkgmgr_installer_get_request_type(_pi), pkgmgr_installer_get_request_info(_pi), pkgmgr_installer_get_session_id(_pi));
+
+ if (_pi == 0)
+ {
+ AppLogTag(OSP_INSTALLER, "_pi is null");
+ return false;
+ }
+
+ if (errorType == 0)
+ {
+ pAppId = _StringConverter::CopyToCharArrayN(appId);
+ if (pAppId == null)
+ {
+ pAppId = "0000000000";
+ snprintf(resultBuf, sizeof(resultBuf), "%s", pAppId);
+ }
+ else
+ {
+ manager.DisplayPackageInfo(pAppId);
+
+ snprintf(resultBuf, sizeof(resultBuf), "%s", pAppId);
+ delete[] pAppId;
+ pAppId = null;
+ }
+
+ AppLogTag(OSP_INSTALLER, "__result_callback:: [success] errorType = [%d]", errorType);
+ ret = pkgmgr_installer_send_signal(_pi, "tpk", resultBuf, "end", "ok");
+ }
+ else
+ {
+ snprintf(resultBuf, sizeof(resultBuf), "0000000000");
+
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------\n");
+ AppLogTag(OSP_INSTALLER, " # error = [%d]\n", errorType);
+ AppLogTag(OSP_INSTALLER, " # result = [Installation][failure]\n");
+ AppLogTag(OSP_INSTALLER, "---------------------------------------------------\n");
+ AppLogTag(OSP_INSTALLER, "__result_callback:: [failure] errorType = [%d]", errorType);
+
+ ret = pkgmgr_installer_send_signal(_pi, "tpk", resultBuf, "end", "fail");
+ }
+
+ pkgmgr_installer_free(_pi);
+ _pi = null;
+
+ return true;
+}