Add removable propery for CSC
authorDuyoung Jang <duyoung.jang@samsung.com>
Thu, 23 May 2013 08:03:12 +0000 (17:03 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Fri, 24 May 2013 00:52:25 +0000 (09:52 +0900)
Change-Id: Iec559778803f5cb1ea178584a3d5fe2c577ddb3c
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
inc/InstallerDefs.h
src/Context/InstallationContext.cpp
src/Manager/ConfigurationManager.cpp
src/Manager/ConfigurationManager.h
src/Manager/InstallerManager.cpp
src/Manager/SmackManager.cpp

index 82c9a0f..cc25585 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130523.2]"
+#define OSP_INSTALLER_VERSION "version=[20130524.1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
index 9c562b4..9a57b1c 100755 (executable)
@@ -54,7 +54,7 @@ InstallationContext::InstallationContext(void)
 ,__isAppSetting(false)
 ,__isAntiVirus(false)
 ,__isCsc(false)
-,__isUninstallable(true)
+,__isUninstallable(false)
 ,__operation(INSTALLER_OPERATION_INSTALL)
 ,__storage(INSTALLATION_STORAGE_INTERNAL)
 ,__rootCertType(ROOT_CERTIFICATE_NONE)
index 9a466bc..293f7ee 100755 (executable)
@@ -349,49 +349,11 @@ ConfigurationManager::PostInstall(InstallationContext* pContext, bool error) con
 
        PackageId packageId = pContext->__packageId;
        std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
-       TryReturn(pPackageId, false, "pPackageId is null");
+       TryReturn(pPackageId, false, "pPackageId is null.");
 
        if (error == false)
        {
-               int err = 0;
-
-               std::unique_ptr<char[]> pXmlPath(_StringConverter::CopyToCharArrayN(pContext->__coreXmlPath));
-               TryReturn(pXmlPath != null, false, "pXmlPath is null");
-
-               AppLog("------------------------------------------");
-
-               if (pContext->__isUpdated == true)
-               {
-                       AppLog("pkgmgr_parser_parse_manifest_for_upgrade(%s) - START", pXmlPath.get());
-                       err = pkgmgr_parser_parse_manifest_for_upgrade(pXmlPath.get(), null);
-                       TryReturn(err == 0, false, "pkgmgr_parser_parse_manifest_for_upgrade() is failed. error = [%d][%s]", err, pXmlPath.get());
-
-                       AppLog("pkgmgr_parser_parse_manifest_for_upgrade() - END");
-               }
-               else
-               {
-                       AppLog("pkgmgr_parser_parse_manifest_for_installation(%s) - START", pXmlPath.get());
-                       err = pkgmgr_parser_parse_manifest_for_installation(pXmlPath.get(), null);
-                       TryReturn(err == 0, false, "pkgmgr_parser_parse_manifest_for_installation() is failed. error = [%d][%s]", err, pXmlPath.get());
-
-                       AppLog("pkgmgr_parser_parse_manifest_for_installation() - END");
-               }
-
-               AppLog("------------------------------------------");
-
-               String roXmlPath;
-               roXmlPath.Format(1024, DIR_RO_PACKAGE_SYSTEM_MANIFEST, pContext->__packageId.GetPointer());
-
-               if ((File::IsFileExist(roXmlPath) == true) && (pContext->__isHybridService == false)
-                               && (pContext->__isPreloaded == false))
-               {
-                       SetPreloadedProperty(packageId);
-               }
-
-               if (pContext->__isCsc == true)
-               {
-                       SetPackageProperty(pContext);
-               }
+               RegisterCoreXmlFile(pContext);
 
                SmackManager smackManager;
                smackManager.Construct(pContext);
@@ -442,7 +404,7 @@ ConfigurationManager::PostUninstall(InstallationContext* pContext) const
 }
 
 bool
-ConfigurationManager::CreateCoreXmlFile(InstallationContext* pContext)
+ConfigurationManager::CreateCoreXmlFile(InstallationContext* pContext) const
 {
        AppLog("------------------------------------------");
        AppLog("CreateCoreXmlFile() - START");
@@ -462,6 +424,79 @@ ConfigurationManager::CreateCoreXmlFile(InstallationContext* pContext)
        return ret;
 }
 
