Add send signal if there is not enough memory during web app installation
[framework/web/wrt-installer.git] / src / logic / installer_logic.cpp
index a7927ce..df67764 100644 (file)
 #include <plugin_install/job_plugin_install.h>
 #include <job_exception_base.h>
 #include <plugin_install/plugin_objects.h>
+#include <installer_log.h>
 
 using namespace WrtDB;
 
 namespace Logic {
 InstallerLogic::InstallerLogic() :
-    m_NextHandle(0),m_job(0)
+    m_job(0),
+    m_NextHandle(0)
 {}
 
 InstallerLogic::~InstallerLogic()
@@ -40,7 +42,7 @@ InstallerLogic::~InstallerLogic()
 
 void InstallerLogic::Initialize()
 {
-    LogDebug("Done");
+    _D("Done");
 }
 
 void InstallerLogic::Terminate()
@@ -49,7 +51,7 @@ void InstallerLogic::Terminate()
     if(m_job)
         m_job->SetPaused(true);
 
-    LogDebug("Done");
+    _D("Done");
 }
 
 Jobs::JobHandle InstallerLogic::AddAndStartJob()
@@ -67,20 +69,19 @@ Jobs::JobHandle InstallerLogic::AddAndStartJob()
 // But each Job has different constructor, so creating new Job is specific
 Jobs::JobHandle InstallerLogic::InstallWidget(
     const std::string & widgetPath,
-    const WidgetInstallationStruct &
+    const std::string & pkgId,
+    const Jobs::WidgetInstall::WidgetInstallationStruct &
     installerStruct)
 {
     if(m_job)
     {
-        LogError("Job is in progress. It is impossible to add new job");
+        _E("Job is in progress. It is impossible to add new job");
         return -1;
     }
 
-    LogDebug("New Widget Installation:");
-
-    m_job =
-        new Jobs::WidgetInstall::JobWidgetInstall(widgetPath, installerStruct);
+    _D("New Widget Installation:");
 
+    m_job = new Jobs::WidgetInstall::JobWidgetInstall(widgetPath, pkgId, installerStruct);
 
     return AddAndStartJob();
 }
@@ -92,11 +93,11 @@ Jobs::JobHandle InstallerLogic::UninstallWidget(
 {
     if(m_job)
     {
-        LogError("Job is in progress. It is impossible to add new job");
+        _E("Job is in progress. It is impossible to add new job");
         return -1;
     }
 
-    LogDebug("New Widget Uninstallation");
+    _D("New Widget Uninstallation");
 
     m_job  =
         new Jobs::WidgetUninstall::JobWidgetUninstall(widgetPkgName,
@@ -112,11 +113,11 @@ Jobs::JobHandle InstallerLogic::InstallPlugin(
 {
     if(m_job)
     {
-        LogError("Job is in progress. It is impossible to add new job");
+        _E("Job is in progress. It is impossible to add new job");
         return -1;
     }
 
-    LogDebug("New Plugin Installation");
+    _D("New Plugin Installation");
 
     // TODO Conversion to PluginPath is temporary
     m_job =
@@ -145,7 +146,7 @@ bool InstallerLogic::NextStep(Jobs::Job *job)
             return !job->IsPaused();
         }
 
-        if (!job->GetUndoType()) {
+        if (!job->GetAbortStarted()) {
             //job successfully finished
 
             //send finished callback
@@ -153,7 +154,6 @@ bool InstallerLogic::NextStep(Jobs::Job *job)
 
             switch (job->GetInstallationType()) {
             case Jobs::PluginInstallation:
-                //todo move it somewhere
                 InstallWaitingPlugins();
                 break;
             default: //because of warning
@@ -171,10 +171,9 @@ bool InstallerLogic::NextStep(Jobs::Job *job)
         return false;
     } catch (Jobs::JobExceptionBase &exc) {
         //start revert job
-        LogDebug("Exception occured: " << exc.getParam() <<
-                ". Reverting job...");
+        _D("Exception occured: %d. Reverting job...", exc.getParam());
         bool hasAbortSteps = job->Abort();
-        job->SetUndoType(true);
+        job->SetAbortStarted(true);
         job->SaveExceptionData(exc);
 
         if (!hasAbortSteps) {
@@ -237,8 +236,7 @@ bool InstallerLogic::resolvePluginDependencies(PluginHandle handle)
         if (depHandle ==
             Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE)
         {
-            LogError("Library implementing: " <<
-                     *requiredObject << " NOT FOUND");
+            _E("Library implementing: %s NOT FOUND", (*requiredObject).c_str());
 
             //PluginDAO::SetPluginInstallationStatus(INSTALLATION_WAITING);
             return false;