From 30d56cc39ff300f518fd585ea795341113609dc8 Mon Sep 17 00:00:00 2001 From: sangsoo lee Date: Thu, 18 Apr 2013 21:25:11 +0900 Subject: [PATCH] fix popup control issue modify installation permission Change-Id: Ice27d7e2ee878ed86dc242d0a5b1bf6e334f909e --- .cproject | 551 ++++++++++------------------------------ .project | 15 +- inc/AppResourceId.h | 39 +++ inc/IstInstallForm.h | 2 +- manifest.xml | 6 +- src/AppResourceId.cpp | 26 ++ src/IstDetailForm.cpp | 55 ++-- src/IstInstallEventListener.cpp | 27 +- src/IstInstallForm.cpp | 33 +-- src/IstInstallerApp.cpp | 3 +- 10 files changed, 290 insertions(+), 467 deletions(-) create mode 100644 inc/AppResourceId.h create mode 100644 src/AppResourceId.cpp diff --git a/.cproject b/.cproject index b08e532..8fce031 100644 --- a/.cproject +++ b/.cproject @@ -1,8 +1,8 @@ - - + + @@ -15,82 +15,83 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -295,76 +156,77 @@ - - - - - - - - - - + + @@ -429,222 +291,84 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -697,23 +428,17 @@ - + - - - - - - - + - + - + diff --git a/.project b/.project index d6345e6..c742382 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - InstallerRSA + $(projectName) @@ -30,7 +30,7 @@ org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/InstallService/Debug-Tizen-Emulator} + ${workspace_loc:/$(projectName)/Debug} org.eclipse.cdt.make.core.cleanBuildTarget @@ -85,4 +85,15 @@ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature org.tizen.nativecpp.apichecker.core.tizenCppNature + + + 1360216703005 + + 26 + + org.eclipse.ui.ide.multiFilter + 1.0-projectRelativePath-matches-false-false-*/.tpk + + + diff --git a/inc/AppResourceId.h b/inc/AppResourceId.h new file mode 100644 index 0000000..89af834 --- /dev/null +++ b/inc/AppResourceId.h @@ -0,0 +1,39 @@ +#ifndef _APP_RESOURCE_ID_H_ +#define _APP_RESOURCE_ID_H_ + +#include +#include + +using namespace Tizen::Graphics; + +extern const wchar_t* IDF_FORM; +extern const wchar_t* ID_SCNT_MAINSCENE; +extern const wchar_t* IDC_BUTTON_OK; + + +static const int INSTALL_SUCCESS_EVENT = 2000; +static const int INSTALL_FAIL_STORAGE_FULL = 2001; +static const int INSTALL_FAIL_INVALID_PACKAGE = 2002; +static const int INSTALL_PROGRESS_VALUE = 2003; + +extern const wchar_t* HEADER_IMAGE; +extern const wchar_t* APP_NAME; +extern const wchar_t* FILE_URI_SCHEME; + +extern Tizen::Base::String __uriData; +extern Tizen::Base::String __packagePath; + +extern const int GAP_BETWEEN_FORM_POPUP; +extern const int X_POPUP_LABLE; +extern const int Y_POPUP_LABLE; +extern const int H_POPUP_LABLE; +extern const int GAP_BETWEEN_POPUP_LABEL; +extern const int GAP_BETWEEN_POPUP_BUTTON; +extern const int UI_H_POPUP; +extern const int UI_H_POPUP_BUTTON; +extern const int H_POPUP_TITLE; +extern const int H_TEXT_LINE; +extern const int GAP_BETWEEN_BUTTON; +extern const int X_CANCEL_BTN_ALONE; + +#endif // _APP_RESOURCE_ID_H_ diff --git a/inc/IstInstallForm.h b/inc/IstInstallForm.h index 9e7f7e7..77190d3 100644 --- a/inc/IstInstallForm.h +++ b/inc/IstInstallForm.h @@ -60,7 +60,7 @@ public: private: int __timerCounter; bool __isInstalling; - InstallEventListener* __appInstallObj; + InstallEventListener* __pInstallListener; Timer* __pTimer; Tizen::Ui::Controls::Header* __pHeader; diff --git a/manifest.xml b/manifest.xml index ad8f33c..aabd2fe 100644 --- a/manifest.xml +++ b/manifest.xml @@ -4,17 +4,17 @@ 1.0.0 C++App - true + true true - 2.0 + 2.1 + http://tizen.org/privilege/packagemanager.info http://tizen.org/privilege/application.launch http://tizen.org/privilege/appusage http://tizen.org/privilege/packageinfo http://tizen.org/privilege/packagemanager.install - http://tizen.org/privilege/packagemanager.info diff --git a/src/AppResourceId.cpp b/src/AppResourceId.cpp new file mode 100644 index 0000000..f2fa381 --- /dev/null +++ b/src/AppResourceId.cpp @@ -0,0 +1,26 @@ +#include "AppResourceId.h" + +const wchar_t* IDF_FORM = L"IDF_FORM"; +const wchar_t* ID_SCNT_MAINSCENE = L"ID_SCNT_MAINSCENE"; +const wchar_t* IDC_BUTTON_OK = L"IDC_BUTTON_OK"; + +const int GAP_BETWEEN_FORM_POPUP = 28; +const int X_POPUP_LABLE = 0; +const int Y_POPUP_LABLE = 0; +const int H_POPUP_LABLE = 300; +const int GAP_BETWEEN_POPUP_LABEL = 25; +const int GAP_BETWEEN_POPUP_BUTTON = GAP_BETWEEN_POPUP_LABEL; +const int UI_H_POPUP = 330; +const int UI_H_POPUP_BUTTON = 74; +const int H_POPUP_TITLE = 50; +const int H_TEXT_LINE = 150; +const int GAP_BETWEEN_BUTTON = 10; +const int X_CANCEL_BTN_ALONE = 160; + + +const wchar_t* HEADER_IMAGE = L"home_type3.png"; +const wchar_t* APP_NAME = L"Installer"; +const wchar_t* FILE_URI_SCHEME = L"file://"; + +Tizen::Base::String __uriData; +Tizen::Base::String __packagePath; diff --git a/src/IstDetailForm.cpp b/src/IstDetailForm.cpp index 1e40790..2f7476e 100644 --- a/src/IstDetailForm.cpp +++ b/src/IstDetailForm.cpp @@ -26,7 +26,7 @@ #include "IstInstallerApp.h" #include "IstInstallEventListener.h" #include "IstInstallerApp.h" -#include "IstTypes.h" +#include "AppResourceId.h" #include "IstMainFrame.h" using namespace Tizen::Base; @@ -135,7 +135,9 @@ DetailForm::GetDescriptionInfo(int groupIndex, int itemIndex, String& name, Stri PrivilegeInfo* pPrivilege = null; TryReturn(groupIndex == 0, E_FAILURE, "Group Index Error"); - pPrivilege = dynamic_cast (__pPrivilegeList->GetAt(itemIndex)); + if (__pPrivilegeList != null){ + pPrivilege = dynamic_cast (__pPrivilegeList->GetAt(itemIndex)); + } if (pPrivilege != null){ pPrivilege->GetDisplayName().IsEmpty() == false ? name = pPrivilege->GetDisplayName() : name = ""; @@ -194,7 +196,7 @@ DetailForm::ParsingTPK() __isInstalled = true; localVersion = pLocalPackageInfo->GetVersion(); // Upper Version Check - if (__pTargetPackageInfo->GetVersion().CompareTo(localVersion) <= 0){ + if (__pTargetPackageInfo->GetVersion().CompareTo(localVersion) < 0){ __isUpdatable = false; } else{ @@ -256,9 +258,12 @@ DetailForm::SetListItemImage(AppResource* pAppResource) void DetailForm::SetPopupControl() { + RelativeLayout popupLayout; + popupLayout.Construct(); + int popupWidth = GetClientAreaBounds().width - GAP_BETWEEN_FORM_POPUP * 2; __pPopup = new (std::nothrow) Popup(); - __pPopup->Construct(true, Dimension(popupWidth, UI_H_POPUP)); + __pPopup->Construct(popupLayout, true, Dimension(popupWidth, UI_H_POPUP)); __pPopup->SetTitleText(L"Install Application"); __pPopup->SetTitleTextColor(Color::GetColor(COLOR_ID_BLACK)); @@ -285,20 +290,42 @@ DetailForm::SetPopupControl() InstallerApp* pUiApp = static_cast(UiApp::GetInstance()); String packagePath = pUiApp->GetPackagePath(); - if (packagePath.IsEmpty() || pUiApp->IsValidAccess() == false){ + if (packagePath.IsEmpty() || pUiApp->IsValidAccess() == false) + { pTextBox->SetText(L"Wrong Execution."); __pPopup->AddControl(pTextBox); pButtonClose->SetPosition(X_CANCEL_BTN_ALONE, pButtonClose->GetY()); + __pPopup->AddControl(pButtonClose); + + popupLayout.SetRelation(*pButtonClose, __pPopup, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM); + popupLayout.SetCenterAligned(*pButtonClose, CENTER_ALIGN_HORIZONTAL); + popupLayout.SetMargin(*pButtonClose, 0, 16, 0, 20); } - else if (__isInstalled && !__isUpdatable){ + else if (__isInstalled && !__isUpdatable) + { __pPopup->AddControl(pTextBox); pButtonClose->SetPosition(X_CANCEL_BTN_ALONE, pButtonClose->GetY()); + __pPopup->AddControl(pButtonClose); + + popupLayout.SetRelation(*pButtonClose, __pPopup, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM); + popupLayout.SetCenterAligned(*pButtonClose, CENTER_ALIGN_HORIZONTAL); + popupLayout.SetMargin(*pButtonClose, 0, 16, 0, 20); } - else{ + else + { __pPopup->AddControl(popUpLabel); __pPopup->AddControl(pButtonInstall); + __pPopup->AddControl(pButtonClose); + + popupLayout.SetRelation(*pButtonInstall, __pPopup, RECT_EDGE_RELATION_LEFT_TO_LEFT); + popupLayout.SetRelation(*pButtonInstall, __pPopup, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM); + popupLayout.SetMargin(*pButtonInstall, 16, 0, 0, 20); + popupLayout.SetRelation(*pButtonClose, __pPopup, RECT_EDGE_RELATION_RIGHT_TO_RIGHT); + popupLayout.SetRelation(*pButtonClose, __pPopup, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM); + popupLayout.SetMargin(*pButtonClose, 0, 16, 0, 20); } - __pPopup->AddControl(pButtonClose); + popupLayout.Update(); + } result @@ -306,14 +333,12 @@ DetailForm::OnInitializing(void) { result r = E_SUCCESS; AppResource* pAppResource = Application::GetInstance()->GetAppResource(); - // Set Image Control SetListItemImage(pAppResource); // Header Item set __pHeader = GetHeader(); __pHeader->SetTitleIcon(__pHeaderImage); - // Footer Item Set FooterItem footerItem1; footerItem1.Construct(IDA_INSTALL_BTN); @@ -328,7 +353,6 @@ DetailForm::OnInitializing(void) __itemCount = 0; __isUpdatable = false; __isInstalled = false; - // parsing tpk package info then get and set item count ParsingTPK(); @@ -344,7 +368,6 @@ DetailForm::OnInitializing(void) __pList->SetShowState(false); Invalidate(true); - return r; } @@ -373,14 +396,6 @@ DetailForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) { TryReturnVoid(__pTargetPackageInfo, "target package info is empty"); - // In case of package update, previous running app has to be closed(killed) - AppManager* pAppManager = AppManager::GetInstance(); - String pakcageId = __pTargetPackageInfo->GetId() + L"." + __pTargetPackageInfo->GetDisplayName(); - if (pAppManager->IsRunning(pakcageId)){ - //TODO: is this check necessary? - pAppManager->TerminateApplication(pakcageId); - } - IList* pArgs = null; pArgs = new (std::nothrow) ArrayList(); pArgs->Add(*(new (std::nothrow) String(__pTargetPackageInfo->GetDisplayName()))); diff --git a/src/IstInstallEventListener.cpp b/src/IstInstallEventListener.cpp index 5fe5de1..ce3c286 100644 --- a/src/IstInstallEventListener.cpp +++ b/src/IstInstallEventListener.cpp @@ -25,7 +25,7 @@ #include #include "IstInstallEventListener.h" -#include "IstTypes.h" +#include "AppResourceId.h" using namespace Tizen::App; using namespace Tizen::App::Package; @@ -43,6 +43,17 @@ void InstallEventListener::OnPackageInstallationResponseReceived(const PackageId& packageId, PackageInstallationResult installationResult) { IList* pArgs = null; + Tizen::Ui::Controls::Form* pForm = null; + if (UiApp::GetInstance() != null && UiApp::GetInstance()->GetFrame(APP_NAME) != null && UiApp::GetInstance()->GetFrame(APP_NAME)->GetCurrentForm() != null ) + { + pForm = UiApp::GetInstance()->GetFrame(APP_NAME)->GetCurrentForm(); + } + else + { + AppLogException("Get Form Instance Error"); + return; + } + switch(installationResult) { case PACKAGE_INSTALLATION_RESULT_SUCCESS: @@ -51,19 +62,20 @@ InstallEventListener::OnPackageInstallationResponseReceived(const PackageId& pac pArgs = new (std::nothrow) ArrayList(); pArgs->Add(*(new (std::nothrow) String(data))); - UiApp::GetInstance()->GetFrame(APP_NAME)->GetCurrentForm()->SendUserEvent(INSTALL_SUCCESS_EVENT, pArgs); + pForm->SendUserEvent(INSTALL_SUCCESS_EVENT, pArgs); + } break; case PACKAGE_INSTALLATION_RESULT_INVALID_PACKAGE: { AppLogException("== PACKAGE_INSTALLATION_RESULT_INVALID_PACKAGE == package id : %ls", packageId.GetPointer()); - UiApp::GetInstance()->GetFrame(APP_NAME)->GetCurrentForm()->SendUserEvent(INSTALL_FAIL_INVALID_PACKAGE, pArgs); + pForm->SendUserEvent(INSTALL_FAIL_INVALID_PACKAGE, pArgs); } break; case PACKAGE_INSTALLATION_RESULT_STORAGE_FULL: { AppLogException("== PACKAGE_INSTALLATION_RESULT_STORAGE_FULL == "); - UiApp::GetInstance()->GetFrame(APP_NAME)->GetCurrentForm()->SendUserEvent(INSTALL_FAIL_STORAGE_FULL, pArgs); + pForm->SendUserEvent(INSTALL_FAIL_STORAGE_FULL, pArgs); } break; default: @@ -72,7 +84,6 @@ InstallEventListener::OnPackageInstallationResponseReceived(const PackageId& pac } break; } -// delete pArgs; } void @@ -83,7 +94,9 @@ InstallEventListener::OnPackageInstallationInProgressResponseReceived(const Pack pArgs = new (std::nothrow) ArrayList(); pArgs->Add(*(new (std::nothrow) String(data))); - UiApp::GetInstance()->GetFrame(APP_NAME)->GetCurrentForm()->SendUserEvent(INSTALL_PROGRESS_VALUE, pArgs); + if (UiApp::GetInstance() != null && UiApp::GetInstance()->GetFrame(APP_NAME) != null && UiApp::GetInstance()->GetFrame(APP_NAME)->GetCurrentForm() != null ) + { + UiApp::GetInstance()->GetFrame(APP_NAME)->GetCurrentForm()->SendUserEvent(INSTALL_PROGRESS_VALUE, pArgs); + } -// delete pArgs; } diff --git a/src/IstInstallForm.cpp b/src/IstInstallForm.cpp index 0ff874d..fe4b9eb 100644 --- a/src/IstInstallForm.cpp +++ b/src/IstInstallForm.cpp @@ -24,7 +24,7 @@ #include "IstInstallForm.h" #include "IstInstallEventListener.h" #include "IstInstallerApp.h" -#include "IstTypes.h" +#include "AppResourceId.h" using namespace Tizen::Base; using namespace Tizen::App; @@ -37,8 +37,6 @@ using namespace Tizen::Ui::Scenes; static const int ID_FOOTER_OPEN = 101; static const int ID_BUTTON_CLOSE_POPUP = 103; -static const wchar_t* PROGRESS_IMAGE = L"00_progress_pending_02_bg.png"; -static const wchar_t* PROGRESS_EF_IMAGE = L"00_progress_pending_ef_02_bg.png"; static const wchar_t* POPUP_MSESSAGE_SUCCESS = L"Installation success"; static const wchar_t* POPUP_MSESSAGE_FAIL = L"Installation fail"; @@ -92,6 +90,7 @@ InstallForm::InstallApplication() pTargetPackageInfo = packManager->GetPackageInfoFromFileN(packagePath); String packageId = pTargetPackageInfo->GetId(); + result res; if (packagePath.IsEmpty()){ @@ -101,7 +100,7 @@ InstallForm::InstallApplication() return; } - res = packManager->InstallPackage(packageId, packagePath, __appInstallObj); + res = packManager->InstallPackage(packageId, packagePath, __pInstallListener); if (res != E_SUCCESS) { TryLog(res != E_INVALID_ARG, "E_INVALID_ARG"); @@ -159,9 +158,8 @@ InstallForm::OnInitializing(void) { result r = E_SUCCESS; - AppResource* pAppResource = Application::GetInstance()->GetAppResource(); __pAppManager = AppManager::GetInstance(); - __appInstallObj = new (std::nothrow) InstallEventListener(); + __pInstallListener = new (std::nothrow) InstallEventListener(); SetFormBackEventListener(this); @@ -173,14 +171,6 @@ InstallForm::OnInitializing(void) __pTimer = new (std::nothrow) Timer(); __pTimer->Construct(*this); - // progress test image - __pProgressEfImage = pAppResource->GetBitmapN(PROGRESS_EF_IMAGE); - __pProgressImage = pAppResource->GetBitmapN(PROGRESS_IMAGE); - __progressImageLabel = new (std::nothrow) Label(); - __progressImageLabel->Construct(Rectangle(70, 550, 580, 20), L""); - - AddControl(__progressImageLabel); - __pProgress = static_cast(GetControl(L"IDF_PROGRESS", true)); __pProgressLabel = static_cast(GetControl(L"IDC_PROGRESS_LABEL", true)); @@ -226,18 +216,20 @@ InstallForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection: { __isInstalling = false; String *packageId = (String*)pArgs->GetAt(0); + TryReturnVoid(!(packageId->IsEmpty()), "package id not delivered from listener"); PackageInfo* pLocalPackageInfo; PackageManager* pMgr = PackageManager::GetInstance(); + TryReturnVoid(pMgr != null, "[PackageManager::GetInstance() return null] package manager instance get error") + pLocalPackageInfo = pMgr->GetPackageInfoN(*packageId); + TryReturnVoid(pLocalPackageInfo != null, "[PackageManager::GetPackageInfoN() return null] get package info error") __packageOperationId = *packageId + L"." + pLocalPackageInfo->GetDisplayName(); AddFooterItem(); __pProgressLabel->SetText(POPUP_MSESSAGE_SUCCESS); -// delete pLocalPackageInfo; -// __appInstallObj->~InstallEventListener(); } else if (requestId == INSTALL_PROGRESS_VALUE) { @@ -252,13 +244,16 @@ InstallForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection: else { __isInstalling = false; - if (requestId == INSTALL_FAIL_INVALID_PACKAGE){ + if (requestId == INSTALL_FAIL_INVALID_PACKAGE) + { SetPopupValue(POPUP_MSESSAGE_FAIL, L"Invalid Package Install Error"); } - else if (requestId == INSTALL_FAIL_STORAGE_FULL){ + else if (requestId == INSTALL_FAIL_STORAGE_FULL) + { SetPopupValue(POPUP_MSESSAGE_FAIL, L"Storage Full Install Error"); } - else { + else + { AppLogException("error event request ID sent by EndpointThread"); SetPopupValue(POPUP_MSESSAGE_FAIL, L"Return Value is Error"); } diff --git a/src/IstInstallerApp.cpp b/src/IstInstallerApp.cpp index 29a1989..37aba4f 100644 --- a/src/IstInstallerApp.cpp +++ b/src/IstInstallerApp.cpp @@ -22,7 +22,7 @@ #include "IstInstallerApp.h" #include "IstMainFrame.h" -#include "IstTypes.h" +#include "AppResourceId.h" using namespace Tizen::App; using namespace Tizen::Base; @@ -155,7 +155,6 @@ InstallerApp::OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::St } AppLog("uri data : %ls", uriData.GetPointer()); - String filePath; // 1. parsing file uri data if (uriData.StartsWith(FILE_URI_SCHEME, 0)){ -- 2.7.4