add untrusted source check and invalid package check
authorsangsoo lee <sangs87.lee@samsung.com>
Fri, 19 Apr 2013 08:20:53 +0000 (17:20 +0900)
committersangsoo lee <sangs87.lee@samsung.com>
Fri, 19 Apr 2013 08:20:53 +0000 (17:20 +0900)
Change-Id: If75c8e5650a07860e775fab8efbcd1e5444a103f

inc/IstDetailForm.h
src/IstDetailForm.cpp

index 93cd392..01e9a28 100644 (file)
@@ -93,6 +93,8 @@ private:
 
        int __itemCount;
        bool __isInstalled;
+       bool __isValidPackage;
+       bool __isUntrustedSource;
        bool __isUpdatable;
 };
 
index 2f7476e..7af3f74 100644 (file)
@@ -135,13 +135,19 @@ DetailForm::GetDescriptionInfo(int groupIndex, int itemIndex, String& name, Stri
        PrivilegeInfo* pPrivilege = null;
 
        TryReturn(groupIndex == 0, E_FAILURE, "Group Index Error");
+
        if (__pPrivilegeList != null){
                pPrivilege = dynamic_cast <PrivilegeInfo*>(__pPrivilegeList->GetAt(itemIndex));
        }
+       else{
+               AppLogException("__pPrivilegeList is empty");
+       }
 
        if (pPrivilege != null){
                pPrivilege->GetDisplayName().IsEmpty() == false ? name = pPrivilege->GetDisplayName() : name = "";
                pPrivilege->GetDescription().IsEmpty() == false ? description = pPrivilege->GetDescription() : description = "";
+               AppLog("name : %ls", name.GetPointer());
+               AppLog("description : %ls", description.GetPointer());
        }
 
        return E_SUCCESS;
@@ -161,6 +167,16 @@ DetailForm::ParsingTPK()
        __pTargetPackageInfo = pMgr->GetPackageInfoFromFileN(filePath);
        TryReturn(__pTargetPackageInfo != null, GetLastResult(), "[%s] Package Path is not delivered", GetErrorMessage(GetLastResult()))
 
+       String UNTRUSTED_SOURCE = L"UnknownSrc";
+       if (__pTargetPackageInfo->GetStoreClientId().IsEmpty()){
+               AppLogException("Store Client id is Empty");
+       }
+       else if (__pTargetPackageInfo->GetStoreClientId().CompareTo(UNTRUSTED_SOURCE) == 0){
+               __isUntrustedSource = true;
+       }
+       __isUntrustedSource = true;
+       AppLog("Store resource id : %ls", __pTargetPackageInfo->GetStoreClientId().GetPointer());
+
        __pHeader->SetTitleText(__pTargetPackageInfo->GetDisplayName());
        packageId = __pTargetPackageInfo->GetId().GetPointer();
        TryReturn(packageId.IsEmpty() == false, E_FAILURE, "pakcageId is Empty!!!");
@@ -208,8 +224,13 @@ DetailForm::ParsingTPK()
        }
 
        __pPrivilegeList = __pTargetPackageInfo->GetPrivilegeListN();
-       if (__pPrivilegeList)           {
+       result res = GetLastResult();
+       TryReturn(res == E_SUCCESS, res, "[%s] GetPrivilegeListN() error occurred", GetErrorMessage(res));
+
+       if (__pPrivilegeList)
+       {
                __itemCount = __pPrivilegeList->GetCount();
+               AppLog("item count : %d ", __itemCount);
        }
        else{
                AppLog("No Privilege List");
@@ -235,8 +256,8 @@ void
 DetailForm::SetInfoTextBox()
 {
        String installMsg = L"Do you want to install this application?\n\nAllow this application to:";
-       if (__isInstalled){
-               installMsg.Append(L"\n\n(application will be updated)");
+       if (__isUntrustedSource){
+               installMsg.Append(L"\n\n(Unknown sources)");
        }
        __pTextBox = static_cast<TextBox *>(GetControl(L"IDC_INFO_TEXTBOX"));
        __pTextBox->SetText(installMsg);
@@ -290,9 +311,14 @@ DetailForm::SetPopupControl()
 
        InstallerApp* pUiApp =  static_cast<InstallerApp*>(UiApp::GetInstance());
        String packagePath = pUiApp->GetPackagePath();
-       if (packagePath.IsEmpty() || pUiApp->IsValidAccess() == false)
+       if (packagePath.IsEmpty() || pUiApp->IsValidAccess() == false || !__isValidPackage)
        {
-               pTextBox->SetText(L"Wrong Execution.");
+               if (!__isValidPackage){
+                       pTextBox->SetText(L"Invalid Package.");
+               }
+               else{
+                       pTextBox->SetText(L"Wrong Execution.");
+               }
                __pPopup->AddControl(pTextBox);
                pButtonClose->SetPosition(X_CANCEL_BTN_ALONE, pButtonClose->GetY());
                __pPopup->AddControl(pButtonClose);
@@ -353,8 +379,13 @@ DetailForm::OnInitializing(void)
        __itemCount = 0;
        __isUpdatable = false;
        __isInstalled = false;
+       __isValidPackage = true;
        // parsing tpk package info then get and set item count
-       ParsingTPK();
+       r = ParsingTPK();
+       if (r != E_SUCCESS)
+       {
+               __isValidPackage = false;
+       }
 
        // Install Confirmation Popup
        SetPopupControl();