+bool
+ConfigurationManager::RegisterCoreXmlFile(InstallationContext* pContext) const
+{
+       if (pContext->__isHybridService == true)
+       {
+               AppLog("HybridService is skipped.");
+               return true;
+       }
+
+       std::unique_ptr<char[]> pXmlPath(_StringConverter::CopyToCharArrayN(pContext->__coreXmlPath));
+       TryReturn(pXmlPath != null, false, "pXmlPath is null.");
+
+       int err = 0;
+
+       if (pContext->__isCsc == true)
+       {
+               char* pUpdateTag[3] = {null, };
+
+               String preload("preload=true");
+               String removable("removable=");
+               if (pContext->__isUninstallable == false)
+               {
+                       removable.Append("false");
+               }
+               else
+               {
+                       removable.Append("true");
+               }
+
+               std::unique_ptr<char[]> pPreload(_StringConverter::CopyToCharArrayN(preload));
+               TryReturn(pPreload, false, "pPreload is null.");
+
+               std::unique_ptr<char[]> pRemovable(_StringConverter::CopyToCharArrayN(removable));
+               TryReturn(pRemovable, false, "pRemovable is null.");
+
+               pUpdateTag[0] = pPreload.get();
+               pUpdateTag[1] = pRemovable.get();
+               pUpdateTag[2] = null;
+
+               for (int i = 0; pUpdateTag[i] != null; i++)
+               {
+                       AppLog("pUpdateTag[%d] = [%s]", i, pUpdateTag[i]);
+               }
+
+               AppLog("pkgmgr_parser_parse_manifest_for_installation(%s) - START", pXmlPath.get());
+               err = pkgmgr_parser_parse_manifest_for_installation(pXmlPath.get(), pUpdateTag);
+               TryReturn(err == 0, false, "pkgmgr_parser_parse_manifest_for_installation() is failed. error = [%d][%s]", err, pXmlPath.get());
+
+               AppLog("pkgmgr_parser_parse_manifest_for_installation() - END");
+       }
+       else
+       {
+               if (pContext->__isUpdated == true)
+               {
+                       AppLog("pkgmgr_parser_parse_manifest_for_upgrade(%s) - START", pXmlPath.get());
+                       err = pkgmgr_parser_parse_manifest_for_upgrade(pXmlPath.get(), null);
+                       TryReturn(err == 0, false, "pkgmgr_parser_parse_manifest_for_upgrade() is failed. error = [%d][%s]", err, pXmlPath.get());
+
+                       AppLog("pkgmgr_parser_parse_manifest_for_upgrade() - END");
+               }
+               else
+               {
+                       AppLog("pkgmgr_parser_parse_manifest_for_installation(%s) - START", pXmlPath.get());
+                       err = pkgmgr_parser_parse_manifest_for_installation(pXmlPath.get(), null);
+                       TryReturn(err == 0, false, "pkgmgr_parser_parse_manifest_for_installation() is failed. error = [%d][%s]", err, pXmlPath.get());
+
+                       AppLog("pkgmgr_parser_parse_manifest_for_installation() - END");
+               }
+       }
+
+       return true;
+}
+
 //bool
 //ConfigurationManager::CreateHybridServiceDesktopFile(InstallationContext* pContext)
 //{
@@ -942,77 +977,3 @@ ConfigurationManager::FindPrivilege(InstallationContext* pContext, const String&
 
        return ret;
 }
