From 78801828286cc95f2fbf3c59796df0698374ee6d Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Wed, 15 May 2013 11:23:09 +0900 Subject: [PATCH] fix proxy not to set instance when it's failed to construct, check exception for GetAppWidgetProviderInfo(), AddShortcut() Change-Id: Ic20081fd8d33cdfbfb4165f66260abd00a63f193 Signed-off-by: jungmin76.park --- src/FShell_AppWidgetManagerImpl.cpp | 7 ++++++- src/FShell_AppWidgetManagerProxy.cpp | 27 ++++++++++++++------------- src/FShell_AppWidgetProviderInfoImpl.cpp | 21 +++++++++++++++++++-- src/core/FShell_LockManagerProxy.cpp | 9 +++++---- src/core/FShell_ShortcutManagerImpl.cpp | 7 +++++-- src/inc/FShell_AppWidgetProviderInfoImpl.h | 3 +++ 6 files changed, 52 insertions(+), 22 deletions(-) diff --git a/src/FShell_AppWidgetManagerImpl.cpp b/src/FShell_AppWidgetManagerImpl.cpp index e0afb8d..7cab8de 100644 --- a/src/FShell_AppWidgetManagerImpl.cpp +++ b/src/FShell_AppWidgetManagerImpl.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -145,9 +146,13 @@ _AppWidgetManagerImpl::GetAppWidgetProviderInfoN(const Tizen::App::AppId& appId, AppWidgetProviderInfo* _AppWidgetManagerImpl::GetDefaultAppWidgetProviderInfoN(const Tizen::App::PackageId& packageId) { + SysTryReturn(NID_SHELL, Tizen::App::Package::_PackageManagerImpl::GetInstance()->IsPackageInstalled(packageId) == true, + null, E_APP_NOT_INSTALLED, + "[E_APP_NOT_INSTALLED] The application package(%ls) is not installed.", packageId.GetPointer() ); + std::unique_ptr pPackageId(_StringConverter::CopyToCharArrayN(packageId) ); std::unique_ptr pDefaultProviderId(livebox_service_pkgname(pPackageId.get()) ); - SysTryReturn(NID_SHELL, pDefaultProviderId.get(), null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND]"); + SysTryReturn(NID_SHELL, pDefaultProviderId.get(), null, E_SUCCESS, "Specified package(%ls) has no default provider.", packageId.GetPointer() ); String providerId(pDefaultProviderId.get()); String appId; diff --git a/src/FShell_AppWidgetManagerProxy.cpp b/src/FShell_AppWidgetManagerProxy.cpp index 61e90bc..69da5c4 100644 --- a/src/FShell_AppWidgetManagerProxy.cpp +++ b/src/FShell_AppWidgetManagerProxy.cpp @@ -80,19 +80,20 @@ _AppWidgetManagerProxy::Construct(void) { SysLog(NID_SHELL, "Enter."); - __pIpcClient = new (std::nothrow) _IpcClient(); - SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_OUT_OF_MEMORY, "_IpcClient creation failed."); + std::unique_ptr<_IpcClient> pIpcClient(new (std::nothrow) _IpcClient() ); + SysTryReturnResult(NID_SHELL, pIpcClient, E_OUT_OF_MEMORY, "_IpcClient creation failed."); const int MAX_TRY_COUNT = 5; - const int TRY_SLEEP_TIME = 500; + const int TRY_SLEEP_TIME = 250; int count = 0; while (true) { - result r = __pIpcClient->Construct(IPC_SERVER_NAME, this); + result r = pIpcClient->Construct(IPC_SERVER_NAME, this); if (r == E_SUCCESS) { SysLog(NID_APP, "Succeeded in connecting service(%s)", IPC_SERVER_NAME); + __pIpcClient = pIpcClient.release(); return E_SUCCESS; } @@ -108,7 +109,7 @@ _AppWidgetManagerProxy::Construct(void) result _AppWidgetManagerProxy::RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument) { - SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_SYSTEM, "__pIpcClient instance must not be null."); SysLog(NID_SHELL, "Enter."); // String providerId; // if( providerName.IsEmpty() == true) @@ -131,7 +132,7 @@ _AppWidgetManagerProxy::RequestUpdate(const Tizen::App::AppId& appId, const Tize result _AppWidgetManagerProxy::RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument) { - SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_SYSTEM, "__pIpcClient instance must not be null."); SysLog(NID_SHELL, "Enter."); result ret = E_SUCCESS; @@ -145,7 +146,7 @@ _AppWidgetManagerProxy::RequestUpdateInstance(const Tizen::Base::String& instanc result _AppWidgetManagerProxy::RequestSharedMemoryId(const Tizen::Base::String& instanceId, int width, int height, int& shmId ) { - SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_SYSTEM, "__pIpcClient instance must not be null."); std::auto_ptr pMsg (new (std::nothrow) AppWidgetManager_RequestSharedMemoryId(instanceId, width, height, &shmId)); result r = __pIpcClient->SendRequest(*pMsg.get()); @@ -158,7 +159,7 @@ _AppWidgetManagerProxy::RequestSharedMemoryId(const Tizen::Base::String& instanc result _AppWidgetManagerProxy::RequestSharedMemoryIdForPD(const Tizen::Base::String& instanceId, int width, int height, int& shmId ) { - SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_SYSTEM, "__pIpcClient instance must not be null."); std::auto_ptr pMsg (new (std::nothrow) AppWidgetManager_RequestSharedMemoryIdForPD(instanceId, width, height, &shmId)); result r = __pIpcClient->SendRequest(*pMsg.get()); @@ -171,7 +172,7 @@ _AppWidgetManagerProxy::RequestSharedMemoryIdForPD(const Tizen::Base::String& in result _AppWidgetManagerProxy::RequestSyncSharedMemory(const Tizen::Base::String& instanceId, int width, int height) { - SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_SYSTEM, "__pIpcClient instance must not be null."); SysLog(NID_SHELL, ""); result ret = E_FAILURE; @@ -184,7 +185,7 @@ _AppWidgetManagerProxy::RequestSyncSharedMemory(const Tizen::Base::String& insta result _AppWidgetManagerProxy::RequestSyncSharedMemoryForPD(const Tizen::Base::String& instanceId) { - SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_SYSTEM, "__pIpcClient instance must not be null."); SysLog(NID_SHELL, ""); result ret = E_FAILURE; @@ -197,7 +198,7 @@ _AppWidgetManagerProxy::RequestSyncSharedMemoryForPD(const Tizen::Base::String& result _AppWidgetManagerProxy::RequestReleaseSharedMemory(const Tizen::Base::String& instanceId) { - SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_SYSTEM, "__pIpcClient instance must not be null."); SysLog(NID_SHELL, ""); result ret = E_FAILURE; @@ -210,7 +211,7 @@ _AppWidgetManagerProxy::RequestReleaseSharedMemory(const Tizen::Base::String& in result _AppWidgetManagerProxy::RequestReleaseSharedMemoryForPD(const Tizen::Base::String& instanceId) { - SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_SYSTEM, "__pIpcClient instance must not be null."); SysLog(NID_SHELL, ""); result ret = E_FAILURE; @@ -223,7 +224,7 @@ _AppWidgetManagerProxy::RequestReleaseSharedMemoryForPD(const Tizen::Base::Strin result _AppWidgetManagerProxy::SendResult(const Tizen::Base::String& instanceId, bool isSucceeded) { - SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_SYSTEM, "__pIpcClient instance must not be null."); SysLog(NID_SHELL, ""); std::auto_ptr pMsg (new (std::nothrow) AppWidgetManager_SendResult(instanceId, isSucceeded)); diff --git a/src/FShell_AppWidgetProviderInfoImpl.cpp b/src/FShell_AppWidgetProviderInfoImpl.cpp index fbb1b93..7ab2b15 100644 --- a/src/FShell_AppWidgetProviderInfoImpl.cpp +++ b/src/FShell_AppWidgetProviderInfoImpl.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -49,8 +50,10 @@ _AppWidgetProviderInfoImpl::_AppWidgetProviderInfoImpl(const Tizen::App::AppId& __providerId = _AppWidgetManagerImpl::MakeProviderName(appId, name); std::unique_ptr pProviderId(_StringConverter::CopyToCharArrayN(__providerId)); - __displayName = livebox_service_i18n_name(pProviderId.get(), null); - __configurationAppControlAppId = livebox_service_setup_appid(pProviderId.get()); + std::unique_ptr pDisplayName(livebox_service_i18n_name(pProviderId.get(), null)); + std::unique_ptr pSetUpAppId(livebox_service_setup_appid(pProviderId.get())); + __displayName = pDisplayName.get(); + __configurationAppControlAppId = pSetUpAppId.get(); SysSecureLog(NID_SHELL, "appId(%ls), name(%ls), providerId(%ls), displayName(%ls), configuration(%ls)", appId.GetPointer(), name.GetPointer(), __providerId.GetPointer(), __displayName.GetPointer(), __configurationAppControlAppId.GetPointer() ); } @@ -214,6 +217,8 @@ _AppWidgetProviderInfoImpl::GetAppWidgetProviderInfoN(const Tizen::App::AppId& a AppWidgetProviderInfo* _AppWidgetProviderInfoImpl::GetAppWidgetProviderInfoN(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, bool isDefault) { + SysTryReturn(NID_SHELL, IsExist(appId, providerName) == true, null, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer()); + AppWidgetProviderInfo* pInfo = new (std::nothrow) AppWidgetProviderInfo(appId, providerName); SysTryReturn(NID_SHELL, pInfo, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocate memory for AppWidgetProviderInfo." ); @@ -222,6 +227,18 @@ _AppWidgetProviderInfoImpl::GetAppWidgetProviderInfoN(const Tizen::App::AppId& a return pInfo; } +bool +_AppWidgetProviderInfoImpl::IsExist(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName) +{ + SysTryReturn(NID_SHELL, Tizen::App::_Aul::IsInstalled(appId) == true, false, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer()); + + std::unique_ptr pProviderId(_StringConverter::CopyToCharArrayN(_AppWidgetManagerImpl::MakeProviderName(appId, providerName))); + std::unique_ptr pPackageId(livebox_service_appid(pProviderId.get())); + SysTryReturn(NID_SHELL, pPackageId.get(), false, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer()); + + return true; +} + _AppWidgetProviderInfoImpl* _AppWidgetProviderInfoImpl::GetImpl(const AppWidgetProviderInfo& appwidgetProviderInfo) { diff --git a/src/core/FShell_LockManagerProxy.cpp b/src/core/FShell_LockManagerProxy.cpp index c4ea037..e7c4db2 100644 --- a/src/core/FShell_LockManagerProxy.cpp +++ b/src/core/FShell_LockManagerProxy.cpp @@ -94,8 +94,8 @@ _LockManagerProxy::Construct(void) { SysLog(NID_SHELL, "Enter."); - __pIpcClient = new (std::nothrow) _IpcClient(); - SysTryReturnResult(NID_SHELL, __pIpcClient != null, E_OUT_OF_MEMORY, "_IpcClient creation failed."); + std::unique_ptr<_IpcClient> pIpcClient( new (std::nothrow) _IpcClient() ); + SysTryReturnResult(NID_SHELL, pIpcClient, E_OUT_OF_MEMORY, "_IpcClient creation failed."); const int MAX_TRY_COUNT = 5; const int TRY_SLEEP_TIME = 250; @@ -103,10 +103,11 @@ _LockManagerProxy::Construct(void) int count = 0; while (true) { - result r = __pIpcClient->Construct(IPC_SERVER_NAME); + result r = pIpcClient->Construct(IPC_SERVER_NAME); if (r == E_SUCCESS) { SysLog(NID_APP, "Succeeded in connecting service(%s)", IPC_SERVER_NAME); + __pIpcClient = pIpcClient.release(); return E_SUCCESS; } @@ -123,7 +124,7 @@ _LockManagerProxy::Construct(void) result _LockManagerProxy::Unlock(void) { - SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysTryReturnResult(NID_APP, __pIpcClient != null, E_SYSTEM, "__pIpcClient instance must not be null."); result response = E_SUCCESS; diff --git a/src/core/FShell_ShortcutManagerImpl.cpp b/src/core/FShell_ShortcutManagerImpl.cpp index a0e695e..2ef24dc 100644 --- a/src/core/FShell_ShortcutManagerImpl.cpp +++ b/src/core/FShell_ShortcutManagerImpl.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "FShell_ShortcutManagerImpl.h" @@ -142,7 +143,8 @@ _ShortcutManagerImpl::ConstructListener() result _ShortcutManagerImpl::AddShortcut(const AppId& appId, const String& displayName, const String& iconFilePath, const String& uriData, bool allowDuplication) { - SysLog(NID_SHELL, "_ShortcutManagerImpl::AddShortcut enters."); + SysTryReturnResult(NID_SHELL, _Aul::IsInstalled(appId) == true, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer()); + std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId)); std::unique_ptr pIcon(_StringConverter::CopyToCharArrayN(iconFilePath)); std::unique_ptr pName(_StringConverter::CopyToCharArrayN(displayName)); @@ -153,7 +155,8 @@ _ShortcutManagerImpl::AddShortcut(const AppId& appId, const String& displayName, SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_COMM, E_SUCCESS, "It's failed to add_to_home_shortcut, but regarded as success."); SysTryReturnResult(NID_SHELL, ret != SHORTCUT_ERROR_MEMORY, E_OUT_OF_MEMORY, "It's failed to add_to_home_shortcut."); SysTryReturnResult(NID_SHELL, ret == SHORTCUT_SUCCESS, E_SYSTEM, "Failed to add_to_home_shortcut"); - SysLog(NID_SHELL, "_ShortcutManagerImpl::AddShortcut exits."); + + SysLog(NID_SHELL, "Successed."); return E_SUCCESS; } diff --git a/src/inc/FShell_AppWidgetProviderInfoImpl.h b/src/inc/FShell_AppWidgetProviderInfoImpl.h index dcdceb9..2f2c950 100644 --- a/src/inc/FShell_AppWidgetProviderInfoImpl.h +++ b/src/inc/FShell_AppWidgetProviderInfoImpl.h @@ -140,6 +140,9 @@ private: */ _AppWidgetProviderInfoImpl& operator =(const _AppWidgetProviderInfoImpl& rhs); + static bool IsExist(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName); + + private: Tizen::Base::String __appId; Tizen::Base::String __name; -- 2.7.4