struct timeval tv;
gettimeofday(&tv, NULL);
srand(time(NULL) + tv.tv_usec);
- WrtDB::DbWidgetHandle handle;
- do {
- handle = rand() % INT_MAX + 1;
- LogInfo("Random widget handle: " << handle);
- } while (WidgetDAOReadOnly::isWidgetInstalled(handle));
- m_installerContext.widgetHandle = handle; //TODO: mvoe to wrt-commons (ace_widget_handle_t not int needed)
m_installerContext.m_quiet = m_jobStruct.m_quiet;
if(!browserRequest)
if (needEncryption) {
AddTask(new TaskEncryptResource(m_installerContext));
}
- AddTask(new TaskDatabase(m_installerContext)); //TODO: this should belast task (or almost)
AddTask(new TaskFileManipulation(m_installerContext));
// TODO: Update progress information for this task
AddTask(new TaskPrivateStorage(m_installerContext));
- AddTask(new TaskAceCheck(m_installerContext));
+
//This is sort of quick solution, because ACE verdicts are based upon
//data from DAO (DB). So AceCheck for now has to be AFTER DbUpdate
//task.
AddTask(new TaskLiveboxConf(m_installerContext));
#endif
AddTask(new TaskPluginsCopy(m_installerContext));
+
+ AddTask(new TaskDatabase(m_installerContext));
+ AddTask(new TaskAceCheck(m_installerContext));
} else if (result == ConfigureResult::Updated) {
LogInfo("Configure installation updated");
LogInfo("Widget Update");
AddTask(new TaskCertify(m_installerContext));
AddTask(new TaskUpdateFiles(m_installerContext));
- AddTask(new TaskDatabase(m_installerContext)); //TODO: this should belast task (or almost)
/* TODO : To backup file, save md5 values */
- AddTask(new TaskAceCheck(m_installerContext));
AddTask(new TaskSmack(m_installerContext));
AddTask(new TaskManifestFile(m_installerContext));
- AddTask(new TaskRemoveBackupFiles(m_installerContext));
if (m_installerContext.widgetConfig.pType ==
PKG_TYPE_TIZEN_WITHSVCAPP) {
AddTask(new TaskInstallOspsvc(m_installerContext));
}
+ AddTask(new TaskRemoveBackupFiles(m_installerContext));
#ifdef LB_SUPPORT
AddTask(new TaskLiveboxConf(m_installerContext));
#endif
AddTask(new TaskPluginsCopy(m_installerContext));
+
+ AddTask(new TaskDatabase(m_installerContext));
+
+ AddTask(new TaskAceCheck(m_installerContext));
+ //TODO: remove widgetHandle from this task and move before database task
+ // by now widget handle is needed in ace check
+ // Any error in acecheck while update will break widget
+
} else if (result == ConfigureResult::Deferred) {
// Installation is deferred
LogInfo("Configure installation deferred");
bool JobWidgetInstall::setTizenId(
const WrtDB::ConfigParserData &configInfo, ConfigureResult result)
{
- Assert(!!m_installerContext.widgetHandle
- && "Widget Handle should be initialized");
-
regex_t reg;
regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED);
struct stat dirStat;
LogDebug("Setting tizenId provided in config.xml: " << configInfo.tizenId);
if ((regexec(®, DPL::ToUTF8String(*(configInfo.tizenId)).c_str(),
static_cast<size_t>(0), NULL, 0) != REG_NOERROR) ||
- (stat((std::string(GlobalConfig::GetUserInstalledWidgetPath()) + "/"
- + DPL::ToUTF8String(*(configInfo.tizenId))).c_str(), &dirStat) == 0))
+ ((stat((std::string(GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+ + DPL::ToUTF8String(*(configInfo.tizenId))).c_str(), &dirStat) == 0)
+ && result != ConfigureResult::Updated))
{
//it is true when tizenId does not fit REG_TIZENID_PATTERN
LogError("tizen_id provided but not proper.");
return true;
}
-DPL::Optional<WidgetHandle> JobWidgetInstall::getNewWidgetHandle() const
-{
- return m_installerContext.widgetHandle;
-}
-
DPL::OptionalString JobWidgetInstall::getNewTizenId() const
{
return m_installerContext.widgetConfig.pkgname;
// Check policy
WidgetUpdateMode::Type updateTypeCheckBit;
- bool isUpdate = false;
JobWidgetInstall::ConfigureResult ret = ConfigureResult::Ok;
if (update.existingWidgetInfo.isExist == false) {
LogInfo("Widget info does not exist");
updateTypeCheckBit = WidgetUpdateMode::NotInstalled;
} else {
- LogInfo("Widget info exists. Handle: " <<
- update.existingWidgetInfo.existingHandle);
+ LogInfo("Widget info exists. PkgName: " <<
+ update.existingWidgetInfo.pkgname);
- DPL::OptionalString pkgname =
- WidgetDAOReadOnly(update.existingWidgetInfo.existingHandle).getPkgname();
+ DPL::OptionalString pkgname = update.existingWidgetInfo.pkgname;
if(pkgname.IsNull()) {
LogInfo("But package name doesn't exist");
return ConfigureResult::Failed;
} else {
using namespace PackageManager;
- LogInfo("WidgetHandle: " << m_installerContext.widgetHandle);
LogInfo("Tizen Id: " << m_installerContext.widgetConfig.pkgname);
configureWidgetLocation(widgetSource, browserRequest);
widgetGUID,
widgetVersion,
WidgetUpdateInfo::ExistingWidgetInfo(
- dao.getHandle(), dao.getVersion()));
+ *dao.getPkgname(), dao.getVersion()));
}
Catch(WidgetDAOReadOnly::Exception::WidgetNotExist)
{
void JobWidgetInstall::displayWidgetInfo()
{
- DPL::Optional<WidgetHandle> handle = getNewWidgetHandle();
- Assert(!!handle);
-
- WidgetDAOReadOnly dao(*handle);
+ WidgetDAOReadOnly dao(m_installerContext.locations->getPkgname());
std::ostringstream out;
WidgetLocalizedInfo localizedInfo =
- W3CFileLocalization::getLocalizedInfo(*handle);
+ W3CFileLocalization::getLocalizedInfo(dao.getHandle()); //TODO: pkgname arg
out << std::endl <<
"===================================== INSTALLED WIDGET INFO ========="\
out << std::endl << "Width: " << size.width;
out << std::endl << "Height: " << size.height;
out << std::endl << "Start File: " <<
- W3CFileLocalization::getStartFile(*handle);
+ W3CFileLocalization::getStartFile(dao.getHandle()); //TODO: pkgname arg
out << std::endl << "Version: " << dao.getVersion();
out << std::endl << "Licence: " <<
localizedInfo.license;
dao.isDistributorSigned();
out << std::endl << "Widget trusted: " << dao.isTrusted();
- OptionalWidgetIcon icon = W3CFileLocalization::getIcon(*handle);
+ OptionalWidgetIcon icon = W3CFileLocalization::getIcon(dao.getHandle()); //TODO: pkgname arg
DPL::OptionalString iconSrc =
!!icon ? icon->src : DPL::OptionalString::Null;
out << std::endl << "Icon: " << iconSrc;
JobWidgetInstall(std::string const & widgetPath,
const WidgetInstallationStruct &installerStruct);
- DPL::Optional<WidgetHandle> getNewWidgetHandle() const;
DPL::OptionalString getNewTizenId() const;
//overrides
void TaskAceCheck::StepPrepareForAce()
{
- Assert(!!m_context.widgetHandle);
+ WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
m_context.featureLogic =
- FeatureLogicPtr(new FeatureLogic(*m_context.widgetHandle));
+ FeatureLogicPtr(new FeatureLogic(dao.getHandle()));
m_context.job->UpdateProgress(
InstallerContext::INSTALL_ACE_PREPARE,
"Widget Access Control Check Prepared");
void TaskAceCheck::StepAceCheck()
{
-
+ WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
LogInfo("StepAceCheck!");
// This widget does not use any device cap
if (m_context.featureLogic->isDone()) {
LogInfo("StepAceCheck!");
LogInfo("DevCap is : " << deviceCap);
- Assert(!!m_context.widgetHandle);
std::string devCapStr = DPL::ToUTF8String(deviceCap);
ace_policy_result_t policyResult = ACE_DENY;
ace_return_t ret = ace_get_policy_result(
const_cast<const ace_resource_t>(devCapStr.c_str()),
- *m_context.widgetHandle,
+ dao.getHandle(),
&policyResult);
if (ACE_OK != ret) {
ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
void TaskAceCheck::StepProcessAceResponse()
{
+ WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
if (m_context.locations->browserRequest()) {
return;
}
list.items[i].smack_granted =
devCapsSmack[i] ? ACE_TRUE : ACE_FALSE;
}
- ace_return_t ret = ace_set_requested_dev_caps(*(m_context.widgetHandle), //TODO: (ace_widget_handle_t not int needed)
+ ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(), //TODO: (ace_widget_handle_t not int needed)
&list);
if (ACE_OK != ret) {
ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
i++;
}
- ret = ace_set_accepted_feature(
- *(m_context.widgetHandle),
- &featureList);
+ ret = ace_set_accepted_feature(dao.getHandle(), &featureList);
delete [] featureList.items;
for(;it != end; ++it){
LogInfo(" |- Feature: " << it->name << " has reject status: " << it->rejected);
if (it->rejected) {
- WrtDB::WidgetDAO dao(*(m_context.widgetHandle));
+ WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
dao.updateFeatureRejectStatus(*it);
}
}
//#include <dpl/wrt-dao-ro/config_parser_data.h>
#include <dpl/wrt-dao-rw/widget_dao.h>
#include <dpl/foreach.h>
+#include <dpl/utils/wrt_utility.h>
#include <dpl/log/log.h>
#include <dpl/assert.h>
//#include <dpl/wrt-dao-ro/global_config.h>
DPL::TaskDecl<TaskDatabase>(this),
m_context(context)
{
+ AddStep(&TaskDatabase::StepRegisterExternalFiles);
AddStep(&TaskDatabase::StepDBInsert);
AddAbortStep(&TaskDatabase::StepAbortDBInsert);
/* Set install Time */
time(&m_context.widgetConfig.installedTime);
- LogInfo("Registering widget...");
-
- WidgetDAO::registerWidget(
- *(m_context.widgetHandle),
- m_context.widgetConfig,
- m_context.wacSecurity);
+ if (m_context.existingWidgetInfo.isExist) //update
+ {
+ LogInfo("Registering widget... (update)");
+ WidgetDAO::registerOrUpdateWidget(
+ m_context.locations->getPkgname(),
+ m_context.widgetConfig,
+ m_context.wacSecurity);
+ }
+ else //new installation
+ {
+ LogInfo("Registering widget...");
+ WidgetDAO::registerWidget(
+ m_context.locations->getPkgname(),
+ m_context.widgetConfig,
+ m_context.wacSecurity);
+ }
FOREACH (cap, m_context.staticPermittedDevCaps) {
LogInfo("staticPermittedDevCaps : " << cap->first
<< " smack status: " << cap->second);
}
- Assert(!!m_context.widgetConfig.pkgname
- && "pkgName should be initialized");
-
- WrtDB::WidgetDAO widgetDao(*m_context.widgetHandle);
- widgetDao.setPkgName(m_context.widgetConfig.pkgname);
-
LogInfo("Widget registered");
}
Catch(WidgetDAO::Exception::DatabaseError)
"New Widget DB UPDATE Finished");
}
+void TaskDatabase::StepRegisterExternalFiles()
+{
+ WrtDB::ExternalLocationList externalLocationsUpdate = m_context.locations->listExternalLocations();
+ if (m_context.existingWidgetInfo.isExist) //update
+ {
+ WidgetDAO dao(m_context.locations->getPkgname());
+ WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations();
+ LogDebug("Removing external files:");
+ FOREACH(file, externalLocationsDB)
+ {
+ if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end())
+ {
+ if(WrtUtilFileExists(*file))
+ {
+ LogDebug(" -> " << *file);
+ remove(file->c_str());
+ }
+ else if(WrtUtilDirExists(*file))
+ {
+ LogDebug(" -> " << *file);
+ if(!WrtUtilRemove(*file)){
+ ThrowMsg(Exceptions::RemovingFolderFailure,
+ "Failed to remove external directory");
+ }
+ }
+ else
+ {
+ LogWarning(" -> " << *file << "(no such a path)");
+ }
+ }
+ }
+ }
+ LogDebug("Registering external files:");
+ FOREACH(file, externalLocationsUpdate)
+ {
+ LogDebug(" -> " << *file);
+ }
+
+ //set external lcoations to be registered
+ m_context.widgetConfig.externalLocations = externalLocationsUpdate;
+}
+
void TaskDatabase::StepAbortDBInsert()
{
LogWarning("[DB Update Task] Aborting... (DB Clean)");
- Assert(!!m_context.widgetHandle);
Try
{
- WidgetDAO::unregisterWidget(*m_context.widgetHandle); //TODO: unregister by pkgname (ace_widget_handle_t not int needed)
+ WidgetDAO::unregisterWidget(m_context.locations->getPkgname());
LogDebug("Cleaning DB successful!");
}
InstallerContext& m_context;
void StepDBInsert();
+ void StepRegisterExternalFiles();
void StepAbortDBInsert();
{
AddStep(&TaskFileManipulation::StepCreateDirs);
AddStep(&TaskFileManipulation::StepRenamePath);
- AddStep(&TaskFileManipulation::StepRegisterExternalFiles);
AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
}
"Widget Rename path Finished");
}
-void TaskFileManipulation::StepRegisterExternalFiles()
-{
- LogDebug("Registering external files:");
- WrtDB::ExternalLocationList externalPaths = m_context.locations->listExternalLocations();
- FOREACH(path, externalPaths)
- {
- LogDebug(" -> " << *path);
- }
- WidgetDAO dao(m_context.locations->getPkgname());
- dao.registerExternalLocations(externalPaths);
-}
-
void TaskFileManipulation::StepAbortRenamePath()
{
LogDebug("[Rename Widget Path] Aborting.... (Rename path)");
void StepCreateDirs();
void StepRenamePath();
- void StepRegisterExternalFiles();
void StepAbortRenamePath();
WrtUtilMakeDir(destination);
LogDebug("Registering widget's livebox directory under /opt/live/");
- WrtDB::ExternalLocationList list;
- list.push_back(liveboxDir);
- WrtDB::WidgetDAO dao(m_context.locations->getPkgname());
- dao.registerExternalLocations(list);
+ m_context.locations->registerExternalLocation(liveboxDir);
LogInfo("Coping livebox configuration file: " << confFile << " -> " << targetFile);
DPL::FileInput input(confFile);
#include <sys/stat.h>
#include <string>
#include <sstream>
-#include <dpl/wrt-dao-rw/widget_dao.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <dpl/foreach.h>
#include <dpl/log/log.h>
DPL::TaskDecl<TaskRemoveBackupFiles>(this),
m_context(context)
{
- AddStep(&TaskRemoveBackupFiles::StepDeleteDB);
AddStep(&TaskRemoveBackupFiles::StepRemoveBackupFiles);
}
-void TaskRemoveBackupFiles::StepDeleteDB()
-{
- LogInfo("Delete old widget DB");
- Try
- {
- // If there is existing model, remove its database data
- if (true == m_context.existingWidgetInfo.isExist) {
- WidgetHandle old = m_context.existingWidgetInfo.existingHandle;
- LogInfo("Unregistering widget...: " << old);
- WidgetDAO::unregisterWidget(old);
- LogInfo("Widget unregistered");
- }
- }
- Catch(DPL::DB::SqlConnection::Exception::Base)
- {
- LogError("Failed to clean up old widget DB!");
- ReThrowMsg(Exceptions::RemoveBackupFailed, "Database failure!");
- }
-
- m_context.job->UpdateProgress(
- InstallerContext::INSTALL_DELETE_OLD_DB,
- "Backup widget db delete Finished");
-}
-
void TaskRemoveBackupFiles::StepRemoveBackupFiles()
{
std::ostringstream backupDir;
private:
InstallerContext& m_context;
- void StepDeleteDB();
void StepRemoveBackupFiles();
public:
#include <widget_install/widget_install_errors.h>
#include <widget_install/job_widget_install.h>
-#include <dpl/wrt-dao-rw/widget_dao.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <dpl/exception.h>
#include <dpl/errno_string.h>
AddStep(&TaskUpdateFiles::StepCreateBackupFolder);
AddStep(&TaskUpdateFiles::StepResourceFilesBackup);
AddStep(&TaskUpdateFiles::StepExecFileBackup);
- AddStep(&TaskUpdateFiles::StepUpdateExternalFiles);
AddAbortStep(&TaskUpdateFiles::StepAbortCreateBackupFolder);
AddAbortStep(&TaskUpdateFiles::StepAbortExecFileBackup);
}
}
-void TaskUpdateFiles::StepUpdateExternalFiles()
-{
- WidgetDAO dao(m_context.locations->getPkgname());
- WrtDB::ExternalLocationList externalLocationsUpdate = m_context.locations->listExternalLocations();
- WrtDB::ExternalLocationList externalLocationsDB = dao.getWidgetExternalLocations();
- LogDebug("Removing external files:");
- FOREACH(file, externalLocationsDB)
- {
- if(std::find(externalLocationsUpdate.begin(), externalLocationsUpdate.end(), *file) == externalLocationsUpdate.end())
- {
- if(WrtUtilFileExists(*file))
- {
- LogDebug(" -> " << *file);
- remove(file->c_str());
- }
- else if(WrtUtilDirExists(*file))
- {
- LogDebug(" -> " << *file);
- if(!WrtUtilRemove(*file)){
- ThrowMsg(Exceptions::RemovingFolderFailure,
- "Failed to remove external directory");
- }
- }
- else
- {
- LogWarning(" -> " << *file << "(no such a path)");
- }
- }
- }
- dao.unregisterAllExternalLocations();
- LogDebug("Registering(update) external files:");
- FOREACH(file, externalLocationsUpdate)
- {
- LogDebug(" -> " << *file);
- }
- dao.registerExternalLocations(externalLocationsUpdate);
-}
-
} //namespace WidgetInstall
} //namespace Jobs
void StepCreateBackupFolder();
void StepResourceFilesBackup();
void StepExecFileBackup();
- void StepUpdateExternalFiles();
void ReadDirList(std::string dirPath, ExistFileList &list, size_t subLen);
// Installation state variables
WrtDB::WidgetRegisterInfo widgetConfig; ///< WidgetConfigInfo
- DPL::Optional<WrtDB::DbWidgetHandle> widgetHandle;
DPL::Optional<WidgetLocation> locations;
Jobs::WidgetInstall::WacSecurity wacSecurity;///< Widget Domain information.
InstallStep installStep; ///< current step of installation
#include "widget_update_info.h"
WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo() :
- isExist(false),
- existingHandle(0)
+ isExist(false)
{
}
WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo(
- const WidgetHandle handle,
+ const WrtDB::WidgetPkgName & name,
const DPL::Optional<WidgetVersion> &version) :
+ pkgname(name),
isExist(true),
- existingHandle(handle),
existingVersion(version)
{
}
WidgetUpdateInfo::ExistingWidgetInfo::ExistingWidgetInfo(
- const WidgetHandle handle,
+ const WrtDB::WidgetPkgName & name,
const DPL::Optional<DPL::String> &version) :
- isExist(true),
- existingHandle(handle)
+ pkgname(name),
+ isExist(true)
{
if (!!version) {
existingVersion = WidgetVersion(*version);
{
struct ExistingWidgetInfo
{
+ WrtDB::WidgetPkgName pkgname;
bool isExist;
- WidgetHandle existingHandle;
DPL::Optional<WidgetVersion> existingVersion;
ExistingWidgetInfo();
- ExistingWidgetInfo(const WidgetHandle handle,
+ ExistingWidgetInfo(const WrtDB::WidgetPkgName & name,
const DPL::Optional<WidgetVersion> &version);
- ExistingWidgetInfo(const WidgetHandle handle,
+ ExistingWidgetInfo(const WrtDB::WidgetPkgName & name,
const DPL::Optional<DPL::String> &version);
};
namespace Jobs {
namespace WidgetUninstall {
-JobWidgetUninstall::JobWidgetUninstall(WidgetHandle widgetHandle,
+JobWidgetUninstall::JobWidgetUninstall(const std::string & widgetPkgName,
const WidgetUninstallationStruct &uninstallerStruct) :
Job(Uninstallation),
JobContextBase<WidgetUninstallationStruct>(uninstallerStruct)
{
using namespace PackageManager;
- m_context.widgetHandle = widgetHandle;
m_context.removeStarted = false;
m_context.removeFinished = false;
m_context.uninstallStep = UninstallerContext::UNINSTALL_START;
m_context.job = this;
+ m_context.pkgname = widgetPkgName;
Try
{
- WrtDB::WidgetDAOReadOnly dao(widgetHandle);
- m_context.pkgname = DPL::ToUTF8String(*dao.getPkgname());
+ WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(widgetPkgName));
m_context.locations = WidgetLocation(m_context.pkgname);
LogInfo("Widget model exists. Pkg name: " << m_context.pkgname);
}
}
-WidgetHandle JobWidgetUninstall::getRemovedWidgetHandle() const
-{
- return m_context.widgetHandle;
-}
-
std::string JobWidgetUninstall::getRemovedTizenId() const
{
return m_context.pkgname;
/**
* @brief Uninstaller must to know which widget to uninstall.
*
- * @param[in] const int& widget_id - wdget to uninstall
+ * @param[in] WrtDB::WidgetPkgName widgetPkgName - widget to uninstall
*/
- JobWidgetUninstall(WidgetHandle widgetHandle,
+ JobWidgetUninstall(const std::string &widgetPkgName,
const WidgetUninstallationStruct& uninstallerStruct);
- WidgetHandle getRemovedWidgetHandle() const;
std::string getRemovedTizenId() const;
bool getRemoveStartedFlag() const;
bool getRemoveFinishedFlag() const;
void TaskCheck::StepUninstallPreCheck()
{
- LogInfo("Uninstall check for widget Handle: " << m_context.widgetHandle);
+ LogInfo("Uninstall check for pkgname: " << m_context.locations->getPkgname());
//check if deferred
//TODO if widget to be updated, then remove it from Deferred list?
//TODO or defer uninstall?
}
- LogInfo("Widget Can be uninstalled. Handle : " << m_context.widgetHandle);
+ LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.locations->getPkgname());
m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_PRECHECK,
"Uninstall pre-checking Finished");
}
{
Try
{
- WidgetDAO::unregisterWidget(m_context.widgetHandle);
+ WidgetDAO::unregisterWidget(m_context.locations->getPkgname());
LogDebug("Unregistered widget successfully!");
}
void TaskRemoveFiles::StepRemoveExternalLocations()
{
- WidgetDAO dao(m_context.widgetHandle);
+ WidgetDAO dao(m_context.locations->getPkgname());
LogDebug("Removing external locations:");
WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
FOREACH(path, externalPaths)
LogInfo("------------------------> SMACK: Jobs::WidgetUninstall::TaskSmack::Step()");
#ifdef WRT_SMACK_ENABLED
try {
- WrtDB::WidgetDAOReadOnly dao(m_context.widgetHandle);
+ WrtDB::WidgetDAOReadOnly dao(m_context.locations->getPkgname());
DPL::OptionalString pkgName = dao.getPkgname();
Assert(!pkgName.IsNull() && "widget doesn't have a pkg name");
const char *devCap = "";
pclose(fd);
- LogInfo("Widget Can be uninstalled. Handle : " << m_context.widgetHandle);
+ LogInfo("Widget Can be uninstalled. Pkgname : " << m_context.pkgname);
m_context.job->UpdateProgress(UninstallerContext::UNINSTALL_REMOVE_OSPSVC,
"Uninstall OSP service finished");
}
UNINSTALL_END
};
- WidgetHandle widgetHandle;
-
///< flag that indicates whether installer starts
//to remove files.rStruct;
bool removeStarted;
void InstallerController::OnEventReceived(
const InstallerControllerEvents::UninstallWidgetEvent &event)
{
- WidgetHandle widgetHandle = event.GetArg0();
+ std::string widgetPkgName = event.GetArg0();
WidgetUninstallationStruct uninstallerStruct = event.GetArg1();
- m_installerLogic.UninstallWidget(widgetHandle, uninstallerStruct);
+ m_installerLogic.UninstallWidget(widgetPkgName, uninstallerStruct);
}
Eina_Bool InstallerController::AddNextStep(void *data)
* WidgetHandler is used to point witch widget shuld be uninstalled
*/
DECLARE_GENERIC_EVENT_2(UninstallWidgetEvent,
- WidgetHandle,
+ std::string,
WidgetUninstallationStruct)
/**
//InstallWidget, UninstallWidget InstallPlugin method are almost the same
// But each Job has different constructor, so creating new Job is specific
-// i.e. widgetHandle, path etc...
-Jobs::JobHandle InstallerLogic::InstallWidget(std::string const & widgetPath,
+Jobs::JobHandle InstallerLogic::InstallWidget(const std::string & widgetPath,
const WidgetInstallationStruct &installerStruct)
{
LogDebug("New Widget Installation:");
return AddAndStartJob(job);
}
-Jobs::JobHandle InstallerLogic::UninstallWidget(WidgetHandle widgetHandle,
+Jobs::JobHandle InstallerLogic::UninstallWidget(const std::string & widgetPkgName,
const WidgetUninstallationStruct &uninstallerStruct)
{
LogDebug("New Widget Uninstallation");
Jobs::Job *job =
- new Jobs::WidgetUninstall::JobWidgetUninstall(widgetHandle,
+ new Jobs::WidgetUninstall::JobWidgetUninstall(widgetPkgName,
uninstallerStruct);
return AddAndStartJob(job);
void Terminate();
- Jobs::JobHandle InstallWidget(std::string const & widgetPath,
+ Jobs::JobHandle InstallWidget(const std::string & widgetPath,
const WidgetInstallationStruct &installerStruct);
- Jobs::JobHandle UninstallWidget(WidgetHandle widgetHandle,
+ Jobs::JobHandle UninstallWidget(const std::string & widgetPkgName,
const WidgetUninstallationStruct &uninstallerStruct);
Jobs::JobHandle InstallPlugin(std::string const & pluginPath,
m_packagePath = m_argv[2];
m_installPolicy = WRT_WIM_POLICY_FORCE_INSTALL;
AddStep(&WrtInstaller::installStep);
- } else if (arg == "-u" || arg == "--uninstall") {
- if (m_argc != 3) {
- return showHelpAndQuit();
- }
-
- m_handle = atoi(m_argv[2]);
- AddStep(&WrtInstaller::uninstallStep);
} else if (arg == "-un" || arg == "--uninstall-name") {
if (m_argc != 3) {
return showHelpAndQuit();
"install or update widget package for given path\n"
" -if, --install-force "
"install forcibly widget package for given path\n"
- " -u, --uninstall "
- "uninstall widget for given ID\n"
- " -un, --uninstall for given package name "
+ " -un, --uninstall-name "
"uninstall widget for given package name\n"
" -ug, --uninstall-guid "
- "uninstall widget for given package path\n"
- " -up, --uninstall-packagepath "
"uninstall widget for given Global Unique IDentifier\n"
+ " -up, --uninstall-packagepath "
+ "uninstall widget for given package file path\n"
"\n");
Quit();
}
}
-void WrtInstaller::uninstallStep()
+void WrtInstaller::uninstallPkgNameStep()
{
LogDebug("Uninstalling widget ...");
- wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+ LogDebug("Package name : " << m_name);
+ wrt_uninstall_widget(m_name.c_str(), this, &staticWrtStatusCallback,
(!m_quiet || m_installByPkgmgr)
? &staticWrtUninstallProgressCallback : NULL);
}
-void WrtInstaller::uninstallPkgNameStep()
-{
- LogDebug("Uninstalling widget ...");
- WrtErrStatus status = wrt_get_widget_by_pkgname(m_name, &m_handle);
- if (status == WRT_SUCCESS) {
- LogDebug("Get Widget Handle by package name : " << m_handle);
- wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
- (!m_quiet || m_installByPkgmgr)
- ? &staticWrtUninstallProgressCallback : NULL);
- } else {
- printf("failed: can not uninstall widget\n");
- LogError("Fail to uninstalling widget... ");
- m_returnStatus = -1;
- DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
- WRTInstallerNS::QuitEvent());
- }
-}
-
void WrtInstaller::uninstallGuidStep()
{
LogDebug("Uninstalling widget ...");
- WrtErrStatus status = wrt_get_widget_by_guid(m_name, &m_handle);
+ std::string pkgname;
+ WrtErrStatus status = wrt_get_widget_by_guid(pkgname, m_name);
if (status == WRT_SUCCESS) {
- LogDebug("Get Widget Handle by guid : " << m_handle);
- wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+ LogDebug("Guid : " << m_name);
+ wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
!m_quiet ? &staticWrtUninstallProgressCallback : NULL);
} else {
printf("failed: can not uninstall widget\n");
std::string guid = DPL::ToUTF8String(*widgetGUID);
- WrtErrStatus status = wrt_get_widget_by_guid(guid, &m_handle);
+ std::string pkgname;
+ WrtErrStatus status = wrt_get_widget_by_guid(pkgname, guid);
if (status == WRT_SUCCESS) {
- LogDebug("Get Widget Handle by guid : " << m_handle);
- wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+ LogDebug("Pkgname from packagePath : " << pkgname);
+ wrt_uninstall_widget(pkgname.c_str(), this, &staticWrtStatusCallback,
!m_quiet ? &staticWrtUninstallProgressCallback : NULL);
} else {
LogError("Fail to uninstalling widget... ");
{
resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
printMsg = "installed";
- } else if (current == &WrtInstaller::uninstallStep ||
- current == &WrtInstaller::uninstallPkgNameStep ||
+ } else if (current == &WrtInstaller::uninstallPkgNameStep ||
current == &WrtInstaller::uninstallGuidStep ||
current == &WrtInstaller::unistallWgtFileStep)
{
void installStep();
void installNewPlugins();
void installPluginsStep();
- void uninstallStep();
void uninstallPkgNameStep();
void uninstallGuidStep();
void unistallWgtFileStep();
UNHANDLED_EXCEPTION_HANDLER_END
}
- EXPORT_API void wrt_uninstall_widget(int widget_handle,
+ EXPORT_API void wrt_uninstall_widget(const char * const pkg_name,
void* userdata,
WrtInstallerStatusCallback status_cb,
WrtProgressCallback progress_cb)
{
UNHANDLED_EXCEPTION_HANDLER_BEGIN
{
- LogInfo("[WRT-API] UNINSTALL WIDGET: " << widget_handle);
+ std::string widgetPkgName(pkg_name);
+ LogInfo("[WRT-API] UNINSTALL WIDGET: " << widgetPkgName);
// Post uninstallation event
CONTROLLER_POST_EVENT(
Logic::InstallerController,
InstallerControllerEvents::UninstallWidgetEvent(
- widget_handle,
+ widgetPkgName,
WidgetUninstallationStruct(
InstallerCallbacksTranslate::uninstallFinishedCallback,
InstallerCallbacksTranslate::installProgressCallback,
}
}
- EXPORT_API WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
- int *widget_handle)
+ EXPORT_API WrtErrStatus wrt_get_widget_by_guid(std::string & pkgname,
+ const std::string guid)
{
try
{
- LogInfo("[WRT-API] GETTING WIDGET HANDLE BY PKG NAME : "
- << pkgname);
-
- WidgetHandle handle = WidgetDAOReadOnly::getHandle(
- DPL::FromASCIIString(pkgname));
- *widget_handle = static_cast<int>(handle);
- return WRT_SUCCESS;
- }
- catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
- {
- LogError("Error package name is not found");
- return WRT_ERROR_PKGNAME_NOT_FOUND;
- }
- catch (const DPL::Exception& ex)
- {
- LogError("Internal Error during get widget id by package name");
- DPL::Exception::DisplayKnownException(ex);
- return WRT_ERROR_INTERNAL;
- }
- }
-
- EXPORT_API WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
- int *widget_handle)
- {
- try
- {
- LogInfo("[WRT-API] GETTING WIDGET HANDLE BY WidgetID : "
+ LogInfo("[WRT-API] GETTING WIDGET PACKAGE NAME BY WidgetID : "
<< guid);
WidgetGUID widget_guid = DPL::FromUTF8String(guid);
- WidgetHandle handle = WidgetDAOReadOnly::getHandle(widget_guid);
- *widget_handle = static_cast<int>(handle);
+ WrtDB::WidgetDAOReadOnly dao(widget_guid);
+ pkgname = DPL::ToUTF8String(*dao.getPkgname());
return WRT_SUCCESS;
}
catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
bool quiet);
/**
- * @fn void wrt_installer_uninstall_widget (int widget_handle,
+ * @fn void wrt_installer_uninstall_widget (const char * const pkg_name,
* void* userdata,
* WrtInstallerStatusCallback cb)
- * @brief Uninstalls widget using its id
+ * @brief Uninstalls widget using its name
*
- * This method is used to uninstall the widget specified by its handle.
+ * This method is used to uninstall the widget specified by its pkgname.
* The callback function is called when the uninstall operation is done.
*
- * @param [in] widget_handle - widget id
+ * @param [in] pkg_name - package name
* @param [in] userdata - user parameters to be passed to the callback
* @param [in] status_cb - Call to this one will be done at the end of
* operation
*
* @see wrt_installer_install_widget
*/
-void wrt_uninstall_widget (int widget_handle,
+void wrt_uninstall_widget (const char * const pkg_name,
void* userdata,
WrtInstallerStatusCallback status_cb,
WrtProgressCallback progress_cb);
*/
void wrt_installer_shutdown_for_tests();
-WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
- int *widget_handle);
-
-WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
- int *widget_handle);
+/**
+ * @brief wrt_get_widget_by_guid Returns pkgname by pkg guid (widgetId)
+ * @param pkgname pkgname argument ot be set
+ * @param guid guid that we look for
+ * @return error code
+ */
+WrtErrStatus wrt_get_widget_by_guid(std::string &pkgname, const std::string guid);
#ifdef __cplusplus
}
#endif