Add dynamic box icon src exception handle
authorsung-su.kim <sung-su.kim@samsung.com>
Thu, 4 Jul 2013 09:21:47 +0000 (18:21 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Thu, 11 Jul 2013 11:29:45 +0000 (11:29 +0000)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] Add dynamic box icon src exception handle
[SCMRequest] N/A

Change-Id: Ia134292d7303049b4991c09d87feec8a9bab9232

src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_manifest_file.h
src/jobs/widget_install/widget_install_errors.h

index 99b34a1..ff3e8ac 100755 (executable)
@@ -54,6 +54,7 @@
 #include <dpl/localization/LanguageTagsProvider.h>
 
 #define DEFAULT_ICON_NAME   "icon.png"
+#define DEFAULT_PREVIEW_NAME   "preview.png"
 
 using namespace WrtDB;
 
@@ -323,16 +324,13 @@ void TaskManifestFile::stepCopyLiveboxFiles()
             if (preview.empty()) {
                 continue;
             }
-            // copy preview image to shared directory
             sourceFile << m_context.locations->getSourceDir() << "/";
             sourceFile << preview;
             targetFile << m_context.locations->getSharedDataDir() << "/";
             targetFile << (**boxIt).m_liveboxId << ".";
-            targetFile << DPL::ToUTF8String((*sizeIt).m_size) << ".preview.png";
+            targetFile << DPL::ToUTF8String((*sizeIt).m_size) << "." << DEFAULT_PREVIEW_NAME;
 
-            DPL::FileInput input(sourceFile.str());
-            DPL::FileOutput output(targetFile.str());
-            DPL::Copy(&input, &output);
+            DynamicBoxFileCopy(sourceFile.str(), targetFile.str(), preview);
 
             // clear stream objects
             sourceFile.str("");
@@ -343,26 +341,39 @@ void TaskManifestFile::stepCopyLiveboxFiles()
         if (icon.empty()) {
             continue;
         }
-        // copy icon to shared directory
         sourceFile << m_context.locations->getSourceDir() << "/";
         sourceFile << icon;
         targetFile << m_context.locations->getSharedDataDir() << "/";
-        targetFile << (**boxIt).m_liveboxId << ".icon.png";
+        targetFile << (**boxIt).m_liveboxId << "." << DEFAULT_ICON_NAME;
 
-        DPL::FileInput input(sourceFile.str());
-        DPL::FileOutput output(targetFile.str());
-        DPL::Copy(&input, &output);
+        DynamicBoxFileCopy(sourceFile.str(), targetFile.str(), icon);
 
         // clear stream objects
         sourceFile.str("");
         targetFile.str("");
     }
-
     m_context.job->UpdateProgress(
         InstallerContext::INSTALL_COPY_LIVEBOX_FILES,
         "Livebox files copy Finished");
 }
 
+void TaskManifestFile::DynamicBoxFileCopy(const std::string& sourceFile,
+                                          const std::string& targetFile)
+{
+    Try
+    {
+        DPL::FileInput input(sourceFile);
+        DPL::FileOutput output(targetFile);
+        DPL::Copy(&input, &output);
+    }
+    Catch(DPL::Exception)
+    {
+        LogError("Copying Dynamic Box File Failed. " << sourceFile
+                                                     << " to " << targetFile);
+        ReThrowMsg(Exceptions::DynamicBoxFailed, "Dynamic Box File Copy Failed.");
+    }
+}
+
 void TaskManifestFile::stepBackupIconFiles()
 {
     LogDebug("Backup Icon Files");
index efb1881..4bcc3b3 100644 (file)
@@ -120,6 +120,8 @@ class TaskManifestFile :
                             const DPL::OptionalString& tag,
                             const DPL::String& language,
                             bool & defaultIconSaved);
+    void DynamicBoxFileCopy(const std::string& sourceFile,
+                            const std::string& targetFile);
 
     //for widget update
     void backupIconFiles();
index 89be530..3ef2a79 100644 (file)
@@ -75,6 +75,7 @@ DECLARE_JOB_EXCEPTION(Base, RemovingFolderFailure, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, RemovingFileFailure, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, CreateVconfFailure, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorFatalError)
+DECLARE_JOB_EXCEPTION(Base, DynamicBoxFailed, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, FileOperationFailed, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, InstallToExternalFailed, ErrorFatalError)
 DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorFatalError)