#include <dpl/mutable_task_list.h>
+#include <job_types.h>
+
namespace Jobs {
class JobExceptionBase;
-/**
- * @brief Defines installation and uninstallation type.
- */
-enum InstallationType
-{
- Installation, ///< defines install process
- Uninstallation, ///< defines uninstall process
- PluginInstallation ///< defines plugin installation process
-};
typedef int JobHandle;
--- /dev/null
+/*
+ * Copyright (c) 2013 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_types.h
+ * @author Tomasz Iwanek ()
+ */
+#ifndef JOB_TYPES_H
+#define JOB_TYPES_H
+
+namespace Jobs {
+/**
+ * @brief Defines installation and uninstallation type.
+ */
+enum InstallationType
+{
+ UnknownInstallation, ///< defines installation of yet unknown type
+ NewInstallation, ///< defines install process
+ UpdateInstallation, ///< defines update installation
+ Uninstallation, ///< defines uninstall process
+ PluginInstallation ///< defines plugin installation process
+};
+
+}
+
+#endif // JOB_TYPES_H
std::string const &widgetPath,
const Jobs::WidgetInstall::WidgetInstallationStruct &
installerStruct) :
- Job(Installation),
+ Job(UnknownInstallation),
JobContextBase<Jobs::WidgetInstall::WidgetInstallationStruct>(installerStruct),
m_exceptionCaught(Jobs::Exceptions::Success)
{
if (GetProgressFlag() != false) {
if (GetInstallerStruct().progressCallback != NULL) {
// send progress signal of pkgmgr
- std::ostringstream percent;
- percent << static_cast<int>(GetProgressPercent());
- GetInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_PROGRESS_KEY,
- percent.str());
+ GetInstallerStruct().pkgmgrInterface->sendProgress(GetProgressPercent());
_D("Call widget install progressCallback");
GetInstallerStruct().progressCallback(
if (GetProgressFlag() != false) {
if (GetInstallerStruct().progressCallback != NULL) {
// send progress signal of pkgmgr
- GetInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_ICON_PATH,
- path);
+ GetInstallerStruct().pkgmgrInterface->sendIconPath(path);
}
}
}
TizenAppId& tizenId = m_installerContext.widgetConfig.tzAppid;
// send signal of pkgmgr
- GetInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_END_KEY,
- PKGMGR_END_SUCCESS);
+ GetInstallerStruct().pkgmgrInterface->endJob(m_exceptionCaught);
_D("Call widget install successfinishedCallback");
GetInstallerStruct().finishedCallback(GetInstallerStruct().userParam,
TizenAppId & tizenId = m_installerContext.widgetConfig.tzAppid;
_D("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);
+ GetInstallerStruct().pkgmgrInterface->endJob(m_exceptionCaught);
GetInstallerStruct().finishedCallback(GetInstallerStruct().userParam,
DPL::ToUTF8String(
void TaskConfiguration::PkgmgrStartStep()
{
- pkgMgrInterface()->sendSignal(
- PKGMGR_PROGRESS_KEY,
- PKGMGR_START_VALUE);
+ pkgMgrInterface()->sendProgress(0);
}
void TaskConfiguration::AppendTasklistStep()
m_context.isUpdateMode = true;
//if update, notify pkgmgr that this is update
- pkgMgrInterface()->sendSignal( PKGMGR_START_KEY, PKGMGR_START_UPDATE);
+ pkgMgrInterface()->startJob(InstallationType::UpdateInstallation);
}
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
- pkgMgrInterface()->sendSignal(PKGMGR_START_KEY, PKGMGR_START_INSTALL);
+ pkgMgrInterface()->startJob(InstallationType::NewInstallation);
m_context.isUpdateMode = false;
// send start signal of pkgmgr
if (GetInstallerStruct().pkgmgrInterface->setPkgname(m_context.tzPkgid))
{
- GetInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_START_KEY,
- PKGMGR_START_UNINSTALL);
+ GetInstallerStruct().pkgmgrInterface->startJob(InstallationType::Uninstallation);
}
AddTask(new TaskCheck(m_context));
{
using namespace PackageManager;
// send signal of pkgmgr
- GetInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_END_KEY,
- PKGMGR_END_SUCCESS);
+ GetInstallerStruct().pkgmgrInterface->endJob(m_exceptionCaught);
_D("Call widget uninstall success finishedCallback");
GetInstallerStruct().finishedCallback(GetInstallerStruct().userParam,
_E("Message: %s", m_exceptionMessage.c_str());
// send signal of pkgmgr
- GetInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_END_KEY,
- PKGMGR_END_FAILURE);
+ GetInstallerStruct().pkgmgrInterface->endJob(m_exceptionCaught);
_D("Call widget uninstall failure finishedCallback");
GetInstallerStruct().finishedCallback(GetInstallerStruct().userParam,
* @brief
*/
+#include <dpl/lexical_cast.h>
+
#include <pkgmgr_installer.h>
#include <pkg-manager/pkgmgr_signal.h>
#include <installer_log.h>
+namespace {
+// package type sent in every signal
+const char PKGMGR_WEBAPP_TYPE[] = "wgt";
+
+// notification about opoeration start
+const char PKGMGR_START_KEY[] = "start";
+
+// value for new installation
+const char PKGMGR_START_INSTALL[] = "install";
+
+// value for update installation
+const char PKGMGR_START_UPDATE[] = "update";
+
+// value for uninstallation
+const char PKGMGR_START_UNINSTALL[] = "uninstall";
+
+// notification about progress of installation with percentage number
+const char PKGMGR_PROGRESS_KEY[] = "install_percent";
+
+// notification about icon path for installation frontend
+const char PKGMGR_ICON_PATH[] = "icon_path";
+
+// notification about error before end with given error code
+// (currently, same as backend exit status)
+const char PKGMGR_ERROR[] = "error";
+
+// notification about end of installation with status
+const char PKGMGR_END_KEY[] = "end";
+
+// success value of end of installation
+const char PKGMGR_END_SUCCESS[] = "ok";
+
+// failure value of end of installation
+const char PKGMGR_END_FAILURE[] = "fail";
+}
+
namespace PackageManager {
PkgmgrSignal::PkgmgrSignal() :
m_initialized(false),
m_handle(NULL),
- m_reqType(PKGMGR_REQ_INVALID)
+ m_reqType(RequestType::UNSUPPORTED)
{}
PkgmgrSignal::~PkgmgrSignal()
if (!pkgmgr_installer_receive_request(
m_handle, argc, argv))
{
- m_reqType = pkgmgr_installer_get_request_type(m_handle);
- if (m_reqType != PKGMGR_REQ_INSTALL &&
- m_reqType != PKGMGR_REQ_UNINSTALL &&
- m_reqType != PKGMGR_REQ_REINSTALL)
+ auto pkgmgrtype = pkgmgr_installer_get_request_type(m_handle);
+ switch(pkgmgrtype)
+ {
+ case PKGMGR_REQ_INSTALL:
+ m_reqType = RequestType::INSTALL;
+ break;
+ case PKGMGR_REQ_UNINSTALL:
+ m_reqType = RequestType::UNINSTALL;
+ break;
+ case PKGMGR_REQ_REINSTALL:
+ m_reqType = RequestType::REINSTALL;
+ break;
+ default:
+ m_reqType = RequestType::UNSUPPORTED;
+ break;
+ }
+
+ if (m_reqType == RequestType::UNSUPPORTED)
{
_E("Fail to get request type of pkgmgr");
pkgmgr_installer_free(m_handle);
return true;
}
+bool PkgmgrSignal::startJob(Jobs::InstallationType type)
+{
+ switch(type)
+ {
+ case Jobs::InstallationType::NewInstallation:
+ sendSignal(PKGMGR_START_KEY, PKGMGR_START_INSTALL);
+ break;
+ case Jobs::InstallationType::UpdateInstallation:
+ sendSignal(PKGMGR_START_KEY, PKGMGR_START_UPDATE);
+ break;
+ case Jobs::InstallationType::Uninstallation:
+ sendSignal(PKGMGR_START_KEY, PKGMGR_START_UNINSTALL);
+ break;
+ default:
+ _E("Trying to send unknown installation type to pkgmgr");
+ return false;
+ }
+ return true;
+}
+
+bool PkgmgrSignal::endJob(Jobs::Exceptions::Type ecode)
+{
+ if(ecode == Jobs::Exceptions::Type::Success)
+ {
+ return sendSignal(PKGMGR_END_KEY, PKGMGR_END_SUCCESS);
+ }
+ else
+ {
+ sendSignal(PKGMGR_ERROR, DPL::lexical_cast<std::string>(ecode));
+ return sendSignal(PKGMGR_END_KEY, PKGMGR_END_FAILURE);
+ }
+}
+
+bool PkgmgrSignal::sendProgress(int percent)
+{
+ return sendSignal(PKGMGR_PROGRESS_KEY, DPL::lexical_cast<std::string>(percent));
+}
+
+bool PkgmgrSignal::sendIconPath(const std::string & iconpath)
+{
+ return sendSignal(PKGMGR_ICON_PATH, iconpath);
+}
+
bool PkgmgrSignal::sendSignal(const std::string& key,
const std::string& value) const
{
return m_pkgname;
}
-int PkgmgrSignal::getRequestedType() const
+PkgmgrSignal::RequestType PkgmgrSignal::getRequestedType() const
{
if (!m_initialized) {
_E("PkgmgrSingal not yet intialized");
#define WRT_PKGMGR_SIGNAL_H_
#include <pkg-manager/pkgmgr_signal_interface.h>
-#include <pkgmgr_installer.h>
-namespace PackageManager {
-#define PKGMGR_WEBAPP_TYPE "wgt"
-#define PKGMGR_START_KEY "start"
-#define PKGMGR_START_INSTALL "install"
-#define PKGMGR_START_UPDATE "update"
-#define PKGMGR_START_UNINSTALL "uninstall"
-#define PKGMGR_END_KEY "end"
-#define PKGMGR_END_SUCCESS "ok"
-#define PKGMGR_END_FAILURE "fail"
-#define PKGMGR_PROGRESS_KEY "install_percent"
-#define PKGMGR_ICON_PATH "icon_path"
-#define PKGMGR_ERROR "error"
-#define PKGMGR_START_VALUE "0"
+struct pkgmgr_installer;
-typedef pkgmgr_installer* PkgmgrHandle;
+namespace PackageManager {
class PkgmgrSignal : public IPkgmgrSignal
{
- public:
+public:
+ enum class RequestType
+ {
+ UNSUPPORTED,
+ INSTALL,
+ UNINSTALL,
+ REINSTALL
+ };
+
bool initialize(int argc, char* argv[]);
bool deinitialize();
bool setPkgname(const std::string& name);
- bool sendSignal(const std::string& key, const std::string& value) const;
std::string getPkgname() const;
- int getRequestedType() const;
+ RequestType getRequestedType() const;
std::string getCallerId() const;
+ bool startJob(Jobs::InstallationType type);
+ bool endJob(Jobs::Exceptions::Type ecode);
+ bool sendProgress(int percent);
+ bool sendIconPath(const std::string & iconpath);
+
PkgmgrSignal();
virtual ~PkgmgrSignal();
- private:
+protected:
+ bool sendSignal(const std::string& key, const std::string& value) const;
+
+private:
bool m_initialized;
- PkgmgrHandle m_handle;
+ pkgmgr_installer* m_handle;
std::string m_type;
std::string m_pkgname;
- int m_reqType;
+ RequestType m_reqType;
std::string m_callerId;
};
} // PackageManager
#include <pkg-manager/pkgmgr_signal_interface.h>
+#include<dpl/unused.h>
+
namespace PackageManager {
class PkgmgrSignalDummy : public IPkgmgrSignal
{
virtual ~PkgmgrSignalDummy()
{}
- bool setPkgname(const std::string& /*name*/)
- {
- return false;
- }
- bool sendSignal(const std::string& /*key*/, const std::string& /*value*/) const
+ bool setPkgname(const std::string& /*name*/)
{
return false;
}
{
return "";
}
+
+ bool startJob(Jobs::InstallationType type DPL_UNUSED)
+ {
+ return false;
+ }
+
+ bool endJob(Jobs::Exceptions::Type ecode DPL_UNUSED)
+ {
+ return false;
+ }
+
+ bool sendProgress(int percent DPL_UNUSED)
+ {
+ return false;
+ }
+
+ bool sendIconPath(const std::string & iconpath DPL_UNUSED)
+ {
+ return false;
+ }
};
} // PkgmgrSignalDummy
#define WRT_PKGMGR_SIGNAL_INTERFACE_H_
#include <string>
+
+#include <job_types.h>
+#include <job_exception_error.h>
+
namespace PackageManager {
class IPkgmgrSignal
{
public:
virtual bool setPkgname(const std::string& name) = 0;
- virtual bool sendSignal(const std::string& key,
- const std::string& value) const = 0;
virtual std::string getPkgname() const = 0;
virtual std::string getCallerId() const = 0;
+
+ virtual bool startJob(Jobs::InstallationType type) = 0;
+ virtual bool endJob(Jobs::Exceptions::Type ecode) = 0;
+ virtual bool sendProgress(int percent) = 0;
+ virtual bool sendIconPath(const std::string & iconpath) = 0;
virtual ~IPkgmgrSignal(){}
};
} // IPkgmgrSignal
pkgmgrSignal->initialize(m_argc, m_argv);
- int reqType = pkgmgrSignal->getRequestedType();
+ PackageManager::PkgmgrSignal::RequestType reqType = pkgmgrSignal->getRequestedType();
pkgmgrSignalInterface =
std::static_pointer_cast<PackageManager::IPkgmgrSignal>(
pkgmgrSignal);
switch (reqType) {
- case PKGMGR_REQ_INSTALL:
+ case PackageManager::PkgmgrSignal::RequestType::INSTALL:
m_packagePath = m_argv[4];
struct stat info;
if (-1 != stat(m_argv[4], &info) && S_ISDIR(info.st_mode)) {
}
AddStep(&WrtInstaller::installStep);
break;
- case PKGMGR_REQ_UNINSTALL:
+ case PackageManager::PkgmgrSignal::RequestType::UNINSTALL:
{
m_name = m_argv[4];
pkgmgrinfo_pkginfo_h handle = NULL;
}
break;
}
- case PKGMGR_REQ_REINSTALL:
+ case PackageManager::PkgmgrSignal::RequestType::REINSTALL:
m_packagePath = m_argv[4];
m_installMode.command = InstallMode::Command::REINSTALL;
m_installMode.extension = InstallMode::ExtensionType::DIR;
WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
Assert(This);
- DPL::String resultMsg;
std::string printMsg = "initialization";
if (WRT_SUCCESS != status) {
printMsg.c_str());
_D("Status succesfull");
This->m_returnStatus = 0;
- resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
This->DPL::Event::ControllerEventHandler<WRTInstallerNS::
NextStepEvent>
Assert(This);
Step current = This->GetCurrentStep();
- DPL::String resultMsg;
std::string printMsg;
if (current == &WrtInstaller::installStep) {
- resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
printMsg = "installation";
} else if (current == &WrtInstaller::uninstallPkgNameStep ||
current == &WrtInstaller::unistallWgtFileStep)
{
- resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
printMsg = "uninstallation";
}
printMsg.c_str());
_D("Status succesfull");
This->m_returnStatus = 0;
- resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
if (This->m_installMode.installTime == InstallMode::InstallTime::PRELOAD &&
!This->m_packagePath.empty())