Change account icon path from resource directory to shared directory
authorsung-su.kim <sung-su.kim@samsung.com>
Thu, 10 Oct 2013 07:36:02 +0000 (16:36 +0900)
committerSoo-Hyun Choi <sh9.choi@samsung.com>
Thu, 10 Oct 2013 22:33:39 +0000 (07:33 +0900)
[Issue#]   N_SE-54764
[Problem]  "Account" application cannot show icon.
[Cause]    SMACK access is denied when "Account" application process touch
           account icon which is in other application resource directory.
[Solution] Copy account icon to application shared directory.
             - Resource directory : [package]/res/wgt/
             - Shared directory : [package]/shared/res/
           Shared directory is assigned "*" label.
           Changed account icon path in manifest file.

Change-Id: I08f0dfbc42b3754780996d80a9bed8980743dc6c

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 b53fcd6..47898ff 100755 (executable)
@@ -116,13 +116,14 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) :
         AddStep(&TaskManifestFile::stepBackupIconFiles);
         AddStep(&TaskManifestFile::stepCopyIconFiles);
         AddStep(&TaskManifestFile::stepCopyLiveboxFiles);
+        AddStep(&TaskManifestFile::stepCopyAccountIconFiles);
         AddStep(&TaskManifestFile::stepCreateExecFile);
         AddStep(&TaskManifestFile::stepGenerateManifest);
-
         AddAbortStep(&TaskManifestFile::stepAbortIconFiles);
     } else {
         AddStep(&TaskManifestFile::stepCopyIconFiles);
         AddStep(&TaskManifestFile::stepCopyLiveboxFiles);
+        AddStep(&TaskManifestFile::stepCopyAccountIconFiles);
         AddStep(&TaskManifestFile::stepCreateExecFile);
         AddStep(&TaskManifestFile::stepGenerateManifest);
     }
@@ -331,7 +332,7 @@ void TaskManifestFile::stepCopyLiveboxFiles()
             targetFile << (**boxIt).m_liveboxId << ".";
             targetFile << DPL::ToUTF8String((*sizeIt).m_size) << "." << DEFAULT_PREVIEW_NAME;
 
-            copyDynamicBoxFile(sourceFile.str(), targetFile.str());
+            copyFile(sourceFile.str(), targetFile.str());
 
             // clear stream objects
             sourceFile.str("");
@@ -347,7 +348,7 @@ void TaskManifestFile::stepCopyLiveboxFiles()
         targetFile << m_context.locations->getSharedDataDir() << "/";
         targetFile << (**boxIt).m_liveboxId << "." << DEFAULT_ICON_NAME;
 
-        copyDynamicBoxFile(sourceFile.str(), targetFile.str());
+        copyFile(sourceFile.str(), targetFile.str());
 
         // clear stream objects
         sourceFile.str("");
@@ -358,8 +359,30 @@ void TaskManifestFile::stepCopyLiveboxFiles()
         "Livebox files copy Finished");
 }
 
-void TaskManifestFile::copyDynamicBoxFile(const std::string& sourceFile,
-                                          const std::string& targetFile)
+void TaskManifestFile::stepCopyAccountIconFiles()
+{
+    _D("Copy Account icon files");
+    WrtDB::ConfigParserData::AccountProvider account =
+        m_context.widgetConfig.configInfo.accountProvider;
+
+    if (account.m_iconSet.empty()) {
+        _D("Widget doesn't contain Account");
+        return;
+    }
+
+    FOREACH(it, account.m_iconSet) {
+        std::string sourceFile = m_context.locations->getSourceDir() +
+                                 '/' +
+                                 DPL::ToUTF8String(it->second);
+        std::string targetFile = m_context.locations->getSharedResourceDir() +
+                                 '/' +
+                                 DPL::ToUTF8String(it->second);
+        copyFile(sourceFile, targetFile);
+    }
+}
+
+void TaskManifestFile::copyFile(const std::string& sourceFile,
+                                const std::string& targetFile)
 {
     Try
     {
@@ -369,8 +392,8 @@ void TaskManifestFile::copyDynamicBoxFile(const std::string& sourceFile,
     }
     Catch(DPL::Exception)
     {
-        _E("Copying Dynamic Box File Failed. %s to %s", sourceFile.c_str(), targetFile.c_str());
-        ReThrowMsg(Exceptions::DynamicBoxFailed, "Dynamic Box File Copy Failed.");
+        _E("Failed to file copy. %s to %s", sourceFile.c_str(), targetFile.c_str());
+        ReThrowMsg(Exceptions::CopyIconFailed, "Error during file copy.");
     }
 }
 
@@ -1224,8 +1247,8 @@ void TaskManifestFile::setAccount(Manifest& manifest)
         }
 
         // account manifest requires absolute path for icon
-        // /opt/apps/[package]/res/wgt/[icon_path]
-        icon.second = DPL::FromUTF8String(m_context.locations->getSourceDir()) +
+        // /opt/apps/[package]/shared/res/[icon_path]
+        icon.second = DPL::FromUTF8String(m_context.locations->getSharedResourceDir()) +
                       DPL::String(L"/") +
                       it->second;
         provider.icon.push_back(icon);
index dee925d..20c65ab 100644 (file)
@@ -63,6 +63,7 @@ class TaskManifestFile :
     void stepCreateExecFile();
     void stepCopyIconFiles();
     void stepCopyLiveboxFiles();
+    void stepCopyAccountIconFiles();
     void stepGenerateManifest();
 
     void stepAbortParseManifest();
@@ -120,8 +121,8 @@ class TaskManifestFile :
                             const DPL::OptionalString& tag,
                             const DPL::String& language, const std::string &extension,
                             bool & defaultIconSaved);
-    void copyDynamicBoxFile(const std::string& sourceFile,
-                            const std::string& targetFile);
+    void copyFile(const std::string& sourceFile,
+                  const std::string& targetFile);
     bool addBoxUiApplication(Manifest& manifest);
 
     //for widget update
index 3fb3dfc..473d9cb 100644 (file)
@@ -76,7 +76,6 @@ 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)