#include <installer_controller.h>
#include <dpl/string.h>
#include <dpl/foreach.h>
-//#include <plugin_logic.h>
#include <dpl/wrt-dao-rw/feature_dao.h>
#include <dpl/wrt-dao-rw/plugin_dao.h>
-#include <dpl/wrt-dao-ro/global_config.h>
#include <widget_install/job_widget_install.h>
#include <widget_uninstall/job_widget_uninstall.h>
#include <plugin_install/job_plugin_install.h>
using namespace WrtDB;
+namespace Logic {
InstallerLogic::InstallerLogic() :
m_NextHandle(0)
-{
-}
+{}
InstallerLogic::~InstallerLogic()
{
//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,
- const WidgetInstallationStruct &installerStruct)
+Jobs::JobHandle InstallerLogic::InstallWidget(
+ const std::string & widgetPath,
+ const WidgetInstallationStruct &
+ installerStruct)
{
LogDebug("New Widget Installation:");
return AddAndStartJob(job);
}
-Jobs::JobHandle InstallerLogic::UninstallWidget(WidgetHandle widgetHandle,
- const WidgetUninstallationStruct &uninstallerStruct)
+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);
}
-Jobs::JobHandle InstallerLogic::InstallPlugin(std::string const & pluginPath,
- const PluginInstallerStruct &installerStruct)
+Jobs::JobHandle InstallerLogic::InstallPlugin(
+ std::string const & pluginPath,
+ const PluginInstallerStruct &
+ installerStruct)
{
LogDebug("New Plugin Installation");
Jobs::Job *job =
new Jobs::PluginInstall::JobPluginInstall(pluginPath, installerStruct);
-
+ // before start install plugin, reset plugin data which is stopped
+ // during installing. (PluginDAO::INSTALLATION_IN_PROGRESS)
+ ResetProgressPlugins();
return AddAndStartJob(job);
}
Try {
bool stepSucceded = job->NextStep();
- if (stepSucceded) {
- job->SendProgress();
+ job->SendProgress();
+ if (stepSucceded) {
return !job->IsPaused();
}
delete job;
return false;
- }
- catch (Jobs::JobExceptionBase &exc) {
+ } catch (Jobs::JobExceptionBase &exc) {
//start revert job
LogInfo("Exception occured: " << exc.getParam() <<
". Reverting job...");
LogWarning("Not implemented");
// LogInfo("Installing deferred widget packages...");
//
- // WidgetPackageList packages = GlobalDAO::GetDefferedWidgetPackageInstallationList();
+ // WidgetPackageList packages =
+ // GlobalDAO::GetDefferedWidgetPackageInstallationList();
//
// LogInfo(packages.size() << " widget package(s) to install");
//
void InstallerLogic::InstallSingleDeferredPackage()
{
LogWarning("Not implemented");
- // if (m_packagesToInstall.empty())
- // return;
- //
- // // Take single package
- // DPL::String widgetPackage = m_packagesToInstall.front();
- // m_packagesToInstall.pop_front();
- //
- // // Remove it from DB
- // GlobalDAO::RemoveDefferedWidgetPackageInstallation(widgetPackage);
- //
- // // Begin installation
- // LogInfo("Installing deferred widget package: " << widgetPackage);
- //
- // // Post installation
- // CONTROLLER_POST_EVENT(
- // InstallerController, InstallerControllerEvents::InstallWidgetEvent(
- // DPL::ToUTF8String(widgetPackage).c_str(), WidgetInstallationStruct(
- // &DummyInstallCallback, &DummyProgressCallback, NULL,
- // WidgetUpdateMode::PolicyWac)));
-}
-
-void InstallerLogic::InstallPluginGeolocation(
- const PluginInstallerStruct &installerStruct)
-{
- FeatureDAO::RegisterStrangeFeature(
- std::string(GlobalConfig::GetW3CGeolocationFeatureName()));
-
- LogDebug("Call plugins installer FinishedCallback");
- installerStruct.finishedCallback(installerStruct.userParam,
- Jobs::PluginInstall::Exceptions::Success);
}
void InstallerLogic::InstallWaitingPlugins()
}
}
+void InstallerLogic::ResetProgressPlugins()
+{
+ PluginHandleSetPtr progressPlugins;
+
+ progressPlugins =
+ PluginDAO::getPluginHandleByStatus(PluginDAO::INSTALLATION_IN_PROGRESS);
+
+ FOREACH(it, *progressPlugins) {
+ FeatureHandleListPtr featureListPtr =
+ FeatureDAOReadOnly::GetFeatureHandleListForPlugin(*it);
+ FOREACH(ItFeature, *featureListPtr) {
+ FeatureDAO::UnregisterFeature(*ItFeature);
+ }
+ PluginDAO::unregisterPlugin(*it);
+ }
+}
+
bool InstallerLogic::resolvePluginDependencies(PluginHandle handle)
{
PluginHandleSetPtr dependencies(new PluginHandleSet);
PluginDAO::getPluginHandleForImplementedObject(*requiredObject);
if (depHandle ==
- Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE) {
+ Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE)
+ {
LogError("Library implementing: " <<
*requiredObject << " NOT FOUND");
return true;
}
+}