Add preloaded, removable property for csc
authorDuyoung Jang <duyoung.jang@samsung.com>
Tue, 30 Apr 2013 05:20:52 +0000 (14:20 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Tue, 30 Apr 2013 05:48:17 +0000 (14:48 +0900)
Change-Id: I254d32e061ba603a8570a171d66fc276b08b2a9b
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
inc/InstallerDefs.h
src/Context/InstallationContext.cpp
src/Context/InstallationContext.h
src/Manager/ConfigurationManager.cpp
src/Manager/ConfigurationManager.h
src/Manager/InstallerManager.cpp

index f2a5df6..58537e7 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130429.3]"
+#define OSP_INSTALLER_VERSION "version=[20130430.1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
@@ -216,6 +216,7 @@ enum InstallerOption
        INSTALLER_OPTION_NO_INPUT = 16,
        INSTALLER_OPTION_FILELOG_ON = 32,
        INSTALLER_OPTION_UPDATE_STDOUT = 64,
+       INSTALLER_OPTION_CSC = 128,
 
 };
 
index 8e36bef..9c562b4 100755 (executable)
@@ -53,6 +53,8 @@ InstallationContext::InstallationContext(void)
 ,__isUpdated(false)
 ,__isAppSetting(false)
 ,__isAntiVirus(false)
+,__isCsc(false)
+,__isUninstallable(true)
 ,__operation(INSTALLER_OPERATION_INSTALL)
 ,__storage(INSTALLATION_STORAGE_INTERNAL)
 ,__rootCertType(ROOT_CERTIFICATE_NONE)
index ca70c7f..c566c56 100755 (executable)
@@ -95,13 +95,14 @@ public:
        Tizen::Base::Collection::IListT<AppData *>* __pAppDataList;
 
        bool __isOspCompat;
-
        bool __isPreloaded;
        bool __isHybridService;
        bool __isVerificationMode;
        bool __isUpdated;
        bool __isAppSetting;
        bool __isAntiVirus;
+       bool __isCsc;
+       bool __isUninstallable;
 
        InstallerOperation __operation;
        InstallationStorage __storage;
@@ -137,7 +138,7 @@ public:
        Tizen::Base::String __author;
        Tizen::Base::String __url;
        Tizen::Base::String __description;
-       Tizen::App::AppId __storeClientId;
+       Tizen::App::PackageId __storeClientId;
        Tizen::Base::String __additionalErrorString;
 
        int __certType;
index 4cc3bb3..c5efd44 100755 (executable)
@@ -370,6 +370,11 @@ ConfigurationManager::PostInstall(InstallationContext* pContext, bool error) con
                        SetPreloadedProperty(packageId);
                }
 
+               if (pContext->__isCsc == true)
+               {
+                       SetPackageProperty(pContext);
+               }
+
                SmackManager smackManager;
                smackManager.Construct(pContext);
                smackManager.EnablePermissions(packageId);
@@ -954,3 +959,45 @@ CATCH:
 
        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 8357fde..97210fb 100755 (executable)
@@ -63,6 +63,7 @@ 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 c35bc53..7084155 100755 (executable)
@@ -150,6 +150,12 @@ InstallerManager::Construct(const String& path, InstallerOperation operation, In
                }
                else
                {
+                       if (option & INSTALLER_OPTION_CSC)
+                       {
+                               AppLog("INSTALLER_OPTION_CSC is detected.");
+                               __pContext->__isCsc = true;
+                       }
+
                        installerType = INSTALLER_TYPE_PACKAGE;
                        __pContext->__packagePath = newPath;
                }
@@ -458,13 +464,11 @@ InstallerManager::ParseOptionalData(const String* pOptionalData)
                        AppLog(" # storeClient = [%ls]", storeClientId.GetPointer());
                }
 
-#if 0
-               if (removable.IsEmpty() == false)
+               if (removable.Equals(L"false", false) == true)
                {
-                       // TODO : removable
+                       __pContext->__isUninstallable = false;
+                       AppLog(" # removable = [false]");
                }
-#endif
-
        }
 
        return true;
@@ -579,6 +583,7 @@ InstallerManager::ParseCommandArg(int argc, char **argv, int *mode, char *buf, I
 
                        AppLog("__osp_installer_parse_options: c");
                        option = (InstallerOption)(option | INSTALLER_OPTION_UPDATE_STDOUT);
+                       option = (InstallerOption)(option | INSTALLER_OPTION_CSC);
                        *mode = INSTALLER_MODE_PARSE_CSC_STRING;
                        AppLog("__osp_installer_parse_options: argv[optind] = [%s]", argv[optind]);
                        strncpy(buf, argv[optind], BUFSIZE);
@@ -1257,6 +1262,9 @@ InstallerManager::RequestCsc(const String& buffer, InstallerOption option)
        String path;
        String removable;
 
+       // format -> "path=/opt/usr/apps/22VoFBmj2I/:op=install:removable=true"
+       // format -> "path=yandexmaps:op=uninstall"
+
        while (pEnum->MoveNext() == E_SUCCESS)
        {
                String* pKey = static_cast< String* > (pEnum->GetKey());
@@ -1287,7 +1295,7 @@ InstallerManager::RequestCsc(const String& buffer, InstallerOption option)
 
        if (op.Equals(L"install", false) == true)
        {
-               errorType = InstallerManager::Request(path, INSTALLER_OPERATION_INSTALL, option, null);
+               errorType = InstallerManager::Request(path, INSTALLER_OPERATION_INSTALL, option, null, &buffer);
        }
        else if (op.Equals(L"uninstall", false) == true)
        {