[Release] wrt-installer_0.1.114
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_prepare_files.cpp
index 50c1a58..8a43fa6 100644 (file)
 
 namespace Jobs {
 namespace WidgetInstall {
-
 TaskPrepareFiles::TaskPrepareFiles(InstallerContext &installerContext) :
     DPL::TaskDecl<TaskPrepareFiles>(this),
     m_installerContext(installerContext)
 {
-    // Install steps
-    AddStep(&TaskPrepareFiles::StepCreateTempPath);
+    AddStep(&TaskPrepareFiles::StartStep);
     AddStep(&TaskPrepareFiles::StepCopyFiles);
-
-    AddAbortStep(&TaskPrepareFiles::StepAbort);
-}
-
-void TaskPrepareFiles::StepCreateTempPath()
-{
-    /*
-     * Config.xml and all icons will be copied to another location so the path
-     * has to be updated.
-     */
-    m_installerContext.tempWidgetPath = createTempPath();
+    AddStep(&TaskPrepareFiles::EndStep);
 }
 
 void TaskPrepareFiles::CopyFile(const std::string& source)
 {
-    if(source.empty()) {
+    if (source.empty()) {
         LogWarning("No source file specified");
         return;
     }
 
     std::string filename = source;
-    size_t last = source.find_last_of( "\\/" );
-    if(last != std::string::npos) {
-        filename = source.substr( last+1 );
+    size_t last = source.find_last_of("\\/");
+    if (last != std::string::npos) {
+        filename = source.substr(last + 1);
     }
-    std::string target = m_installerContext.tempWidgetPath + '/' + filename;
+    std::string target =
+        m_installerContext.locations->getTemporaryPackageDir() + '/' +
+        filename;
     LogDebug("source " << source);
     LogDebug("target " << target);
 
@@ -100,25 +90,35 @@ void TaskPrepareFiles::CopyFile(const std::string& source)
 
 void TaskPrepareFiles::StepCopyFiles()
 {
-    CopyFile(m_installerContext.widgetSource);
+    CopyFile(m_installerContext.locations->getWidgetSource());
 
-    size_t last = m_installerContext.widgetSource.find_last_of("\\/");
+    size_t last = m_installerContext.locations->getWidgetSource().find_last_of(
+            "\\/");
     std::string sourceDir = "";
     if (last != std::string::npos) {
-        sourceDir = m_installerContext.widgetSource.substr(0,last+1);
+        sourceDir = m_installerContext.locations->getWidgetSource().substr(
+                0,
+                last
+                + 1);
     }
 
+    LogDebug("Icons copy...");
     FOREACH(it, m_installerContext.widgetConfig.configInfo.iconsList) {
         std::ostringstream os;
+        LogDebug("Coping: " << sourceDir << DPL::ToUTF8String(it->src));
         os << sourceDir << DPL::ToUTF8String(it->src);
         CopyFile(os.str());
     }
 }
 
-void TaskPrepareFiles::StepAbort()
+void TaskPrepareFiles::StartStep()
 {
-    removeTemporaryDir(m_installerContext.tempWidgetPath);
+    LogDebug("--------- <TaskPrepareFiles> : START ----------");
 }
 
+void TaskPrepareFiles::EndStep()
+{
+    LogDebug("--------- <TaskPrepareFiles> : END ----------");
+}
 } // namespace WidgetInstall
 } // namespace Jobs