namespace Logic {
InstallerLogic::InstallerLogic() :
- m_NextHandle(0)
+ m_NextHandle(0),m_job(0)
{}
InstallerLogic::~InstallerLogic()
{
- Assert(m_jobs.empty() && "There are still running jobs");
+ Assert(!m_job && "There are still running job");
//FIXME what should be done here?
}
void InstallerLogic::Terminate()
{
//TODO how to delete, if it is still running, paused and so on
- FOREACH(it, m_jobs)
- {
- it->second->SetPaused(true); //FIXME this is not enough!
- }
+ if(m_job)
+ m_job->SetPaused(true);
LogDebug("Done");
}
-Jobs::JobHandle InstallerLogic::AddAndStartJob(Jobs::Job *job)
+Jobs::JobHandle InstallerLogic::AddAndStartJob()
{
Jobs::JobHandle handle = GetNewJobHandle();
- job->SetJobHandle(handle);
-
- m_jobs.insert(std::make_pair(handle, job));
-
+ m_job->SetJobHandle(handle);
//Start job
CONTROLLER_POST_EVENT(InstallerController,
- InstallerControllerEvents::NextStepEvent(job));
+ InstallerControllerEvents::NextStepEvent(m_job));
return handle;
}
const WidgetInstallationStruct &
installerStruct)
{
+ if(m_job)
+ {
+ LogError("Job is in progress. It is impossible to add new job");
+ return -1;
+ }
+
LogDebug("New Widget Installation:");
- Jobs::Job *job =
+ m_job =
new Jobs::WidgetInstall::JobWidgetInstall(widgetPath, installerStruct);
- return AddAndStartJob(job);
+
+ return AddAndStartJob();
}
Jobs::JobHandle InstallerLogic::UninstallWidget(
const
WidgetUninstallationStruct &uninstallerStruct)
{
+ if(m_job)
+ {
+ LogError("Job is in progress. It is impossible to add new job");
+ return -1;
+ }
+
LogDebug("New Widget Uninstallation");
- Jobs::Job *job =
+ m_job =
new Jobs::WidgetUninstall::JobWidgetUninstall(widgetPkgName,
uninstallerStruct);
- return AddAndStartJob(job);
+ return AddAndStartJob();
}
Jobs::JobHandle InstallerLogic::InstallPlugin(
const PluginInstallerStruct &
installerStruct)
{
+ if(m_job)
+ {
+ LogError("Job is in progress. It is impossible to add new job");
+ return -1;
+ }
+
LogDebug("New Plugin Installation");
- Jobs::Job *job =
+ m_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);
+
+ return AddAndStartJob();
}
#define TRANSLATE_JOB_EXCEPTION() \
}
//clean job
- m_jobs.erase(job->GetJobHandle());
delete job;
+ m_job=0;
return false;
} catch (Jobs::JobExceptionBase &exc) {
job->SendFinishedFailure();
//clean job
- m_jobs.erase(job->GetJobHandle());
delete job;
+ m_job=0;
}
return hasAbortSteps;
}