-
-bool
-ConfigurationManager::SetPreloadedProperty(const PackageId& packageId) const
-{
-       TryReturn(packageId.IsEmpty() == false, false, "packageId is empty.");
-
-       std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
-       TryReturn(pPackageId, false, "pPackageId is null.");
-
-       bool ret = true;
-       int res = PMINFO_R_OK;
-       pkgmgrinfo_pkgdbinfo_h handle = null;
-
-       res = pkgmgrinfo_create_pkgdbinfo(pPackageId.get(), &handle);
-       TryCatch(res == PMINFO_R_OK, ret = false, "pkgmgrinfo_create_pkgdbinfo() failed. [%d]", res);
-
-       res = pkgmgrinfo_set_preload_to_pkgdbinfo(handle, 1);
-       TryCatch(res == PMINFO_R_OK, ret = false, "pkgmgrinfo_set_preload_to_pkgdbinfo() failed. [%d]", res);
-
-       res = pkgmgrinfo_save_pkgdbinfo(handle);
-       TryCatch(res == PMINFO_R_OK, ret = false, "pkgmgrinfo_save_pkgdbinfo() failed. [%d]", res);
-
-       AppLog("Preloaded property is set. [%ls] ", packageId.GetPointer());
-
-CATCH:
-       if (handle)
-       {
-               pkgmgrinfo_destroy_pkgdbinfo(handle);
-       }
-
-       return ret;
-}
-
-bool
-ConfigurationManager::SetPackageProperty(InstallationContext* pContext) const
-{
-       TryReturn(pContext, false, "pContext is null.");
-
-       std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(pContext->__packageId));
-       TryReturn(pPackageId, false, "pPackageId is null.");
-
-       bool ret = true;
-       int res = PMINFO_R_OK;
-       int removable = 1;
-       pkgmgrinfo_pkgdbinfo_h handle = null;
-
-       if (pContext->__isUninstallable == false)
-       {
-               removable = 0;
-       }
-
-       res = pkgmgrinfo_create_pkgdbinfo(pPackageId.get(), &handle);
-       TryCatch(res == PMINFO_R_OK, ret = false, "pkgmgrinfo_create_pkgdbinfo() failed. [%d]", res);
-
-       res = pkgmgrinfo_set_preload_to_pkgdbinfo(handle, 1);
-       TryCatch(res == PMINFO_R_OK, ret = false, "pkgmgrinfo_set_preload_to_pkgdbinfo() failed. [%d]", res);
-
-       res = pkgmgrinfo_set_removable_to_pkgdbinfo(handle, removable);
-       TryCatch(res == PMINFO_R_OK, ret = false, "pkgmgrinfo_set_removable_to_pkgdbinfo(%d) failed. [%d]", removable, res);
-
-       res = pkgmgrinfo_save_pkgdbinfo(handle);
-       TryCatch(res == PMINFO_R_OK, ret = false, "pkgmgrinfo_save_pkgdbinfo() failed. [%d]", res);
-
-       AppLog("Preloaded property is set. [%s]", pPackageId.get());
-       AppLog("Removable property is set. [%s]", removable?"true":"false");
-
-CATCH:
-       if (handle)
-       {
-               pkgmgrinfo_destroy_pkgdbinfo(handle);
-       }
-
-       return ret;
-}
index 97210fb..b4107b2 100755 (executable)
@@ -46,7 +46,8 @@ public:
        bool PostUninstall(InstallationContext* pContext) const;
 
 private:
-       bool CreateCoreXmlFile(InstallationContext* pContext);
+       bool CreateCoreXmlFile(InstallationContext* pContext) const;
+       bool RegisterCoreXmlFile(InstallationContext* pContext) const;
        // bool CreateHybridServiceDesktopFile(InstallationContext* pContext);
        bool MergeToSystemXmlFile(const Tizen::Base::String& systemXmlPath, const Tizen::Base::String& webXmlPath,const Tizen::Base::String& serviceXmlPath);
        bool MergePrivileges(char* pMergedBuf, char* pServiceBuf, int& fileSize);
@@ -62,8 +63,6 @@ private:
 
        bool CreateImeSymlink(const Tizen::Base::String& binaryPath, const Tizen::Base::String& packageName);
        bool FindPrivilege(InstallationContext* pContext, const Tizen::Base::String& privilege) const;
-       bool SetPreloadedProperty(const Tizen::App::PackageId& packageId) const;
-       bool SetPackageProperty(InstallationContext* pContext) const;
 
 }; // ConfigurationManager
 
index 507a97a..cf31ee7 100755 (executable)
@@ -507,10 +507,10 @@ InstallerManager::ParseOptionalData(const String* pOptionalData)
                        AppLog(" # storeClient = [%ls]", storeClientId.GetPointer());
                }
 
-               if (removable.Equals(L"false", false) == true)
+               if (removable.Equals(L"true", false) == true)
                {
-                       __pContext->__isUninstallable = false;
-                       AppLog(" # removable = [false]");
+                       __pContext->__isUninstallable = true;
+                       AppLog(" # removable = [true]");
                }
        }
 
index 03d4c29..7fb2e99 100755 (executable)
@@ -401,40 +401,6 @@ SmackManager::EnablePermissions(const PackageId& packageId)
                res = EnablePermissions(pPackageId.get(), 1, pNullList, true);
        }
 
-#if 0
-       if ((__pContext->__isPreloaded == true) && (__pContext->__isUpdated == false))
-       {
-               String smackFile(L"/etc/smack/accesses2.d/");
-               smackFile.Append(packageId);
-               smackFile.Append(L"-temp.rule");
-
-               String smackContext(packageId);
-               smackContext.Append(L" all.rule include");
-
-               InstallerUtil::CreateInfoFile(smackFile, &smackContext);
-       }
-       else
-       {
-               String script("/usr/bin/smackload-app.sh");
-               bool exist = File::IsFileExist(script);
-               script.Append(L" ");
-               script.Append(packageId);
-
-               std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(script));
-               TryReturn(pScript, false, "pScript is null.");
-
-               if (exist == true)
-               {
-                       res = system(pScript.get());
-                       AppLog("[smack] system(%s), result = [%d]", pScript.get(), res);
-               }
-               else
-               {
-                       AppLog("[%ls] not found", script.GetPointer());
-               }
-       }
-#endif
-
        return true;
 }