From: Soyoung Kim Date: Wed, 27 Mar 2013 02:23:00 +0000 (+0900) Subject: modifiy define error code. X-Git-Tag: accepted/tizen_2.1/20130425.023916~12^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=15fe1dad140c3cea1391a3ea61270a9d84a45fe8;p=framework%2Fweb%2Fwrt-installer.git modifiy define error code. [Issue#] N/A [Problem] N/A [Cause] error code is redefined. [Solution] if error occur in installer, error code should send to package manager. so modify error code and send logic. [SCMRequest] N/A Change-Id: Ib750e08318d328ac7b1da49598b1dc71872a4780 --- diff --git a/src/jobs/job_exception_error.h b/src/jobs/job_exception_error.h new file mode 100644 index 0000000..52a98a1 --- /dev/null +++ b/src/jobs/job_exception_error.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file job_exception_error.h + * @author Soyoung Kim (sy037.kim@samsung.com) + * @version 1.0 + * @brief This file contains declarations of wrt api + */ + +/* + * @defgroup wrt_engine_group WebRunTime engine Library + * @ingroup internet_FW + * Functions to APIs to access wrt-engine + */ + +#ifndef JOB_EXCEPTION_ERROR_H +#define JOB_EXCEPTION_ERROR_H + +#include +#include + +namespace Jobs { +namespace Exceptions { +enum Type +{ + Success = 0, ///< Success + + /* pkgmgr error */ + ErrorPackageNotFound, ///< + ErrorPackageInvalid, ///< invalid widget package + ErrorPackageLowerVersion, ///< given version is lower + ///< than existing version + ErrorManifestNotFound, ///< + ErrorManifestInvalid, ///< + ErrorConfigNotFound, ///< couldn't find config.xml + ///< in package. + ErrorConfigInvalid, ///< invalid config.xml + ErrorSignatureNotFound, ///< signature file not exist. + ErrorSignatureInvalid, ///< invalid signature file + ErrorSignatureVerificationFailed, ///< failure in verificate + ///< signature + ErrorRootCertificateNotFound, ///< couldn't find root + ///< certificate. + ErrorCertificationInvaid, ///< invalid certification + ErrorCertificateChainVerificationFailed, ///< failure in verificate + ///< certification chain. + ErrorCertificateExpired, ///< expire cerification. + ErrorInvalidPrivilege, ///< invalid privilege. + ErrorMenuIconNotFound, ///< + ErrorFatalError, ///< failure in db operation + ///< or file opertion.. + ErrorOutOfStorage, ///< failure in shortage of + ///< memory + ErrorOutOfMemory, ///< failure in shortage of RAM + + /* wrt-installer error */ + /* 121-140 : reserved for Web installer */ + ErrorPackageAlreadyInstalled = 121, ///< package already in target. + ErrorAceCheckFailed, ///< failure in ace check. + ErrorManifestCreateFailed, ///< failure in creating manifest + ErrorEncryptionFailed, ///< failure in encryption resource + ErrorInstallOspServcie, ///< Failure in installing osp service + ErrorPluginInstallationFailed, ///< failure in plugin installation + ErrorWidgetUninstallationFailed, ///< failure in uninstallation + + ErrorUnknown = 140, ///< do not use this error code. +}; +} +} + +#endif /* JOB_EXCEPTION_ERROR_H */ diff --git a/src/jobs/plugin_install/job_plugin_install.cpp b/src/jobs/plugin_install/job_plugin_install.cpp index ac1642f..38c0aef 100644 --- a/src/jobs/plugin_install/job_plugin_install.cpp +++ b/src/jobs/plugin_install/job_plugin_install.cpp @@ -67,11 +67,11 @@ void JobPluginInstall::SendFinishedSuccess() { LogDebug("Call Plugin install success finishedCallback"); getInstallerStruct().finishedCallback(getInstallerStruct().userParam, - Exceptions::Success); + Jobs::Exceptions::Success); } else { LogDebug("Call Plugin install waiting finishedCallback"); getInstallerStruct().finishedCallback(getInstallerStruct().userParam, - Exceptions::InstallationWaiting); + Jobs::Exceptions::ErrorPluginInstallationFailed); LogInfo("Installation: " << getFilePath() << " NOT possible"); @@ -90,7 +90,7 @@ void JobPluginInstall::SendFinishedFailure() void JobPluginInstall::SaveExceptionData(const Jobs::JobExceptionBase &e) { - m_exceptionCaught = static_cast(e.getParam()); + m_exceptionCaught = static_cast(e.getParam()); m_exceptionMessage = e.GetMessage(); } } //namespace Jobs diff --git a/src/jobs/plugin_install/job_plugin_install.h b/src/jobs/plugin_install/job_plugin_install.h index 46af82a..0af9c04 100644 --- a/src/jobs/plugin_install/job_plugin_install.h +++ b/src/jobs/plugin_install/job_plugin_install.h @@ -75,7 +75,7 @@ class JobPluginInstall : //TODO move it to base class of all jobs //maybe separate JobBase class for this? - Exceptions::Type m_exceptionCaught; + Jobs::Exceptions::Type m_exceptionCaught; std::string m_exceptionMessage; }; } //namespace Jobs diff --git a/src/jobs/plugin_install/plugin_installer_errors.h b/src/jobs/plugin_install/plugin_installer_errors.h index 16ad13f..11c7f88 100644 --- a/src/jobs/plugin_install/plugin_installer_errors.h +++ b/src/jobs/plugin_install/plugin_installer_errors.h @@ -27,30 +27,23 @@ WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_ #include +#include + +using namespace Jobs::Exceptions; namespace Jobs { namespace PluginInstall { namespace Exceptions { -enum Type -{ - Success, ///< Success - - WrongPluginPath, ///< Wrong plugin path - MetafileError, ///< Metafile parse error - AlreadyInstalled, ///< Plugin already installed - LoadingLibraryError, ///< Loading library by dlopen failed. - /// It may be caused by missing symbols - InstallationWaiting, /// Installation failed due to dependencies - Unknown ///< Temporary error. Try to not use this. -}; -DECLARE_JOB_EXCEPTION_BASE(JobExceptionBase, Base, Unknown) -DECLARE_JOB_EXCEPTION(Base, PluginPathFailed, WrongPluginPath) -DECLARE_JOB_EXCEPTION(Base, PluginMetafileFailed, MetafileError) -DECLARE_JOB_EXCEPTION(Base, PluginAlreadyInstalled, AlreadyInstalled) -DECLARE_JOB_EXCEPTION(Base, PluginLibraryError, LoadingLibraryError) -DECLARE_JOB_EXCEPTION(Base, InstallationWaitingError, InstallationWaiting) -DECLARE_JOB_EXCEPTION(Base, UnknownError, Unknown) +DECLARE_JOB_EXCEPTION_BASE(JobExceptionBase, Base, ErrorUnknown) +DECLARE_JOB_EXCEPTION(Base, PluginPathFailed, ErrorPluginInstallationFailed) +DECLARE_JOB_EXCEPTION(Base, PluginMetafileFailed, ErrorPluginInstallationFailed) +DECLARE_JOB_EXCEPTION(Base, PluginAlreadyInstalled, + ErrorPluginInstallationFailed) +DECLARE_JOB_EXCEPTION(Base, PluginLibraryError, ErrorPluginInstallationFailed) +DECLARE_JOB_EXCEPTION(Base, InstallationWaitingError, + ErrorPluginInstallationFailed) +DECLARE_JOB_EXCEPTION(Base, UnknownError, ErrorUnknown) } //namespace } //namespace } //namespace diff --git a/src/jobs/plugin_install/plugin_installer_struct.h b/src/jobs/plugin_install/plugin_installer_struct.h index ef69d6f..c253897 100644 --- a/src/jobs/plugin_install/plugin_installer_struct.h +++ b/src/jobs/plugin_install/plugin_installer_struct.h @@ -29,7 +29,7 @@ //Plugin Installer typedefs typedef void (*PluginInstallerFinishedCallback)( void *userParam, - Jobs::PluginInstall::Exceptions::Type); + Jobs::Exceptions::Type); //installer progress typedef void (*PluginInstallerProgressCallback)( diff --git a/src/jobs/widget_install/job_widget_install.cpp b/src/jobs/widget_install/job_widget_install.cpp index ec95960..0d333f0 100644 --- a/src/jobs/widget_install/job_widget_install.cpp +++ b/src/jobs/widget_install/job_widget_install.cpp @@ -79,6 +79,7 @@ #include using namespace WrtDB; +using namespace Jobs::Exceptions; namespace // anonymous { @@ -97,32 +98,6 @@ const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME = const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT = L"prefer-external"; -class InstallerTaskFail : - public DPL::TaskDecl -{ - private: - bool m_deferred; - - void StepFail() - { - if (m_deferred) { - ThrowMsg(Jobs::WidgetInstall::Exceptions::Deferred, - "Widget installation or update deferred!"); - } else { - ThrowMsg(Jobs::WidgetInstall::Exceptions::NotAllowed, - "Widget installation or update not allowed!"); - } - } - - public: - InstallerTaskFail(bool deferred) : - DPL::TaskDecl(this), - m_deferred(deferred) - { - AddStep(&InstallerTaskFail::StepFail); - } -}; - const std::string XML_EXTENSION = ".xml"; bool hasExtension(const std::string& filename, const std::string& extension) @@ -159,13 +134,54 @@ bool checkTizenPkgIdExist(const std::string& tizenPkgId) namespace Jobs { namespace WidgetInstall { +class InstallerTaskFail : + public DPL::TaskDecl +{ + private: + ConfigureResult m_result; + + void StepFail() + { + if (m_result == ConfigureResult::Deferred) { + ThrowMsg(Jobs::WidgetInstall::Exceptions::Deferred, + "widget installation or update deferred!"); + } else if (m_result == ConfigureResult::Failed_InvalidConfig) { + ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetConfigFileInvalid, + "invalid config"); + } else if (m_result == ConfigureResult::Failed_LowerVersion) { + ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageLowerVersion, + "package version is lower than installed version"); + } else if (m_result == ConfigureResult::Failed_AlreadyInstalled) { + ThrowMsg(Jobs::WidgetInstall::Exceptions::PackageAlreadyInstalled, + "package is already installed"); + } else if (m_result == ConfigureResult::Failed_WidgetRunning) { + ThrowMsg(Jobs::WidgetInstall::Exceptions::WidgetRunningError, + "widget is running"); + } else if (m_result == ConfigureResult::Failed_DrmError) { + ThrowMsg(Jobs::WidgetInstall::Exceptions::DRMFailed, + "drm failed"); + } else { + ThrowMsg(Jobs::WidgetInstall::Exceptions::NotAllowed, + "widget installation or update not allowed!"); + } + } + + public: + InstallerTaskFail(ConfigureResult result) : + DPL::TaskDecl(this), + m_result(result) + { + AddStep(&InstallerTaskFail::StepFail); + } +}; + JobWidgetInstall::JobWidgetInstall( std::string const &widgetPath, const WidgetInstallationStruct & installerStruct) : Job(Installation), JobContextBase(installerStruct), - m_exceptionCaught(Exceptions::Success) + m_exceptionCaught(Jobs::Exceptions::Success) { m_installerContext.m_quiet = m_jobStruct.m_quiet; @@ -268,18 +284,19 @@ JobWidgetInstall::JobWidgetInstall( // Installation is deferred LogInfo("Configure installation deferred"); - AddTask(new InstallerTaskFail(true)); - } else if (result == ConfigureResult::Failed) { + AddTask(new InstallerTaskFail(result)); + } else if (result >= ConfigureResult::Failed && + result <= ConfigureResult::Failed_DrmError) { // Installation is not allowed to proceed due to widget update policy LogWarning("Configure installation failed!"); - AddTask(new InstallerTaskFail(false)); + AddTask(new InstallerTaskFail(result)); } else { Assert(false && "Invalid configure result!"); } } -JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation( +ConfigureResult JobWidgetInstall::PrePareInstallation( const std::string &widgetPath) { ConfigureResult result; @@ -295,7 +312,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation( LogDebug("decrypt DRM widget"); if (DecryptDRMWidget(widgetPath, tempDir)) { LogDebug("Failed decrypt DRM widget"); - return ConfigureResult::Failed; + return ConfigureResult::Failed_DrmError; } } @@ -322,7 +339,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::PrePareInstallation( Catch(Exceptions::ExtractFileFailed) { LogError("Failed to create temporary path for widget"); - result = ConfigureResult::Failed; + result = ConfigureResult::Failed_InvalidConfig; } return result; @@ -447,7 +464,7 @@ void JobWidgetInstall::configureWidgetLocation(const std::string & widgetPath, LogInfo("widgetSource " << widgetPath); } -JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation( +ConfigureResult JobWidgetInstall::ConfigureInstallation( const std::string &widgetSource, const WrtDB::ConfigParserData &configData, const std::string &tempPath) @@ -479,7 +496,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation( //TODO(t.iwanek): appId is unique, what about installation of // abcdefghij.test1 and abcdefghij.test2? regfree(®); - return ConfigureResult::Failed; + return ConfigureResult::Failed_AlreadyInstalled; } regfree(®); @@ -494,7 +511,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::ConfigureInstallation( return result; } -JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate( +ConfigureResult JobWidgetInstall::checkWidgetUpdate( const WidgetUpdateInfo &update) { LogInfo( @@ -533,7 +550,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate( tzAppid).c_str(), &isRunning); if (APP_MANAGER_ERROR_NONE != retval) { LogError("Fail to get running state"); - return ConfigureResult::Failed; + return ConfigureResult::Failed_WidgetRunning; } if (true == isRunning) { @@ -547,7 +564,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate( LogInfo( "Widget is already running. Policy is not update according to WAC"); - return ConfigureResult::Failed; + return ConfigureResult::Failed_WidgetRunning; } } @@ -566,7 +583,7 @@ JobWidgetInstall::ConfigureResult JobWidgetInstall::checkWidgetUpdate( LogInfo("Whether widget policy allow proceed ok"); return ConfigureResult::Updated; } else { - return ConfigureResult::Failed; + return ConfigureResult::Failed_LowerVersion; } } return ConfigureResult::Ok; @@ -839,7 +856,7 @@ void JobWidgetInstall::SendFinishedSuccess() LogDebug("Call widget install successfinishedCallback"); getInstallerStruct().finishedCallback(getInstallerStruct().userParam, DPL::ToUTF8String( - tizenId), Exceptions::Success); + tizenId), Jobs::Exceptions::Success); } void JobWidgetInstall::SendFinishedFailure() @@ -848,14 +865,20 @@ void JobWidgetInstall::SendFinishedFailure() // remove widget install information file unlink(m_installerContext.installInfo.c_str()); - LogError("Error in installation step: " << m_exceptionCaught); + LogError("Error number: " << m_exceptionCaught); LogError("Message: " << m_exceptionMessage); TizenAppId & tizenId = m_installerContext.widgetConfig.tzAppid; LogDebug("Call widget install failure finishedCallback"); + std::stringstream errorNum; + errorNum << m_exceptionCaught; // send signal of pkgmgr getInstallerStruct().pkgmgrInterface->sendSignal( + PKGMGR_ERROR, + errorNum.str()); + + getInstallerStruct().pkgmgrInterface->sendSignal( PKGMGR_END_KEY, PKGMGR_END_FAILURE); @@ -866,7 +889,7 @@ void JobWidgetInstall::SendFinishedFailure() void JobWidgetInstall::SaveExceptionData(const Jobs::JobExceptionBase &e) { - m_exceptionCaught = static_cast(e.getParam()); + m_exceptionCaught = static_cast(e.getParam()); m_exceptionMessage = e.GetMessage(); } diff --git a/src/jobs/widget_install/job_widget_install.h b/src/jobs/widget_install/job_widget_install.h index b323cc3..0027080 100644 --- a/src/jobs/widget_install/job_widget_install.h +++ b/src/jobs/widget_install/job_widget_install.h @@ -33,8 +33,23 @@ #include #include "widget_installer_struct.h" +using namespace Jobs::Exceptions; + namespace Jobs { namespace WidgetInstall { +enum class ConfigureResult +{ + Ok, + Deferred, + Updated, + Failed, + Failed_InvalidConfig, + Failed_LowerVersion, + Failed_AlreadyInstalled, + Failed_WidgetRunning, + Failed_DrmError, +}; + class JobWidgetInstall : public Job, public JobProgressBase make it base template class?? - Exceptions::Type m_exceptionCaught; + Jobs::Exceptions::Type m_exceptionCaught; std::string m_exceptionMessage; WidgetUpdateInfo m_widgetUpdateInfo; bool m_needEncryption; bool m_isDRM; - enum class ConfigureResult - { - Ok, Failed, Deferred, Updated - }; - ConfigureResult ConfigureInstallation(const std::string &widgetSource, const WrtDB::ConfigParserData &configData, diff --git a/src/jobs/widget_install/task_ace_check.cpp b/src/jobs/widget_install/task_ace_check.cpp index 2697a9c..c8fdbe6 100644 --- a/src/jobs/widget_install/task_ace_check.cpp +++ b/src/jobs/widget_install/task_ace_check.cpp @@ -81,7 +81,7 @@ void TaskAceCheck::StepAceCheck() dao.getHandle(), &policyResult); if (ACE_OK != ret) { - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " + ThrowMsg(Exceptions::AceCheckFailed, "Instalation failure. " "ACE check failure"); } @@ -133,7 +133,7 @@ void TaskAceCheck::StepProcessAceResponse() ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(), &list); if (ACE_OK != ret) { - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " + ThrowMsg(Exceptions::AceCheckFailed, "Instalation failure. " "ACE failure"); } delete[] list.items; @@ -165,7 +165,7 @@ void TaskAceCheck::StepProcessAceResponse() if (ACE_OK != ret) { LogError("Error in ace_set_feature"); - ThrowMsg(Exceptions::NotAllowed, "Instalation failure. " + ThrowMsg(Exceptions::AceCheckFailed, "Instalation failure. " "ace_set_feature failure."); } return; @@ -182,7 +182,7 @@ void TaskAceCheck::StepCheckAceResponse() if (m_context.featureLogic->isRejected()) { LogError("Installation failure. Some devCap was not accepted by ACE."); ThrowMsg( - Exceptions::NotAllowed, + Exceptions::AceCheckFailed, "Instalation failure. " "Some deviceCap was not accepted by ACE."); } diff --git a/src/jobs/widget_install/task_certify.cpp b/src/jobs/widget_install/task_certify.cpp index 32007ab..88b8fc4 100644 --- a/src/jobs/widget_install/task_certify.cpp +++ b/src/jobs/widget_install/task_certify.cpp @@ -229,7 +229,7 @@ void TaskCertify::stepSignature() SignatureFinder signatureFinder(widgetPath); if (SignatureFinder::NO_ERROR != signatureFinder.find(signatureFiles)) { LogError("Error in Signature Finder"); - ThrowMsg(Exceptions::InvalidPackage, + ThrowMsg(Exceptions::SignatureNotFound, "Error openig temporary widget directory"); } @@ -279,14 +279,14 @@ void TaskCertify::stepSignature() if (result == WrtSignatureValidator::SIGNATURE_REVOKED) { LogWarning("Certificate is REVOKED"); - ThrowMsg(Exceptions::InvalidPackage, + ThrowMsg(Exceptions::CertificateExpired, "Certificate is REVOKED"); } if (result == WrtSignatureValidator::SIGNATURE_INVALID) { LogWarning("Signature is INVALID"); // TODO change exception name - ThrowMsg(Exceptions::InvalidPackage, + ThrowMsg(Exceptions::SignatureInvalid, "Invalid Package"); } @@ -307,10 +307,9 @@ void TaskCertify::stepSignature() // now signature _must_ be verified processDistributorSignature(data); } - } Catch(ParserSchemaException::Base) { LogError("Error occured in ParserSchema."); - ReThrowMsg(Exceptions::InvalidPackage, + ReThrowMsg(Exceptions::SignatureInvalid, "Error occured in ParserSchema."); } } @@ -478,13 +477,13 @@ void TaskCertify::stepVerifyUpdate() oldCertificate->getBase64()); LogDebug("new widget's author signer certificate : " << newCertificate->getBase64()); - ThrowMsg(Exceptions::InvalidPackage, + ThrowMsg(Exceptions::NotMatchedCertification, "Author signer certificates doesn't match \ between old widget and installing widget"); } } else { if (!(NULL == newCertificate.Get() && NULL == oldCertificate.Get())) { - ThrowMsg(Exceptions::InvalidPackage, + ThrowMsg(Exceptions::NotMatchedCertification, "Author signer certificates doesn't match \ between old widget and installing widget"); } diff --git a/src/jobs/widget_install/task_commons.cpp b/src/jobs/widget_install/task_commons.cpp index ff1006a..cd643ec 100644 --- a/src/jobs/widget_install/task_commons.cpp +++ b/src/jobs/widget_install/task_commons.cpp @@ -75,7 +75,7 @@ std::string createTempPath(bool preload) } // Create new path if (!WrtUtilMakeDir(tempPath, TEMPORARY_PATH_MODE)) { - ThrowMsg(Exceptions::InternalError, + ThrowMsg(Exceptions::FileOperationFailed, "Failed to create temporary directory"); } @@ -85,7 +85,7 @@ std::string createTempPath(bool preload) void createTempPath(const std::string& path) { if (!WrtUtilMakeDir(path, TEMPORARY_PATH_MODE)) { - ThrowMsg(Exceptions::InternalError, + ThrowMsg(Exceptions::FileOperationFailed, "Failed to create temporary directory"); } } diff --git a/src/jobs/widget_install/task_database.cpp b/src/jobs/widget_install/task_database.cpp index 7708055..6f5d039 100755 --- a/src/jobs/widget_install/task_database.cpp +++ b/src/jobs/widget_install/task_database.cpp @@ -85,7 +85,7 @@ void TaskDatabase::StepWrtDBInsert() { LogError( "Given tizenId not found for update installation (Same GUID?)"); - ThrowMsg(Exceptions::InvalidPackage, + ThrowMsg(Exceptions::DatabaseFailure, "Given tizenId not found for update installation"); } WidgetDAO::registerOrUpdateWidget( diff --git a/src/jobs/widget_install/task_encrypt_resource.cpp b/src/jobs/widget_install/task_encrypt_resource.cpp index b88c27f..ee55ea5 100644 --- a/src/jobs/widget_install/task_encrypt_resource.cpp +++ b/src/jobs/widget_install/task_encrypt_resource.cpp @@ -99,7 +99,7 @@ FILE* openFile(const std::string& path, const std::string& mode) if (NULL == result) { - ThrowMsg(Jobs::WidgetInstall::Exceptions::InternalError, + ThrowMsg(Jobs::WidgetInstall::Exceptions::EncryptionFailed, "Could not open file " << path); } @@ -129,7 +129,7 @@ std::size_t readBytes(unsigned char* buffer, std::size_t count, FILE* stream) { if (EINTR != error) { - ThrowMsg(Jobs::WidgetInstall::Exceptions::InternalError, + ThrowMsg(Jobs::WidgetInstall::Exceptions::ErrorExternalInstallingFailure, "Error while reading data" << " [" << DPL::GetErrnoString(error) << "]"); } @@ -161,7 +161,7 @@ void writeBytes(unsigned char* buffer, std::size_t count, FILE* stream) if ((bytesWritten != bytesToWrite) && (EINTR != errno)) { int error = errno; - ThrowMsg(Jobs::WidgetInstall::Exceptions::InternalError, + ThrowMsg(Jobs::WidgetInstall::Exceptions::EncryptionFailed, "Error while writing data" << " [" << DPL::GetErrnoString(error) << "]"); } @@ -252,7 +252,7 @@ void TaskEncryptResource::EncryptDirectory(std::string path) int error = errno; LogWarning(__PRETTY_FUNCTION__ << ": fts_open failed with error: " << strerror(error)); - ThrowMsg(Exceptions::InternalError, "Error reading directory: " + ThrowMsg(Exceptions::EncryptionFailed, "Error reading directory: " << path); } @@ -283,7 +283,7 @@ void TaskEncryptResource::EncryptDirectory(std::string path) << ftsent->fts_path << " with error: " << strerror(ftsent->fts_errno)); - ThrowMsg(Exceptions::InternalError, "Error reading file"); + ThrowMsg(Exceptions::EncryptionFailed, "Error reading file"); break; } } @@ -297,100 +297,93 @@ void TaskEncryptResource::EncryptDirectory(std::string path) void TaskEncryptResource::EncryptFile(const std::string &fileName) { - try - { - LogDebug("Encrypt file: " << fileName); - std::string encFile = fileName + ".enc"; - - struct stat info; - memset(&info, 0, sizeof(info)); - if (stat(fileName.c_str(), &info) != 0) - { - int error = errno; - ThrowMsg(Exceptions::InternalError, - "Could not access file " << fileName << - "[" << DPL::GetErrnoString(error) << "]"); - } - const std::size_t fileSize = info.st_size; - - DPL::ScopedFClose inFile(openFile(fileName, "r")); - DPL::ScopedFClose outFile(openFile(encFile, "w")); + LogDebug("Encrypt file: " << fileName); + std::string encFile = fileName + ".enc"; - const std::size_t chunkSize = (fileSize > ENCRYPTION_CHUNK_MAX_SIZE - ? ENCRYPTION_CHUNK_MAX_SIZE : fileSize); - - std::unique_ptr inChunk(new unsigned char[chunkSize]); - std::unique_ptr outChunk; - - std::size_t bytesRead = 0; - using namespace Tizen::Base; + struct stat info; + memset(&info, 0, sizeof(info)); + if (stat(fileName.c_str(), &info) != 0) + { + int error = errno; + ThrowMsg(Exceptions::EncryptionFailed, + "Could not access file " << fileName << + "[" << DPL::GetErrnoString(error) << "]"); + } + const std::size_t fileSize = info.st_size; - std::string pkgid = - DPL::ToUTF8String(m_context.widgetConfig.tzAppid).c_str(); - const byte *b_pkgid = reinterpret_cast( - pkgid.c_str()); - ByteBuffer appInfo; - appInfo.Construct(pkgid.length()); - appInfo.SetArray(b_pkgid, 0, pkgid.length()); - appInfo.Flip(); + DPL::ScopedFClose inFile(openFile(fileName, "r")); + DPL::ScopedFClose outFile(openFile(encFile, "w")); - do - { - bytesRead = readBytes(inChunk.get(), chunkSize, inFile.Get()); - if (0 != bytesRead) { - ByteBuffer *getBuffer = EncryptChunkByTrustZone( - &appInfo, - inChunk.get(), bytesRead); - int decBufSize = getBuffer->GetRemaining(); - - outChunk.reset(new unsigned char[decBufSize]); - memcpy(outChunk.get(), getBuffer->GetPointer(), getBuffer->GetRemaining()); - getBuffer->Reset(); - - char writeSize[ENCRYPTION_DEC_CHUNK_SIZE]; - memset(writeSize, 0x00, ENCRYPTION_DEC_CHUNK_SIZE); - std::stringstream toString; - toString << decBufSize; - strncpy(writeSize, toString.str().c_str(), toString.str().length()); - - writeBytes((unsigned char*)writeSize, - ENCRYPTION_DEC_CHUNK_SIZE, outFile.Get()); - writeBytes(outChunk.get(), decBufSize, outFile.Get()); - } + const std::size_t chunkSize = (fileSize > ENCRYPTION_CHUNK_MAX_SIZE + ? ENCRYPTION_CHUNK_MAX_SIZE : fileSize); - } while (0 == std::feof(inFile.Get())); + std::unique_ptr inChunk(new unsigned char[chunkSize]); + std::unique_ptr outChunk; - outFile.Reset(); - inFile.Reset(); + std::size_t bytesRead = 0; + using namespace Tizen::Base; - LogDebug("File encrypted successfully"); - LogDebug("Remove plain-text file: " << fileName); - if (0 != unlink(fileName.c_str())) - { - Throw(Exceptions::InternalError); - } + std::string pkgid = + DPL::ToUTF8String(m_context.widgetConfig.tzAppid).c_str(); + const byte *b_pkgid = reinterpret_cast( + pkgid.c_str()); + ByteBuffer appInfo; + appInfo.Construct(pkgid.length()); + appInfo.SetArray(b_pkgid, 0, pkgid.length()); + appInfo.Flip(); - LogDebug("Rename encrypted file"); - if (0 != std::rename(encFile.c_str(), fileName.c_str())) - { - Throw(Exceptions::InternalError); + do + { + bytesRead = readBytes(inChunk.get(), chunkSize, inFile.Get()); + if (0 != bytesRead) { + ByteBuffer *getBuffer = EncryptChunkByTrustZone( + &appInfo, + inChunk.get(), bytesRead); + int decBufSize = getBuffer->GetRemaining(); + + outChunk.reset(new unsigned char[decBufSize]); + memcpy(outChunk.get(), getBuffer->GetPointer(), getBuffer->GetRemaining()); + getBuffer->Reset(); + + char writeSize[ENCRYPTION_DEC_CHUNK_SIZE]; + memset(writeSize, 0x00, ENCRYPTION_DEC_CHUNK_SIZE); + std::stringstream toString; + toString << decBufSize; + strncpy(writeSize, toString.str().c_str(), toString.str().length()); + + writeBytes((unsigned char*)writeSize, + ENCRYPTION_DEC_CHUNK_SIZE, outFile.Get()); + writeBytes(outChunk.get(), decBufSize, outFile.Get()); } - std::string realPath = fileName; - realPath.replace(0, - m_context.locations->getTemporaryRootDir().length(), - m_context.locations->getSourceDir()); + } while (0 == std::feof(inFile.Get())); - WrtDB::EncryptedFileInfo fileInfo; - fileInfo.fileName = DPL::FromUTF8String(realPath); - fileInfo.fileSize = fileSize; + outFile.Reset(); + inFile.Reset(); - m_context.widgetConfig.encryptedFiles.insert(fileInfo); + LogDebug("File encrypted successfully"); + LogDebug("Remove plain-text file: " << fileName); + if (0 != unlink(fileName.c_str())) + { + Throw(Exceptions::EncryptionFailed); } - Catch (Exceptions::InternalError) + + LogDebug("Rename encrypted file"); + if (0 != std::rename(encFile.c_str(), fileName.c_str())) { - ReThrowMsg(Exceptions::ExtractFileFailed, fileName); + Throw(Exceptions::EncryptionFailed); } + + std::string realPath = fileName; + realPath.replace(0, + m_context.locations->getTemporaryRootDir().length(), + m_context.locations->getSourceDir()); + + WrtDB::EncryptedFileInfo fileInfo; + fileInfo.fileName = DPL::FromUTF8String(realPath); + fileInfo.fileSize = fileSize; + + m_context.widgetConfig.encryptedFiles.insert(fileInfo); } } //namespace WidgetInstall diff --git a/src/jobs/widget_install/task_file_manipulation.cpp b/src/jobs/widget_install/task_file_manipulation.cpp index db50d6b..4c34b5d 100644 --- a/src/jobs/widget_install/task_file_manipulation.cpp +++ b/src/jobs/widget_install/task_file_manipulation.cpp @@ -158,7 +158,7 @@ void TaskFileManipulation::StepCreatePrivateStorageDir() if (euidaccess(storagePath.c_str(), F_OK) != 0) { if (!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)) { LogError("Failed to create directory for private storage"); - ThrowMsg(Exceptions::InternalError, + ThrowMsg(Exceptions::FileOperationFailed, "Failed to create directory for private storage"); } // '5000' is default uid, gid for applications. @@ -169,7 +169,7 @@ void TaskFileManipulation::StepCreatePrivateStorageDir() WEBAPP_DEFAULT_UID, WEBAPP_DEFAULT_GID) != 0) { - ThrowMsg(Exceptions::InternalError, + ThrowMsg(Exceptions::FileOperationFailed, "Chown to invaild user"); } } else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) { @@ -180,15 +180,15 @@ void TaskFileManipulation::StepCreatePrivateStorageDir() WEBAPP_DEFAULT_UID, WEBAPP_DEFAULT_GID) != 0) { - ThrowMsg(Exceptions::InternalError, + ThrowMsg(Exceptions::FileOperationFailed, "Chown to invaild user"); } if (chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) { - ThrowMsg(Exceptions::InternalError, + ThrowMsg(Exceptions::FileOperationFailed, "chmod to 0700"); } } else { - ThrowMsg(Exceptions::InternalError, + ThrowMsg(Exceptions::FileOperationFailed, "No access to private storage."); } } @@ -212,7 +212,7 @@ void TaskFileManipulation::StepRenamePath() if (!(rename(m_context.locations->getTemporaryPackageDir().c_str(), instDir.c_str()) == 0)) { - ThrowMsg(Exceptions::UnknownError, + ThrowMsg(Exceptions::FileOperationFailed, "Error occurs during renaming widget folder"); } m_context.job->UpdateProgress( @@ -298,7 +298,7 @@ void TaskFileManipulation::StepInstallToExternal() if (!_FolderCopy(m_context.locations->getTemporaryPackageDir(), m_context.locations->getSourceDir())) { - ThrowMsg(Exceptions::UnknownError, + ThrowMsg(Exceptions::ErrorExternalInstallingFailure, "Error occurs during renaming widget folder"); } } diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp index 400fc65..96eb80a 100644 --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -142,7 +142,7 @@ void TaskManifestFile::stepCreateExecFile() if(error) LogPedantic("Failed to make a symbolic name for a file " << "[" << DPL::GetErrnoString(error) << "]"); - ThrowMsg(Exceptions::InstallationFailed, + ThrowMsg(Exceptions::FileOperationFailed, "Symbolic link creating is not done."); } m_context.job->UpdateProgress( @@ -461,7 +461,7 @@ void TaskManifestFile::getFileList(const char* path, DIR* dir = opendir(path); if (!dir) { LogError("icon directory doesn't exist"); - ThrowMsg(Exceptions::InternalError, path); + ThrowMsg(Exceptions::FileOperationFailed, path); } struct dirent entry; @@ -514,7 +514,7 @@ void TaskManifestFile::stepParseManifest() if (code != 0) { LogError("Manifest parser error: " << code); - ThrowMsg(ManifestParsingError, "Parser returncode: " << code); + ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code); } // TODO : It will be removed. AIL update is temporary code request by pkgmgr @@ -534,7 +534,7 @@ void TaskManifestFile::stepParseUpgradedManifest() if (code != 0) { LogError("Manifest parser error: " << code); - ThrowMsg(ManifestParsingError, "Parser returncode: " << code); + ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code); } // TODO : It will be removed. AIL update is temporary code request by pkgmgr @@ -862,7 +862,7 @@ void TaskManifestFile::stepAbortParseManifest() if (0 != code) { LogWarning("Manifest parser error: " << code); - ThrowMsg(ManifestParsingError, "Parser returncode: " << code); + ThrowMsg(Exceptions::ManifestInvalid, "Parser returncode: " << code); } int ret = unlink(DPL::ToUTF8String(manifest_file).c_str()); if (0 != ret) { diff --git a/src/jobs/widget_install/task_plugins_copy.cpp b/src/jobs/widget_install/task_plugins_copy.cpp index bf295ea..f5cad57 100644 --- a/src/jobs/widget_install/task_plugins_copy.cpp +++ b/src/jobs/widget_install/task_plugins_copy.cpp @@ -90,7 +90,7 @@ void TaskPluginsCopy::StepFindPlugins() dir = opendir(m_npsource.c_str()); if (dir == NULL) { LogError("Unable to open plugins directory"); - ThrowMsg(Exceptions::InternalError, "Unable to read plugins directory"); + ThrowMsg(Exceptions::FileOperationFailed, "Unable to read plugins directory"); } std::string tempname; struct dirent entry; @@ -173,7 +173,7 @@ void TaskPluginsCopy::StepCopyPlugins() LogDebug("Creating destination plugin directory"); if (!WrtUtilMakeDir(m_npdestination, InstallationPluginsDirMode)) { LogError("Failed to create directory for plugins"); - ThrowMsg(Exceptions::InternalError, + ThrowMsg(Exceptions::FileOperationFailed, "Failed to create directory for plugins"); } @@ -189,7 +189,7 @@ void TaskPluginsCopy::StepCopyPlugins() if (rename(source.c_str(), destination.c_str()) != 0) { LogError("Failed to move " << source << " to " << destination); LogError("(errno: " << errno << ")"); - ThrowMsg(Exceptions::InternalError, "Failed to copy plugin file"); + ThrowMsg(Exceptions::FileOperationFailed, "Failed to copy plugin file"); } } @@ -202,7 +202,7 @@ void TaskPluginsCopy::StepCopyPlugins() * architectures). */ if (!WrtUtilRemove(source)) { LogError("Failed to plugins source remove directory"); - ThrowMsg(Exceptions::InternalError, + ThrowMsg(Exceptions::FileOperationFailed, "Failed to plugins source remove directory"); } LogDebug("Plugins copying step ended"); diff --git a/src/jobs/widget_install/task_recovery.cpp b/src/jobs/widget_install/task_recovery.cpp index c6a5e9b..6e963b8 100644 --- a/src/jobs/widget_install/task_recovery.cpp +++ b/src/jobs/widget_install/task_recovery.cpp @@ -66,14 +66,14 @@ void TaskRecovery::StepCreateCheckFile() int ret = fsync(temp->_fileno); fclose(temp); if (-1 == ret) { - ThrowMsg(Exceptions::InternalError, "Fail to fsync for recovery."); + ThrowMsg(Exceptions::FileOperationFailed, "Fail to fsync for recovery."); } m_context.installInfo = infoPath.str(); LogDebug("Create file : " << m_context.installInfo); } else { - ThrowMsg(Exceptions::InternalError, "Fail to create file for recovery."); + ThrowMsg(Exceptions::FileOperationFailed, "Fail to create file for recovery."); } m_context.job->UpdateProgress( diff --git a/src/jobs/widget_install/task_update_files.cpp b/src/jobs/widget_install/task_update_files.cpp index 76ff014..eeecb86 100644 --- a/src/jobs/widget_install/task_update_files.cpp +++ b/src/jobs/widget_install/task_update_files.cpp @@ -99,7 +99,7 @@ void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list, DIR* pkgDir = opendir(dirPath.c_str()); if (!pkgDir) { LogError("Package directory " << dirPath << " doesn't exist"); - ThrowMsg(Exceptions::InternalError, + ThrowMsg(Exceptions::BackupFailed, "Error occurs during read \ directory"); } @@ -116,7 +116,7 @@ void TaskUpdateFiles::ReadDirList(std::string dirPath, ExistFileList &list, std::string dirName = dirent.d_name; std::string absFileName = dirPath + "/" + dirName; if (stat(absFileName.c_str(), &statInfo) != 0) { - ThrowMsg(Exceptions::InternalError, "Error occurs read file"); + ThrowMsg(Exceptions::BackupFailed, "Error occurs read file"); } if (S_ISDIR(statInfo.st_mode)) { @@ -167,7 +167,7 @@ void TaskUpdateFiles::StepResourceFilesBackup() struct stat sInfo; if (stat(resFile.c_str(), &sInfo) != 0) { - ThrowMsg(Exceptions::InternalError, "Error occurs read file"); + ThrowMsg(Exceptions::BackupFailed, "Error occurs read file"); } if (S_ISDIR(sInfo.st_mode)) { diff --git a/src/jobs/widget_install/widget_install_errors.h b/src/jobs/widget_install/widget_install_errors.h index 79e8407..8d4dcd8 100644 --- a/src/jobs/widget_install/widget_install_errors.h +++ b/src/jobs/widget_install/widget_install_errors.h @@ -25,79 +25,68 @@ #include #include +#include //TODO SafeException(...) +using namespace Jobs::Exceptions; + namespace Jobs { namespace WidgetInstall { namespace Exceptions { -enum Type -{ - Success, ///< Success - - ErrorInvalidWidgetPackage, ///< invalid widget package - ErrorWidgetDoesNotExist, ///< given tizenAppId is invalid, no app - ErrorAreadyUninstalling, ///< Widget is already being uninstalled - ErrorInvalidPackage, ///< Widget signature is invalid. - ErrorInternal, ///< Internal error due to inconsistency - ErrorNotAllowed, ///< Widget installation or update not - // allowed - ///< because violation of policy ocurred - ErrorDeferred, ///< Widget installation was deferred and - // will be continued when possible - ErrorDatabaseFailure, ///< Failure in database - ErrorRemovingFolderFailure, ///< Failure in removing existing widget - // folder - ErrorCreateVconfFailure, ///< Failure in creating vconf - ErrorInstallOspServcie, ///< Failure in installing osp service - ErrorUpdateWidget, ///< Failure in widget update. - ErrorInstallToExt, ///< Failure in install to sdcard - ErrorUnknown ///< Temporary error. Try to not use this. -}; DECLARE_JOB_EXCEPTION_BASE(JobExceptionBase, Base, ErrorUnknown) -// PREPARE -DECLARE_JOB_EXCEPTION(Base, NotAllowed, ErrorNotAllowed) -DECLARE_JOB_EXCEPTION(Base, Deferred, ErrorDeferred) +DECLARE_JOB_EXCEPTION(Base, OpenZipFailed, ErrorPackageInvalid) +DECLARE_JOB_EXCEPTION(Base, ZipEmpty, ErrorPackageInvalid) +DECLARE_JOB_EXCEPTION(Base, ExtractFileFailed, ErrorPackageInvalid) +DECLARE_JOB_EXCEPTION(Base, EmptyPluginsDirectory, ErrorPackageInvalid) +DECLARE_JOB_EXCEPTION(Base, PluginsSubdirectory, ErrorPackageInvalid) -//UNZIP -DECLARE_JOB_EXCEPTION(Base, OpenZipFailed, ErrorInvalidWidgetPackage) -DECLARE_JOB_EXCEPTION(Base, ZipEmpty, ErrorInvalidWidgetPackage) -DECLARE_JOB_EXCEPTION(Base, ExtractFileFailed, ErrorInvalidWidgetPackage) -DECLARE_JOB_EXCEPTION(Base, InternalError, ErrorInternal) +DECLARE_JOB_EXCEPTION(Base, PackageLowerVersion, ErrorPackageLowerVersion) -//CERTIFY -DECLARE_JOB_EXCEPTION(Base, InvalidPackage, ErrorInvalidPackage) +DECLARE_JOB_EXCEPTION(Base, ManifestInvalid, ErrorManifestInvalid) -//WCONFIG -DECLARE_JOB_EXCEPTION(Base, WidgetConfigFileInvalid, ErrorInvalidWidgetPackage) -DECLARE_JOB_EXCEPTION(Base, InstallationFailed, ErrorInvalidWidgetPackage) -DECLARE_JOB_EXCEPTION(Base, UnknownError, ErrorUnknown) -DECLARE_JOB_EXCEPTION(Base, DatabaseFailure, ErrorDatabaseFailure) -DECLARE_JOB_EXCEPTION(Base, RemovingFolderFailure, ErrorRemovingFolderFailure) -DECLARE_JOB_EXCEPTION(Base, RemovingFileFailure, ErrorRemovingFolderFailure) -DECLARE_JOB_EXCEPTION(Base, CreateVconfFailure, ErrorCreateVconfFailure) +DECLARE_JOB_EXCEPTION(Base, WidgetConfigFileNotFound, ErrorConfigNotFound) +DECLARE_JOB_EXCEPTION(Base, WidgetConfigFileInvalid, ErrorConfigInvalid) -DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorUnknown) +DECLARE_JOB_EXCEPTION(Base, SignatureNotFound, ErrorSignatureNotFound) -DECLARE_JOB_EXCEPTION(Base, ErrorExternalInstallingFailure, ErrorInstallToExt) +DECLARE_JOB_EXCEPTION(Base, SignatureInvalid, ErrorSignatureInvalid) -// Installation osp service -DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie) -//UPDATE -DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorUpdateWidget) -DECLARE_JOB_EXCEPTION(Base, InsertNewWidgetFailed, ErrorUpdateWidget) -DECLARE_JOB_EXCEPTION(Base, RemoveBackupFailed, ErrorUpdateWidget) +DECLARE_JOB_EXCEPTION(Base, SignatureVerificationFailed, ErrorSignatureVerificationFailed) + +DECLARE_JOB_EXCEPTION(Base, RootCertificateNotFound, ErrorRootCertificateNotFound) -//Database -DECLARE_JOB_EXCEPTION(Base, UpdateFailed, ErrorInvalidWidgetPackage) +DECLARE_JOB_EXCEPTION(Base, CertificationInvaid, ErrorCertificationInvaid) +DECLARE_JOB_EXCEPTION(Base, NotMatchedCertification, ErrorCertificationInvaid) -// Plugins copy errors -DECLARE_JOB_EXCEPTION(Base, EmptyPluginsDirectory, ErrorInvalidWidgetPackage) -DECLARE_JOB_EXCEPTION(Base, PluginsSubdirectory, ErrorInvalidWidgetPackage) +DECLARE_JOB_EXCEPTION(Base, CertificateChainVerificationFailed, ErrorCertificateChainVerificationFailed) -DECLARE_JOB_EXCEPTION(Base, SetCertificateInfoFailed, ErrorUnknown) +DECLARE_JOB_EXCEPTION(Base, CertificateExpired, ErrorCertificateExpired) + +DECLARE_JOB_EXCEPTION(Base, NotAllowed, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, Deferred, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, WidgetRunningError, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, DRMFailed, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, DatabaseFailure, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, RemovingFolderFailure, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, RemovingFileFailure, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, CreateVconfFailure, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, FileOperationFailed, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, InstallToExternalFailed, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, InsertNewWidgetFailed, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, RemoveBackupFailed, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, UpdateFailed, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, SetCertificateInfoFailed, ErrorFatalError) +DECLARE_JOB_EXCEPTION(Base, ErrorExternalInstallingFailure, ErrorFatalError) + +DECLARE_JOB_EXCEPTION(Base, PackageAlreadyInstalled, ErrorPackageAlreadyInstalled) +DECLARE_JOB_EXCEPTION(Base, AceCheckFailed, ErrorAceCheckFailed) +DECLARE_JOB_EXCEPTION(Base, EncryptionFailed, ErrorEncryptionFailed) +DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie) } //namespace } //namespace } //namespace diff --git a/src/jobs/widget_install/widget_installer_struct.h b/src/jobs/widget_install/widget_installer_struct.h index 797aa2d..7f35574 100644 --- a/src/jobs/widget_install/widget_installer_struct.h +++ b/src/jobs/widget_install/widget_installer_struct.h @@ -39,7 +39,7 @@ typedef void (*InstallerFinishedCallback)( void *userParam, std::string tizenId, - Jobs::WidgetInstall::Exceptions::Type); + Jobs::Exceptions::Type); typedef void (*InstallerProgressCallback)(void *userParam, ProgressPercent percent, diff --git a/src/jobs/widget_uninstall/job_widget_uninstall.cpp b/src/jobs/widget_uninstall/job_widget_uninstall.cpp index 65a1a41..2005f21 100644 --- a/src/jobs/widget_uninstall/job_widget_uninstall.cpp +++ b/src/jobs/widget_uninstall/job_widget_uninstall.cpp @@ -217,7 +217,7 @@ void JobWidgetUninstall::SendFinishedSuccess() LogDebug("Call widget uninstall success finishedCallback"); getInstallerStruct().finishedCallback(getInstallerStruct().userParam, getRemovedTizenId(), - Exceptions::Success); + Jobs::Exceptions::Success); } void JobWidgetUninstall::SendFinishedFailure() @@ -240,7 +240,7 @@ void JobWidgetUninstall::SendFinishedFailure() void JobWidgetUninstall::SaveExceptionData(const Jobs::JobExceptionBase &e) { - m_exceptionCaught = static_cast(e.getParam()); + m_exceptionCaught = static_cast(e.getParam()); m_exceptionMessage = e.GetMessage(); } diff --git a/src/jobs/widget_uninstall/job_widget_uninstall.h b/src/jobs/widget_uninstall/job_widget_uninstall.h index 9ab0ee0..d38d551 100644 --- a/src/jobs/widget_uninstall/job_widget_uninstall.h +++ b/src/jobs/widget_uninstall/job_widget_uninstall.h @@ -40,7 +40,7 @@ class JobWidgetUninstall : UninstallerContext m_context; //TODO move it to base class of all jobs - Exceptions::Type m_exceptionCaught; + Jobs::Exceptions::Type m_exceptionCaught; std::string m_exceptionMessage; public: diff --git a/src/jobs/widget_uninstall/widget_uninstall_errors.h b/src/jobs/widget_uninstall/widget_uninstall_errors.h index 81de95d..842896c 100644 --- a/src/jobs/widget_uninstall/widget_uninstall_errors.h +++ b/src/jobs/widget_uninstall/widget_uninstall_errors.h @@ -24,29 +24,23 @@ #define WIDGET_UNINSTALL_ERRORS_H_ #include +#include + +using namespace Jobs::Exceptions; namespace Jobs { namespace WidgetUninstall { namespace Exceptions { -enum Type -{ - Success, - - ErrorWidgetDoesNotExist, - ErrorAlreadyUninstalling, - ErrorDatabaseFailure, - ErrorUninstallOspSvcFailed, - ErrorPlatformAPI, - ErrorUnknown -}; DECLARE_JOB_EXCEPTION_BASE(JobExceptionBase, Base, ErrorUnknown) -DECLARE_JOB_EXCEPTION(Base, DatabaseFailure, ErrorDatabaseFailure) -DECLARE_JOB_EXCEPTION(Base, AlreadyUninstalling, ErrorAlreadyUninstalling) -DECLARE_JOB_EXCEPTION(Base, WidgetNotExist, ErrorWidgetDoesNotExist) -DECLARE_JOB_EXCEPTION(Base, UninstallOspSvcFailed, ErrorUninstallOspSvcFailed) -DECLARE_JOB_EXCEPTION(Base, PlatformAPIFailure, ErrorPlatformAPI) +DECLARE_JOB_EXCEPTION(Base, DatabaseFailure, ErrorWidgetUninstallationFailed) +DECLARE_JOB_EXCEPTION(Base, AlreadyUninstalling, + ErrorWidgetUninstallationFailed) +DECLARE_JOB_EXCEPTION(Base, WidgetNotExist, ErrorWidgetUninstallationFailed) +DECLARE_JOB_EXCEPTION(Base, UninstallOspSvcFailed, + ErrorWidgetUninstallationFailed) +DECLARE_JOB_EXCEPTION(Base, PlatformAPIFailure, ErrorWidgetUninstallationFailed) } //namespace } //namespace } //namespace diff --git a/src/jobs/widget_uninstall/widget_uninstaller_struct.h b/src/jobs/widget_uninstall/widget_uninstaller_struct.h index 83714a9..3f33e4b 100644 --- a/src/jobs/widget_uninstall/widget_uninstaller_struct.h +++ b/src/jobs/widget_uninstall/widget_uninstaller_struct.h @@ -36,7 +36,7 @@ typedef void (*UninstallerFinishedCallback)( void *userParam, std::string tizenId, - Jobs::WidgetUninstall::Exceptions::Type); + Jobs::Exceptions::Type); typedef void (*UninstallerProgressCallback)( void *userParam, diff --git a/src/pkg-manager/pkgmgr_signal.h b/src/pkg-manager/pkgmgr_signal.h index f5fecd7..eef6ae5 100644 --- a/src/pkg-manager/pkgmgr_signal.h +++ b/src/pkg-manager/pkgmgr_signal.h @@ -37,6 +37,7 @@ namespace PackageManager { #define PKGMGR_END_FAILURE "fail" #define PKGMGR_PROGRESS_KEY "install_percent" #define PKGMGR_ICON_PATH "icon_path" +#define PKGMGR_ERROR "error" typedef pkgmgr_installer* PkgmgrHandle; diff --git a/src/wrt-installer/installer_callbacks_translate.cpp b/src/wrt-installer/installer_callbacks_translate.cpp index 275c3fd..fda2937 100644 --- a/src/wrt-installer/installer_callbacks_translate.cpp +++ b/src/wrt-installer/installer_callbacks_translate.cpp @@ -28,7 +28,7 @@ namespace InstallerCallbacksTranslate { // callback for finished install void installFinishedCallback(void *userParam, std::string tizenId, - Jobs::WidgetInstall::Exceptions::Type status) + Jobs::Exceptions::Type status) { Assert(userParam != NULL); @@ -40,44 +40,102 @@ void installFinishedCallback(void *userParam, WrtErrStatus errorStatus; switch (status) { - case Jobs::WidgetInstall::Exceptions::Success: + case Jobs::Exceptions::Success: errorStatus = WRT_SUCCESS; break; - case Jobs::WidgetInstall::Exceptions::ErrorWidgetDoesNotExist: - errorStatus = WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST; + case Jobs::Exceptions::ErrorPackageNotFound: + errorStatus = WRT_INSTALLER_ERROR_PACKAGE_NOT_FOUND; break; - case Jobs::WidgetInstall::Exceptions::ErrorAreadyUninstalling: - errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING; + case Jobs::Exceptions::ErrorPackageLowerVersion: + errorStatus = WRT_INSTALLER_ERROR_PACKAGE_LOWER_VERSION; break; - case Jobs::WidgetInstall::Exceptions::ErrorInvalidPackage: - errorStatus = WRT_INSTALLER_ERROR_INVALID_CERTIFICATE; + case Jobs::Exceptions::ErrorManifestNotFound: + errorStatus = WRT_INSTALLER_ERROR_MANIFEST_NOT_FOUND; break; - case Jobs::WidgetInstall::Exceptions::ErrorInternal: - errorStatus = WRT_INSTALLER_ERROR_INTERNAL; + case Jobs::Exceptions::ErrorManifestInvalid: + errorStatus = WRT_INSTALLER_ERROR_MANIFEST_INVALID; break; - case Jobs::WidgetInstall::Exceptions::ErrorNotAllowed: - errorStatus = WRT_INSTALLER_ERROR_NOT_ALLOWED; + case Jobs::Exceptions::ErrorConfigNotFound: + errorStatus = WRT_INSTALLER_CONFIG_NOT_FOUND; break; - case Jobs::WidgetInstall::Exceptions::ErrorDeferred: - errorStatus = WRT_INSTALLER_ERROR_DEFERRED; + case Jobs::Exceptions::ErrorConfigInvalid: + errorStatus = WRT_INSTALLER_ERROR_CONFIG_INVALID; break; - case Jobs::WidgetInstall::Exceptions::ErrorDatabaseFailure: - errorStatus = WRT_INSTALLER_ERROR_DATABASE_FAILURE; + case Jobs::Exceptions::ErrorSignatureNotFound: + errorStatus = WRT_INSTALLER_ERROR_SIGNATURE_NOT_FOUND; break; - case Jobs::WidgetInstall::Exceptions::ErrorInstallOspServcie: - errorStatus = WRT_INSTALLER_ERROR_OSPSVC; + case Jobs::Exceptions::ErrorSignatureInvalid: + errorStatus = WRT_INSTALLER_ERROR_SIGNATURE_INVALID; break; - case Jobs::WidgetInstall::Exceptions::ErrorUnknown: - errorStatus = WRT_INSTALLER_ERROR_UNKNOWN; + case Jobs::Exceptions::ErrorSignatureVerificationFailed: + errorStatus = WRT_INSTALLER_ERROR_SIGNATURE_VERIFICATION_FAILED; + break; + + case Jobs::Exceptions::ErrorRootCertificateNotFound: + errorStatus = WRT_INSTALLER_ERROR_ROOT_CERTIFICATE_NOT_FOUND; + break; + + case Jobs::Exceptions::ErrorCertificationInvaid: + errorStatus = WRT_INSTALLER_ERROR_CERTIFICATION_INVAID; + break; + + case + Jobs::Exceptions::ErrorCertificateChainVerificationFailed: + errorStatus = + WRT_INSTALLER_ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED; + break; + + case Jobs::Exceptions::ErrorCertificateExpired: + errorStatus = WRT_INSTALLER_ERROR_CERTIFICATE_EXPIRED; + break; + + case Jobs::Exceptions::ErrorInvalidPrivilege: + errorStatus = WRT_INSTALLER_ERROR_INVALID_PRIVILEGE; + break; + + case Jobs::Exceptions::ErrorMenuIconNotFound: + errorStatus = WRT_INSTALLER_ERROR_MENU_ICON_NOT_FOUND; + break; + + case Jobs::Exceptions::ErrorFatalError: + errorStatus = WRT_INSTALLER_ERROR_FATAL_ERROR; + break; + + case Jobs::Exceptions::ErrorOutOfStorage: + errorStatus = WRT_INSTALLER_ERROR_OUT_OF_STORAGE; + break; + + case Jobs::Exceptions::ErrorOutOfMemory: + errorStatus = WRT_INSTALLER_ERROR_OUT_OF_MEMORY; + break; + + case Jobs::Exceptions::ErrorPackageAlreadyInstalled: + errorStatus = WRT_INSTALLER_ERROR_PACKAGE_ALREADY_INSTALLED; + break; + + case Jobs::Exceptions::ErrorAceCheckFailed: + errorStatus = WRT_INSTALLER_ERROR_ACE_CHECK_FAILED; + break; + + case Jobs::Exceptions::ErrorManifestCreateFailed: + errorStatus = WRT_INSTALLER_ERROR_MANIFEST_CREATE_FAILED; + break; + + case Jobs::Exceptions::ErrorEncryptionFailed: + errorStatus = WRT_INSTALLER_ERROR_ENCRYPTION_FAILED; + break; + + case Jobs::Exceptions::ErrorInstallOspServcie: + errorStatus = WRT_INSTALLER_ERROR_INSTALL_OSP_SERVCIE; break; default: @@ -95,7 +153,7 @@ void installFinishedCallback(void *userParam, // callback for finished install void uninstallFinishedCallback(void *userParam, std::string tizenId, - Jobs::WidgetUninstall::Exceptions::Type status) + Jobs::Exceptions::Type status) { Assert(userParam != NULL); @@ -107,27 +165,15 @@ void uninstallFinishedCallback(void *userParam, WrtErrStatus errorStatus; switch (status) { - case Jobs::WidgetUninstall::Exceptions::Success: + case Jobs::Exceptions::Success: errorStatus = WRT_SUCCESS; break; - case Jobs::WidgetUninstall::Exceptions::ErrorAlreadyUninstalling: - errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING; - break; - - case Jobs::WidgetUninstall::Exceptions::ErrorWidgetDoesNotExist: - errorStatus = WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST; - break; - - case Jobs::WidgetUninstall::Exceptions::ErrorDatabaseFailure: - errorStatus = WRT_INSTALLER_ERROR_DATABASE_FAILURE; - break; - - case Jobs::WidgetUninstall::Exceptions::ErrorUninstallOspSvcFailed: - errorStatus = WRT_INSTALLER_ERROR_OSPSVC; + case Jobs::Exceptions::ErrorWidgetUninstallationFailed: + errorStatus = WRT_INSTALLER_ERROR_UNINSTALLATION_FAILED; break; - case Jobs::WidgetUninstall::Exceptions::ErrorUnknown: + case Jobs::Exceptions::ErrorUnknown: errorStatus = WRT_INSTALLER_ERROR_UNKNOWN; break; @@ -144,7 +190,7 @@ void uninstallFinishedCallback(void *userParam, } void pluginInstallFinishedCallback(void *userParam, - Jobs::PluginInstall::Exceptions::Type status) + Jobs::Exceptions::Type status) { Assert(userParam); @@ -156,24 +202,11 @@ void pluginInstallFinishedCallback(void *userParam, WrtErrStatus errorStatus; switch (status) { - case Jobs::PluginInstall::Exceptions::Success: + case Jobs::Exceptions::Success: errorStatus = WRT_SUCCESS; break; - case Jobs::PluginInstall::Exceptions::WrongPluginPath: - errorStatus = WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH; - break; - case Jobs::PluginInstall::Exceptions::MetafileError: - errorStatus = WRT_PLUGIN_INSTALLER_ERROR_METAFILE; - break; - case Jobs::PluginInstall::Exceptions::AlreadyInstalled: - errorStatus = WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED; - break; - case Jobs::PluginInstall::Exceptions::LoadingLibraryError: - errorStatus = WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR; - break; - case Jobs::PluginInstall::Exceptions::InstallationWaiting: - errorStatus = WRT_PLUGIN_INSTALLER_ERROR_WAITING; - break; + case Jobs::Exceptions::ErrorPluginInstallationFailed: + errorStatus = WRT_INSTALLER_ERROR_PLUGIN_INSTALLATION_FAILED; default: errorStatus = WRT_INSTALLER_ERROR_UNKNOWN; break; diff --git a/src/wrt-installer/installer_callbacks_translate.h b/src/wrt-installer/installer_callbacks_translate.h index c98e448..5322078 100644 --- a/src/wrt-installer/installer_callbacks_translate.h +++ b/src/wrt-installer/installer_callbacks_translate.h @@ -63,14 +63,14 @@ struct PluginStatusCallbackStruct void installFinishedCallback(void *userParam, std::string tizenId, - Jobs::WidgetInstall::Exceptions::Type status); + Jobs::Exceptions::Type status); void uninstallFinishedCallback(void *userParam, std::string tizenId, - Jobs::WidgetUninstall::Exceptions::Type status); + Jobs::Exceptions::Type status); void pluginInstallFinishedCallback(void *userParam, - Jobs::PluginInstall::Exceptions::Type status); + Jobs::Exceptions::Type status); // callback for progress of install OR uninstall void installProgressCallback(void *userParam, diff --git a/src/wrt-installer/wrt_installer.cpp b/src/wrt-installer/wrt_installer.cpp index 27d75f3..72c689e 100644 --- a/src/wrt-installer/wrt_installer.cpp +++ b/src/wrt-installer/wrt_installer.cpp @@ -390,7 +390,7 @@ void WrtInstaller::installPluginsStep() } else if (!PluginUtils::lockPluginInstallation()) { LogError("Failed to open plugin installation lock file" " Plugins are currently installed by other process"); - staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK, + staticWrtPluginInstallationCallback(WRT_INSTALLER_ERROR_PLUGIN_INSTALLATION_FAILED, this); return; } @@ -647,58 +647,180 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId, } switch (status) { - case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE: + case WRT_INSTALLER_ERROR_PACKAGE_NOT_FOUND: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - widget package does not exist\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_PACKAGE_INVALID: This->m_returnStatus = 1; //this status is specific fprintf(stderr, "## wrt-installer : %s %s has failed - invalid widget package\n", tizenId.c_str(), printMsg.c_str()); break; - case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST: - fprintf(stderr, "## wrt-installer : %s %s has failed - widget package does not exist\n", + case WRT_INSTALLER_ERROR_PACKAGE_LOWER_VERSION: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - given" + " version is lower than existing version\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_MANIFEST_NOT_FOUND: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - manifest" + " file doesn't find in package.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_MANIFEST_INVALID: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "invalid manifestx.xml\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_CONFIG_NOT_FOUND: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "config.xml does not exist\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_CONFIG_INVALID: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "invalid config.xml\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_SIGNATURE_NOT_FOUND: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "signature doesn't exist in package.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_SIGNATURE_INVALID: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "invalid signature.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_SIGNATURE_VERIFICATION_FAILED: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "signature verification failed.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_ROOT_CERTIFICATE_NOT_FOUND: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "root certificate could not find.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_CERTIFICATION_INVAID: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "invalid certification.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "certificate chain verification failed.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_CERTIFICATE_EXPIRED: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "certificate expired.\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_INVALID_PRIVILEGE: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "invalid privilege\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_MENU_ICON_NOT_FOUND: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "menu icon could not find\n", + tizenId.c_str(), printMsg.c_str()); + break; + + case WRT_INSTALLER_ERROR_FATAL_ERROR: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "fatal error\n", tizenId.c_str(), printMsg.c_str()); break; - case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING: - fprintf(stderr, "## wrt-installer : %s %s has failed - already uninstalling\n", + case WRT_INSTALLER_ERROR_OUT_OF_STORAGE: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "out of storage\n", tizenId.c_str(), printMsg.c_str()); break; - case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE: - fprintf(stderr,"## wrt-installer : %s %s has failed - invalid certificate - invalid signature\n", + case WRT_INSTALLER_ERROR_OUT_OF_MEMORY: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "out of memory\n", tizenId.c_str(), printMsg.c_str()); break; - case WRT_INSTALLER_ERROR_ALREADY_INSTALLED: - fprintf(stderr,"## wrt-installer : %s %s has failed - already installed\n", + case WRT_INSTALLER_ERROR_PACKAGE_ALREADY_INSTALLED: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "package already installed\n", tizenId.c_str(), printMsg.c_str()); break; - case WRT_INSTALLER_ERROR_INTERNAL: - fprintf(stderr,"## wrt-installer : %s %s has failed - internal error\n", + case WRT_INSTALLER_ERROR_ACE_CHECK_FAILED: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "ace check failure\n", tizenId.c_str(), printMsg.c_str()); break; - case WRT_INSTALLER_ERROR_NOT_ALLOWED: - fprintf(stderr,"## wrt-installer : %s %s has failed - installation or update not allowed; invalid" - " mode\n", tizenId.c_str(), printMsg.c_str()); + case WRT_INSTALLER_ERROR_MANIFEST_CREATE_FAILED: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "to create manifest failed\n", + tizenId.c_str(), printMsg.c_str()); break; - case WRT_INSTALLER_ERROR_DEFERRED: - fprintf(stderr,"## wrt-installer : deferred: widget update will continue after the widget" - " has been stopped\n"); + case WRT_INSTALLER_ERROR_ENCRYPTION_FAILED: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "encryption of resource failed\n", + tizenId.c_str(), printMsg.c_str()); break; - case WRT_INSTALLER_ERROR_DATABASE_FAILURE: - fprintf(stderr,"## wrt-installer : %s %s has failed - database failure\n", + case WRT_INSTALLER_ERROR_INSTALL_OSP_SERVCIE: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "installation of osp service failed\n", tizenId.c_str(), printMsg.c_str()); break; - case WRT_INSTALLER_ERROR_OSPSVC: - fprintf(stderr,"## wrt-installer : %s %s has failed - during installation or" - " uninstallation osp service\n", tizenId.c_str(), - printMsg.c_str()); + case WRT_INSTALLER_ERROR_UNINSTALLATION_FAILED: + This->m_returnStatus = 1; //this status is specific + fprintf(stderr, "## wrt-installer : %s %s has failed - " + "widget uninstallation failed\n", + tizenId.c_str(), printMsg.c_str()); break; + case WRT_INSTALLER_ERROR_UNKNOWN: fprintf(stderr,"## wrt-installer : %s %s has failed - unknown error\n", tizenId.c_str(), printMsg.c_str()); @@ -791,30 +913,12 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status, // Failure LogWarning("One of the plugins installation failed!: " << path); - if (WRT_PLUGIN_INSTALLER_ERROR_WAITING == status) { - LogInfo("Plugin installation is waiting for dependencies"); - fprintf(stderr, "## wrt-installer : plugin installation failed [%s]\n", - path.c_str()); - } - switch (status) { - case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH: - LogError("failed: wrong path to plugin directory\n"); - break; - - case WRT_PLUGIN_INSTALLER_ERROR_METAFILE: - LogError("failed: plugin metafile error\n"); - break; - - case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED: - LogError("failed: plugin already installed\n"); - break; - - case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR: - LogError("failed: plugin library: missing symbols or structures\n"); + case WRT_INSTALLER_ERROR_PLUGIN_INSTALLATION_FAILED: + LogError("failed: plugin installation failed\n"); break; - case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN: + case WRT_INSTALLER_ERROR_UNKNOWN: LogError("failed: unknown error\n"); break; diff --git a/src/wrt-installer/wrt_installer_api.cpp b/src/wrt-installer/wrt_installer_api.cpp index f6bb4fb..2497b33 100644 --- a/src/wrt-installer/wrt_installer_api.cpp +++ b/src/wrt-installer/wrt_installer_api.cpp @@ -179,25 +179,10 @@ void plugin_install_status_cb(WrtErrStatus status, LogError("Fail to install plugin : " << plugin_data->plugin_path); switch (status) { - case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH: + case WRT_INSTALLER_ERROR_PLUGIN_INSTALLATION_FAILED: LogError("Failed : Plugin install path is wrong"); break; - case WRT_PLUGIN_INSTALLER_ERROR_METAFILE: - LogError("Failed : Plugin Metafile Error"); - break; - case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED: - LogError("Failed : This Plugin is already installed"); - break; - case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR: - LogError("Failed : Library Error. Missing symbol or structures"); - break; - case WRT_PLUGIN_INSTALLER_ERROR_WAITING: - LogError("Failed : Waiting for plugin dependencies"); - break; - case WRT_PLUGIN_INSTALLER_ERROR_LOCK: - LogError("Failed : Lock Error"); - break; - case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN: + case WRT_INSTALLER_ERROR_UNKNOWN: LogError("Failed : Unkown Error"); break; default: @@ -232,7 +217,7 @@ EXPORT_API int wrt_installer_init(void *userdata, // Check paths if (!checkPaths()) { if (callback) { - callback(WRT_ERROR_NO_PATH, userdata); + callback(WRT_INSTALLER_ERROR_FATAL_ERROR, userdata); } return TRUE; } @@ -280,7 +265,7 @@ EXPORT_API int wrt_installer_init(void *userdata, LogError("Internal Error during Init:"); DPL::Exception::DisplayKnownException(ex); if (callback) { - callback(WRT_ERROR_INTERNAL, userdata); + callback(WRT_INSTALLER_ERROR_FATAL_ERROR, userdata); } return FALSE; } @@ -545,7 +530,7 @@ EXPORT_API int wrt_installer_init_for_tests(void *userdata, // Check paths if (!checkPaths()) { if (callback) { - callback(WRT_ERROR_NO_PATH, userdata); + callback(WRT_INSTALLER_ERROR_FATAL_ERROR, userdata); } return TRUE; } @@ -563,7 +548,7 @@ EXPORT_API int wrt_installer_init_for_tests(void *userdata, LogError("Internal Error during Init:"); DPL::Exception::DisplayKnownException(ex); if (callback) { - callback(WRT_ERROR_INTERNAL, userdata); + callback(WRT_INSTALLER_ERROR_FATAL_ERROR, userdata); } return FALSE; } @@ -605,11 +590,11 @@ EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & tzAppid, return WRT_SUCCESS; } catch (WidgetDAOReadOnly::Exception::WidgetNotExist&) { LogError("Error package name is not found"); - return WRT_ERROR_PKGNAME_NOT_FOUND; + return WRT_INSTALLER_ERROR_FATAL_ERROR; } catch (const DPL::Exception& ex) { LogError("Internal Error during get widget id by package name"); DPL::Exception::DisplayKnownException(ex); - return WRT_ERROR_INTERNAL; + return WRT_INSTALLER_ERROR_FATAL_ERROR; } } #ifdef __cplusplus diff --git a/src/wrt-installer/wrt_type.h b/src/wrt-installer/wrt_type.h index f061805..9781131 100644 --- a/src/wrt-installer/wrt_type.h +++ b/src/wrt-installer/wrt_type.h @@ -43,45 +43,44 @@ typedef enum /* Generic success */ WRT_SUCCESS = 0, /*< Success*/ - /* Error result */ - WRT_ERROR_INTERNAL = -128, /*< Internal library error. - * Should never occur */ + /* pkgmgr error */ + WRT_INSTALLER_ERROR_PACKAGE_NOT_FOUND, ///< + WRT_INSTALLER_ERROR_PACKAGE_INVALID, ///< invalid widget package + WRT_INSTALLER_ERROR_PACKAGE_LOWER_VERSION, ///< given version is lower than existing version + WRT_INSTALLER_ERROR_MANIFEST_NOT_FOUND, ///< + WRT_INSTALLER_ERROR_MANIFEST_INVALID, ///< + WRT_INSTALLER_CONFIG_NOT_FOUND, ///< couldn't find config.xml + ///< in package. + WRT_INSTALLER_ERROR_CONFIG_INVALID, ///< invalid config.xml + WRT_INSTALLER_ERROR_SIGNATURE_NOT_FOUND, ///< signature file not exist. + WRT_INSTALLER_ERROR_SIGNATURE_INVALID, ///< invalid signature file + WRT_INSTALLER_ERROR_SIGNATURE_VERIFICATION_FAILED, ///< failure in verificate + ///< signature + WRT_INSTALLER_ERROR_ROOT_CERTIFICATE_NOT_FOUND, ///< couldn't find root certificate. + WRT_INSTALLER_ERROR_CERTIFICATION_INVAID, ///< invalid certification + WRT_INSTALLER_ERROR_CERTIFICATE_CHAIN_VERIFICATION_FAILED, ///< failure in verificate + ///< certification chain. + WRT_INSTALLER_ERROR_CERTIFICATE_EXPIRED, ///< expire cerification. + WRT_INSTALLER_ERROR_INVALID_PRIVILEGE, ///< invalid privilege. + WRT_INSTALLER_ERROR_MENU_ICON_NOT_FOUND, ///< + WRT_INSTALLER_ERROR_FATAL_ERROR, ///< failure in db operation or file opertion.. + WRT_INSTALLER_ERROR_OUT_OF_STORAGE, ///< failure in shortage of memory + WRT_INSTALLER_ERROR_OUT_OF_MEMORY, ///< failure in shortage of RAM - WRT_ERROR_PKGNAME_NOT_FOUND, /*< package name was not found */ - WRT_ERROR_NO_PATH, /*