Change smack api for readers
authorDuyoung Jang <duyoung.jang@samsung.com>
Thu, 2 May 2013 14:09:50 +0000 (23:09 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Thu, 2 May 2013 14:09:50 +0000 (23:09 +0900)
Change-Id: I650e97aaff1ccfbab5fbf4b71841e8a405f681f2
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
inc/InstallerDefs.h
src/Manager/InstallerManager.cpp
src/Manager/SmackManager.cpp
src/Manager/SmackManager.h

index aeaaa36..843dce3 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130502.6]"
+#define OSP_INSTALLER_VERSION "version=[20130502.7]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
index 91e722d..5192a11 100755 (executable)
@@ -960,6 +960,10 @@ CATCH:
                {
                        InstallerUtil::PrintLog(pInstallManager->GetLogFilePath());
                }
+               else
+               {
+                       InstallerUtil::Remove(pInstallManager->GetHistoryLogFilePath());
+               }
 
                pInstallManager->Release();
        }
index 83c1890..74a070b 100755 (executable)
@@ -23,6 +23,7 @@
 #include <unique_ptr.h>
 
 #include <FAppPkgPackageInfo.h>
+#include <FIoDirectory.h>
 #include <FIoFile.h>
 #include <FIoRegistry.h>
 #include <FSecCryptoSha1Hash.h>
@@ -180,7 +181,8 @@ SmackManager::AddLabelSharedDir(const PackageId& packageId, const String& dirPat
 
        if (dirPath.Contains(L"shared/data") == true)
        {
-               label.Append("_shareddata");
+               label = L"*";
+               //label.Append("_shareddata");
                AddSharedDirReaders(label);
        }
        else if (dirPath.Contains(L"shared/trusted") == true)
@@ -231,7 +233,7 @@ SmackManager::AddLabelSharedDir(const PackageId& packageId, const String& dirPat
 }
 
 bool
-SmackManager::AddSharedDirReaders(const Tizen::Base::String& label)
+SmackManager::AddSharedDirReaders(const String& label)
 {
        if (__isSmackEnable == false)
        {
@@ -242,11 +244,19 @@ SmackManager::AddSharedDirReaders(const Tizen::Base::String& label)
 
        int error = 0;
        bool res = true;
+       IList* pPackageList = null;
 
        std::unique_ptr<char[]> pLabel(_StringConverter::CopyToCharArrayN(label));
        TryReturn(pLabel, false, "pLabel is null.");
 
-       std::unique_ptr< IList > pPackageList(_PackageManagerImpl::GetInstance()->GetPackageInfoListN());
+       if (__pContext->__isPreloaded == true)
+       {
+               pPackageList = GetPreloadedAppListN();
+       }
+       else
+       {
+               pPackageList = _PackageManagerImpl::GetInstance()->GetPackageInfoListN();
+       }
        TryReturn(pPackageList, false, "pPackageList is null.");
 
        int count = pPackageList->GetCount();
@@ -259,22 +269,45 @@ SmackManager::AddSharedDirReaders(const Tizen::Base::String& label)
 
        for (int i = 0; i < count; i++)
        {
-               PackageInfo* pPackageInfo = dynamic_cast < PackageInfo* >(pPackageList->GetAt(i));
-               if (pPackageInfo)
+               if (__pContext->__isPreloaded == true)
                {
-                       PackageId packageId = pPackageInfo->GetId();
-
-                       if (packageId == __pContext->__packageId)
+                       String* pPackage = dynamic_cast < String* >(pPackageList->GetAt(i));
+                       if (pPackage)
                        {
-                               AppLog("packageId [%ls] is skipped.", packageId.GetPointer());
-                               continue;
+                               PackageId packageId = *pPackage;
+
+                               if (packageId == __pContext->__packageId)
+                               {
+                                       AppLog("package [%ls] is skipped.", packageId.GetPointer());
+                                       continue;
+                               }
+
+                               std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
+                               TryCatch(pPackageId, res = false, "pPackage is null.");
+
+                               pList[i] = pPackageId.release();
+                               AppLog("Package - [%s]", pList[i]);
                        }
+               }
+               else
+               {
+                       PackageInfo* pPackage = dynamic_cast < PackageInfo* >(pPackageList->GetAt(i));
+                       if (pPackage)
+                       {
+                               PackageId packageId = pPackage->GetId();
+
+                               if (packageId == __pContext->__packageId)
+                               {
+                                       AppLog("package [%ls] is skipped.", packageId.GetPointer());
+                                       continue;
+                               }
 
-                       std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
-                       TryCatch(pPackageId, res = false, "pPackageId is null.");
+                               std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
+                               TryCatch(pPackageId, res = false, "pPackage is null.");
 
-                       pList[i] = pPackageId.release();
-                       AppLog("Package - [%s]", pList[i]);
+                               pList[i] = pPackageId.release();
+                               AppLog("Package - [%s]", pList[i]);
+                       }
                }
         }
 
@@ -289,6 +322,7 @@ CATCH:
                delete[] pList[i];
         }
        delete[] pList;
+       delete pPackageList;
 
        return res;
 }
@@ -729,3 +763,59 @@ SmackManager::RegisterAv(const char* pPackageId)
        return ret;
 
 }
+
+ArrayList*
+SmackManager::GetPreloadedAppListN() const
+{
+       result r = E_SUCCESS;
+
+       std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList());
+       TryReturn(pList, null, "pList is null.");
+
+       r = pList->Construct();
+       TryReturn(r == E_SUCCESS, null, "pList->Construct() failed.");
+
+       std::unique_ptr< Directory > pDir(new (std::nothrow) Directory());
+       TryReturn(pDir, null, "pDir is null.");
+
+       r = pDir->Construct(PATH_USR_APPS);
+       TryReturn(r == E_SUCCESS, null, "pDir->Construct() failed.");
+
+       std::unique_ptr< DirEnumerator > pDirEnum(pDir->ReadN());
+       TryReturn(pDirEnum, null, "pDirEnum is null.");
+
+       while (pDirEnum->MoveNext() == E_SUCCESS)
+       {
+               DirEntry entry = pDirEnum->GetCurrentDirEntry();
+               String entryName = entry.GetName();
+
+               if (entryName == L"." || entryName == L"..")
+               {
+                       continue;
+               }
+
+               if (entry.IsDirectory() == false)
+               {
+                       continue;
+               }
+
+               const int entryLength = entryName.GetLength();
+               if (entryLength != PACKAGE_ID_LENGTH)
+               {
+                       continue;
+               }
+
+               std::unique_ptr< String > pPackageId(new (std::nothrow) String(entryName));
+               TryReturn(pPackageId, null, "pPackageId is null.");
+
+               pList->Add(pPackageId.release());
+       }
+
+       if (pList->GetCount() <= 0)
+       {
+               AppLog("pList's count is 0.");
+               return null;
+       }
+
+       return pList.release();
+}
index 0734cbc..2a3f7e3 100755 (executable)
@@ -61,6 +61,8 @@ private:
 
        int RegisterAv(const char* pPackageId);
 
+       Tizen::Base::Collection::ArrayList* GetPreloadedAppListN() const;
+
 private:
        InstallationContext* __pContext;
        bool __isSmackEnable;