From 30ecfc9d78c0126a6b531a7fdc69942f561f9748 Mon Sep 17 00:00:00 2001 From: "kyeongwoo.lee" Date: Wed, 19 Jun 2013 15:00:03 +0900 Subject: [PATCH] replace the data type from ArrayListT to HashMapT Change-Id: Ief75b7614e90eccd89f07d027404f3ac3fd7fa39 Signed-off-by: kyeongwoo.lee --- CMakeLists.txt | 1 + inc/FShell_AppWidgetContext.h | 5 +- inc/FShell_AppWidgetContextBase.h | 8 -- inc/FShell_AppWidgetContextHelper.h | 40 ++++++ inc/FShell_AppWidgetManagerService.h | 4 +- src/FShell_AppWidgetContext.cpp | 15 +- src/FShell_AppWidgetContextBase.cpp | 62 +-------- src/FShell_AppWidgetContextHelper.cpp | 96 +++++++++++++ src/FShell_AppWidgetManagerService.cpp | 183 +++++++++++++------------ 9 files changed, 246 insertions(+), 168 deletions(-) create mode 100644 inc/FShell_AppWidgetContextHelper.h create mode 100644 src/FShell_AppWidgetContextHelper.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d0bf6ef..9c52ed1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ SET (${this_target}_SOURCE_FILES src/FShell_AppWidgetManagerService.cpp src/FShell_AppWidgetManagerStub.cpp src/FShell_AppWidgetPopupContext.cpp + src/FShell_AppWidgetContextHelper.cpp ) ## SET EXTRA COMPILER FLAGS diff --git a/inc/FShell_AppWidgetContext.h b/inc/FShell_AppWidgetContext.h index 9dd32da..bfe5b73 100644 --- a/inc/FShell_AppWidgetContext.h +++ b/inc/FShell_AppWidgetContext.h @@ -95,10 +95,9 @@ private: struct PendingEvent { - PendingEvent(const Tizen::Base::String& instanceId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pHashMap) - : instanceId(instanceId), operation(operation), pArg(pHashMap) { } + PendingEvent(const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pHashMap) + : operation(operation), pArg(pHashMap) { } - Tizen::Base::String instanceId; Tizen::Base::String operation; Tizen::Base::Collection::HashMap* pArg; }; diff --git a/inc/FShell_AppWidgetContextBase.h b/inc/FShell_AppWidgetContextBase.h index 524fead..e9b40cd 100644 --- a/inc/FShell_AppWidgetContextBase.h +++ b/inc/FShell_AppWidgetContextBase.h @@ -100,14 +100,6 @@ private: }; // class _AppWidgetContextBase -class _AppWidgetRequestHelper -{ -public: - static result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); - static result SendRequestToApp(const int clientId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); - -}; // class _AppWidgetRequestHelper - extern const Tizen::Base::String ARG_KEY_INSTANCE_ID; extern const Tizen::Base::String ARG_KEY_PROVIDER_NAME; extern const Tizen::Base::String ARG_KEY_USER_INFO; diff --git a/inc/FShell_AppWidgetContextHelper.h b/inc/FShell_AppWidgetContextHelper.h new file mode 100644 index 0000000..ee91232 --- /dev/null +++ b/inc/FShell_AppWidgetContextHelper.h @@ -0,0 +1,40 @@ +// +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.1 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FShell_AppWidgetContextHelper.h + * @brief This is the header file for the _AppWidgetContextHelper class. + * + * This header file contains the declarations of the _AppWidgetContextHelper class. + */ + +#ifndef _FSHELL_APPWIDGET_CONTEXT_HELPER_H_ +#define _FSHELL_APPWIDGET_CONTEXT_HELPER_H_ + +namespace Tizen { namespace Shell { namespace App +{ + +class _AppWidgetRequestHelper +{ +public: + static result SendAppControlRequest(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); + static result SendIpcRequest(const int clientId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); + +}; // class _AppWidgetRequestHelper + +}}} // Tizen::Shell::App + +#endif // _FSHELL_APPWIDGET_CONTEXT_HELPER_H_ diff --git a/inc/FShell_AppWidgetManagerService.h b/inc/FShell_AppWidgetManagerService.h index 135dff4..dda360b 100644 --- a/inc/FShell_AppWidgetManagerService.h +++ b/inc/FShell_AppWidgetManagerService.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include "FShell_AppWidgetContext.h" #include "FShell_AppWidgetManagerStub.h" @@ -115,7 +115,7 @@ private: private: static AppWidgetManagerService* __pTheInstance; - Tizen::Base::Collection::ArrayListT<_AppWidgetContext*> __appWidgetContextList; + Tizen::Base::Collection::HashMapT __appWidgetContextList; Tizen::Base::Runtime::Timer __pingTimer; _TaskHandlerThread __handlerThread; diff --git a/src/FShell_AppWidgetContext.cpp b/src/FShell_AppWidgetContext.cpp index 7c49f62..ca9d584 100644 --- a/src/FShell_AppWidgetContext.cpp +++ b/src/FShell_AppWidgetContext.cpp @@ -34,6 +34,7 @@ #include "FShell_AppWidgetManagerService.h" #include "FShell_AppWidgetPopupContext.h" #include "FShell_AppWidgetContext.h" +#include "FShell_AppWidgetContextHelper.h" namespace Tizen { namespace Shell { namespace App { @@ -60,6 +61,7 @@ _AppWidgetContext::_AppWidgetContext(const String& info, const String& providerI ,__pPendingEventList(null) , __hasPendingRequest(false) { + // for updating period if (__updateMillis > 0) { __updateMillis = (__updateMillis > UPDATE_PERIOD_MSEC_MIN) ? __updateMillis : UPDATE_PERIOD_MSEC_MIN; @@ -76,8 +78,6 @@ _AppWidgetContext::_AppWidgetContext(const String& info, const String& providerI __pPendingEventList = new ArrayListT(); __pPendingEventList->Construct(); - - } _AppWidgetContext::~_AppWidgetContext(void) @@ -316,8 +316,9 @@ _AppWidgetContext::SendPendingEvent(void) if (pEvent != null) { SysLog(NID_SHELL, "SendPendingEvent by IPC [%d existed.]", __pPendingEventList->GetCount()); - _AppWidgetRequestHelper::SendRequestToApp(GetClientId(), pEvent->operation, pEvent->pArg); + _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), pEvent->operation, pEvent->pArg); __pPendingEventList->RemoveAt(0); + delete pEvent; } else { @@ -385,15 +386,15 @@ _AppWidgetContext::SendRequestToApp(const AppId& appId, const String& operation, if(!HasValidClientId()) { SysLog(NID_SHELL, "The application is running but IPC is not connected yet."); - __pPendingEventList->Add(new PendingEvent(*new String(GetInstanceId()), *new String(operation), pArgs)); + __pPendingEventList->Add(new PendingEvent(*new String(operation), pArgs)); } else { SysLog(NID_SHELL, "The application is running and IPC is connected."); - r = _AppWidgetRequestHelper::SendRequestToApp(GetClientId(), operation, pArgs); + r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), operation, pArgs); -// pArgs->RemoveAll(true); -// delete pArgs; + pArgs->RemoveAll(true); + delete pArgs; } } diff --git a/src/FShell_AppWidgetContextBase.cpp b/src/FShell_AppWidgetContextBase.cpp index 3934ec5..8a04cb0 100644 --- a/src/FShell_AppWidgetContextBase.cpp +++ b/src/FShell_AppWidgetContextBase.cpp @@ -26,12 +26,10 @@ #include #include #include -#include -#include -#include #include "FShell_AppWidgetManagerImpl.h" #include "FShell_AppWidgetContextBase.h" #include "FShell_AppWidgetManagerService.h" +#include "FShell_AppWidgetContextHelper.h" // provider/src/fb.c struct fb_info { @@ -212,7 +210,7 @@ _AppWidgetContextBase::ReleaseSharedMem(void) result _AppWidgetContextBase::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) { - result r = _AppWidgetRequestHelper::SendRequestToApp(appId, operation, pArgs); + result r = _AppWidgetRequestHelper::SendAppControlRequest(appId, operation, pArgs); SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to SendRequestToApp"); return r; @@ -296,62 +294,6 @@ _AppWidgetContextBase::SetHeight(int height) __height = height; } -result -_AppWidgetRequestHelper::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) -{ - const String* pInstanceId = dynamic_cast(pArgs->GetValue(ARG_KEY_INSTANCE_ID)); - SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_INSTANCE_ID.GetPointer() ); - - SysSecureLog(NID_SHELL, "[ac] pInstanceId(%ls), operation(%ls), appId(%ls), arg count(%d)", pInstanceId->GetPointer(), operation.GetPointer(), appId.GetPointer(), pArgs->GetCount()); - - _AppMessageImpl msg; - msg.AddData(OSP_K_APPCONTROL_INTERNAL_OPERATION, L"appwidget"); - Tizen::App::_AppArg::AddStrMap(msg.GetBundle(), pArgs); - - std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId) ); - std::unique_ptr pOperation(_StringConverter::CopyToCharArrayN(operation) ); - - const int TRY_COUNT = 3; - const int TRY_SLEEP_TIME = 65; - - int retry = 0; - - result r = E_FAILURE; - while (true) - { - r = Tizen::App::_AppControlManager::GetInstance()->LaunchPkg(msg, pAppId.get(), pOperation.get(), null, null, null, null); - if( r == E_SUCCESS) - { - SysLog(NID_SHELL, "[%s] Successed to invoke LaunchPkg()", GetErrorMessage(r)); - break; - } - - if( retry ++ >= TRY_COUNT) - { - break; - } - - SysLog(NID_SHELL, "[%s] Failed to invoke LaunchPkg(%s), %dth retry.", GetErrorMessage(r), pOperation.get(), retry); - Tizen::Base::Runtime::Thread::Sleep(TRY_SLEEP_TIME); - } - - return r; -} - -result -_AppWidgetRequestHelper::SendRequestToApp(const int clientId, const String& operation, HashMap* pArgs) -{ - const String* pInstanceId = dynamic_cast(pArgs->GetValue(ARG_KEY_INSTANCE_ID)); - SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_INSTANCE_ID.GetPointer() ); - - SysSecureLog(NID_SHELL, "[ipc] pInstanceId(%ls), operation(%ls), clientId(%d)", pInstanceId->GetPointer(), operation.GetPointer(), clientId); - - bool sendResult = AppWidgetManagerService::GetInstance()->SendAppWidgetEvent(clientId, *pInstanceId, operation, pArgs); - SysTryReturnResult(NID_SHELL, sendResult, E_FAILURE, "Propagated."); - - return E_SUCCESS; -} - }}} // Tizen::Shell::App //////////////////////////////////////////// diff --git a/src/FShell_AppWidgetContextHelper.cpp b/src/FShell_AppWidgetContextHelper.cpp new file mode 100644 index 0000000..0300d53 --- /dev/null +++ b/src/FShell_AppWidgetContextHelper.cpp @@ -0,0 +1,96 @@ +// +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.1 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FShell_AppWidgetContextHelper.cpp + * @brief This is the implementation for the _AppWidgetContextHelper class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "FShell_AppWidgetContextHelper.h" +#include "FShell_AppWidgetManagerService.h" + +namespace Tizen { namespace Shell { namespace App +{ + +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +result +_AppWidgetRequestHelper::SendAppControlRequest(const AppId& appId, const String& operation, HashMap* pArgs) +{ + const String* pInstanceId = dynamic_cast(pArgs->GetValue(ARG_KEY_INSTANCE_ID)); + SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_INSTANCE_ID.GetPointer() ); + + SysSecureLog(NID_SHELL, "[ac] pInstanceId(%ls), operation(%ls), appId(%ls), arg count(%d)", pInstanceId->GetPointer(), operation.GetPointer(), appId.GetPointer(), pArgs->GetCount()); + + _AppMessageImpl msg; + msg.AddData(OSP_K_APPCONTROL_INTERNAL_OPERATION, L"appwidget"); + Tizen::App::_AppArg::AddStrMap(msg.GetBundle(), pArgs); + + std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId) ); + std::unique_ptr pOperation(_StringConverter::CopyToCharArrayN(operation) ); + + const int TRY_COUNT = 3; + const int TRY_SLEEP_TIME = 65; + + int retry = 0; + + result r = E_FAILURE; + while (true) + { + r = Tizen::App::_AppControlManager::GetInstance()->LaunchPkg(msg, pAppId.get(), pOperation.get(), null, null, null, null); + if( r == E_SUCCESS) + { + SysLog(NID_SHELL, "[%s] Successed to invoke LaunchPkg()", GetErrorMessage(r)); + break; + } + + if( retry ++ >= TRY_COUNT) + { + break; + } + + SysLog(NID_SHELL, "[%s] Failed to invoke LaunchPkg(%s), %dth retry.", GetErrorMessage(r), pOperation.get(), retry); + Tizen::Base::Runtime::Thread::Sleep(TRY_SLEEP_TIME); + } + + return r; +} + +result +_AppWidgetRequestHelper::SendIpcRequest(const int clientId, const String& operation, HashMap* pArgs) +{ + const String* pInstanceId = dynamic_cast(pArgs->GetValue(ARG_KEY_INSTANCE_ID)); + SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_INSTANCE_ID.GetPointer() ); + + SysSecureLog(NID_SHELL, "[ipc] pInstanceId(%ls), operation(%ls), clientId(%d)", pInstanceId->GetPointer(), operation.GetPointer(), clientId); + + bool sendResult = AppWidgetManagerService::GetInstance()->SendAppWidgetEvent(clientId, *pInstanceId, operation, pArgs); + SysTryReturnResult(NID_SHELL, sendResult, E_FAILURE, "Propagated."); + + return E_SUCCESS; +} + +}}} // Tizen::Shell::App diff --git a/src/FShell_AppWidgetManagerService.cpp b/src/FShell_AppWidgetManagerService.cpp index 47d551d..6cc2d4a 100644 --- a/src/FShell_AppWidgetManagerService.cpp +++ b/src/FShell_AppWidgetManagerService.cpp @@ -25,16 +25,20 @@ #include #include #include +#include #include #include #include +#include #include "FShell_AppWidgetContext.h" #include "FShell_AppWidgetPopupContext.h" #include "FShell_AppWidgetManagerStub.h" #include "FShell_AppWidgetManagerService.h" +#include "FShell_TemplateUtil.h" namespace Tizen { namespace Shell { namespace App { +using namespace std; using namespace Tizen::App; using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -148,17 +152,10 @@ AppWidgetManagerService::OnTimerExpired(Timer& timer) _AppWidgetContext* AppWidgetManagerService::Find(const String& appId, const String& instanceId) const { - for (int i = 0; i < __appWidgetContextList.GetCount(); i++) - { - _AppWidgetContext* pAppWidgetContext = null; - __appWidgetContextList.GetAt(i, pAppWidgetContext); + _AppWidgetContext* pAppWidgetContext = null; + __appWidgetContextList.GetValue(instanceId, pAppWidgetContext); - if (pAppWidgetContext->GetInstanceId() == instanceId) - { - return pAppWidgetContext; - } - } - return null; + return pAppWidgetContext; } int @@ -166,43 +163,49 @@ AppWidgetManagerService::Find(const String& appId) const { int clientId = -1; - for (int i = 0; i < __appWidgetContextList.GetCount(); i++) + unique_ptr< IMapEnumeratorT > pAppWidgetContextEnum(__appWidgetContextList.GetMapEnumeratorN()); + SysTryReturn(NID_SHELL, pAppWidgetContextEnum, clientId, E_SYSTEM, "[E_SYSTEM]"); + + while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pAppWidgetContext = null; - __appWidgetContextList.GetAt(i, pAppWidgetContext); + _AppWidgetContext* pValue = null; + pAppWidgetContextEnum->GetValue(pValue); - if (pAppWidgetContext->GetProviderId() == appId) + if (pValue->GetProviderId() == appId) { - clientId = pAppWidgetContext->GetClientId(); + clientId = pValue->GetClientId(); break; } } SysLog(NID_SHELL, "clientId is %d", clientId); - return clientId; } result AppWidgetManagerService::SetIpcClientIds(const Tizen::App::AppId& appId, int clientId) { - for (int i = 0; i < __appWidgetContextList.GetCount(); i++) + unique_ptr< IMapEnumeratorT > pAppWidgetContextEnum(__appWidgetContextList.GetMapEnumeratorN()); + SysTryReturnResult(NID_SHELL, pAppWidgetContextEnum, E_SYSTEM, ""); + + while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pAppWidgetContext = null; - __appWidgetContextList.GetAt(i, pAppWidgetContext); - SysSecureLog(NID_SHELL, "%ls, %ls, %ls", pAppWidgetContext->GetInstanceId().GetPointer(), pAppWidgetContext->GetProviderId().GetPointer(), appId.GetPointer()); + _AppWidgetContext* pValue = null; + pAppWidgetContextEnum->GetValue(pValue); + SysSecureLog(NID_SHELL, "%ls, %ls, %ls", pValue->GetInstanceId().GetPointer(), pValue->GetProviderId().GetPointer(), appId.GetPointer()); - if (pAppWidgetContext->GetAppId() == appId) + if (pValue->GetAppId() == appId) { - pAppWidgetContext->SetIpcClientId(clientId); + pValue->SetIpcClientId(clientId); - if( clientId == -1) + if (clientId == -1) { SysLog(NID_SHELL, "client is unregistered."); - pAppWidgetContext->Suspend(); - if(pAppWidgetContext->GetAppWidgetPopup()) + pValue->Suspend(); + + if (pValue->GetAppWidgetPopup()) { - pAppWidgetContext->OnPopupDestoyed(); + pValue->OnPopupDestoyed(); } } else @@ -211,6 +214,7 @@ AppWidgetManagerService::SetIpcClientIds(const Tizen::App::AppId& appId, int cli } } } + return E_SUCCESS; } @@ -255,7 +259,7 @@ AppWidgetManagerService::AddAppWidget(_AppWidgetContext* pAppWidgetContext) { SysSecureLog(NID_SHELL, "%ls, %ls, count(%d)", pAppWidgetContext->GetProviderId().GetPointer(), pAppWidgetContext->GetInstanceId().GetPointer(), __appWidgetContextList.GetCount()); - return __appWidgetContextList.Add(pAppWidgetContext); + return __appWidgetContextList.Add(pAppWidgetContext->GetInstanceId(), pAppWidgetContext); } result @@ -266,7 +270,7 @@ AppWidgetManagerService::RemoveAppWidget(const char* pPackageName, const char* p _AppWidgetContext* pAppWidgetContext = Find(pPackageName, pId); SysTryReturn(NID_SHELL, pAppWidgetContext, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND]"); - result r = __appWidgetContextList.Remove(pAppWidgetContext); + result r = __appWidgetContextList.Remove(pAppWidgetContext->GetInstanceId()); delete pAppWidgetContext; @@ -338,17 +342,21 @@ AppWidgetManagerService::OnAppWidgetUpdate(struct event_arg *arg, void* data) int AppWidgetManagerService::UpdateAllAppWidgetsByAppId(const String& providerId) { - for( int i = 0; i < __appWidgetContextList.GetCount(); i++ ) + unique_ptr< IMapEnumeratorT > pAppWidgetContextEnum(__appWidgetContextList.GetMapEnumeratorN()); + SysTryReturn(NID_SHELL, pAppWidgetContextEnum, 0, E_SYSTEM, "[E_SYSTEM]"); + + while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pAppWidgetContext = null; - __appWidgetContextList.GetAt(i, pAppWidgetContext); + _AppWidgetContext* pValue = null; + pAppWidgetContextEnum->GetValue(pValue); - if ( pAppWidgetContext->GetProviderId() == providerId ) + if (pValue->GetProviderId() == providerId) { - pAppWidgetContext->OnUpdate(L""); + pValue->OnUpdate(L""); } } - return E_SUCCESS; + + return 0; } int @@ -416,20 +424,18 @@ AppWidgetManagerService::OnAppWidgetPause(struct event_arg *arg, void* data) int AppWidgetManagerService::OnAppWidgetPauseAll(struct event_arg *arg, void* data) { - SysLog(NID_SHELL, "I"); - - AppWidgetManagerService* pAppManagerService = AppWidgetManagerService::GetInstance(); + unique_ptr< IMapEnumeratorT > pAppWidgetContextEnum((AppWidgetManagerService::GetInstance()->__appWidgetContextList).GetMapEnumeratorN()); + SysTryReturn(NID_SHELL, pAppWidgetContextEnum, -1, E_SYSTEM, "[E_SYSTEM]"); - for (int i = 0; i < (pAppManagerService->__appWidgetContextList).GetCount(); i++) + while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pAppWidgetContext = null; - (pAppManagerService->__appWidgetContextList).GetAt(i, pAppWidgetContext); + _AppWidgetContext* pValue = null; + pAppWidgetContextEnum->GetValue(pValue); - pAppWidgetContext->OnBackground(); + pValue->OnBackground(); } - SysLog(NID_SHELL, "O"); - return 0; + return 0; } int @@ -448,20 +454,18 @@ AppWidgetManagerService::OnAppWidgetResume(struct event_arg *pArg, void* pData) int AppWidgetManagerService::OnAppWidgetResumeAll(struct event_arg *pArg, void* pData) { - SysLog(NID_SHELL, "I"); + unique_ptr< IMapEnumeratorT > pAppWidgetContextEnum((AppWidgetManagerService::GetInstance()->__appWidgetContextList).GetMapEnumeratorN()); + SysTryReturn(NID_SHELL, pAppWidgetContextEnum, -1, E_SYSTEM, "[E_SYSTEM]"); - AppWidgetManagerService* pAppManagerService = AppWidgetManagerService::GetInstance(); - - for (int i = 0; i < (pAppManagerService->__appWidgetContextList).GetCount(); i++) + while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pAppWidgetContext = null; - (pAppManagerService->__appWidgetContextList).GetAt(i, pAppWidgetContext); + _AppWidgetContext* pValue = null; + pAppWidgetContextEnum->GetValue(pValue); - pAppWidgetContext->OnForeground(); + pValue->OnForeground(); } - SysLog(NID_SHELL, "O"); - return 0; + return 0; } int @@ -536,7 +540,11 @@ AppWidgetManagerService::InitializeCoreDaemonEventReceiver(const char *pIdForCor { SysTryReturnResult(NID_SHELL, pIdForCoreDaemon != null, E_INVALID_ARG, "pIdForCoreDaemon should not be null!"); - __appWidgetContextList.Construct(); + static __HashMapDefaultProviderT strHashCodeProvider; + static ComparerT strComparer; + + result r = __appWidgetContextList.Construct(0, 0, strHashCodeProvider, strComparer); + SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute Construct."); /*! * \note @@ -589,29 +597,32 @@ AppWidgetManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tiz bool found = false; bool updateAllSuspended = appId.IsEmpty(); - for( int i = 0; i < __appWidgetContextList.GetCount(); i++ ) + unique_ptr< IMapEnumeratorT > pAppWidgetContextEnum((AppWidgetManagerService::GetInstance()->__appWidgetContextList).GetMapEnumeratorN()); + SysTryReturnResult(NID_SHELL, pAppWidgetContextEnum, E_SYSTEM, ""); + + while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pAppWidgetContext = null; - __appWidgetContextList.GetAt(i, pAppWidgetContext); - SysAssertf(pAppWidgetContext, "pAppWidgetContext is null!"); + _AppWidgetContext* pValue = null; + pAppWidgetContextEnum->GetValue(pValue); if ( (updateAllSuspended == true && AppManager::GetInstance()->IsRunning(appId) == false ) - || ( pAppWidgetContext->GetAppId() == appId && pAppWidgetContext->GetProviderName() == providerName ) ) + || ( pValue->GetAppId() == appId && pValue->GetProviderName() == providerName ) ) { ArrayList* pArray = new (std::nothrow) ArrayList(); SysTryReturnResult(NID_SHELL, pArray, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); pArray->Construct(); - pArray->Add(pAppWidgetContext); + pArray->Add(pValue); pArray->Add(new String(argument)); result r = __handlerThread.SendUserEvent(LOCAL_EVENT_REQUEST_UPDATE, pArray); SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Propagated.", GetErrorMessage(r)); - SysLog(NID_SHELL, "UserEvent(%d) is sent for '%ls.%ls'.", LOCAL_EVENT_REQUEST_UPDATE, pAppWidgetContext->GetAppId().GetPointer(), pAppWidgetContext->GetProviderName().GetPointer() ); + SysLog(NID_SHELL, "UserEvent(%d) is sent for '%ls.%ls'.", LOCAL_EVENT_REQUEST_UPDATE, pValue->GetAppId().GetPointer(), pValue->GetProviderName().GetPointer() ); found = true; } } + SysLog(NID_SHELL, "Exit."); return (found) ? E_SUCCESS : E_OBJ_NOT_FOUND; } @@ -637,7 +648,6 @@ AppWidgetManagerService::RequestUpdate(_AppWidgetContext* pAppWidgetContext, con SysLog(NID_SHELL, "pAppWidgetContext is null."); } - SysLog(NID_SHELL, "O"); return E_SUCCESS; } @@ -646,30 +656,20 @@ AppWidgetManagerService::RequestUpdateInstance(const Tizen::Base::String& instan { SysSecureLog(NID_SHELL, "%ls, %ls", instanceId.GetPointer(), argument.GetPointer() ); - for (int i = 0; i < __appWidgetContextList.GetCount(); i++ ) - { - _AppWidgetContext* pAppWidgetContext = null; - __appWidgetContextList.GetAt(i, pAppWidgetContext); + _AppWidgetContext* pAppWidgetContext = Find(L"", instanceId); + SysTryReturnResult(NID_SHELL, pAppWidgetContext, E_OBJ_NOT_FOUND, "Failed to find the object."); - if (pAppWidgetContext->GetInstanceId() == instanceId) - { - SysLog(NID_SHELL, "OK"); + ArrayList* pArray = new (std::nothrow) ArrayList(); + SysTryReturnResult(NID_SHELL, pArray, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); - ArrayList* pArray = new (std::nothrow) ArrayList(); - SysTryReturnResult(NID_SHELL, pArray, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); + pArray->Construct(); + pArray->Add(pAppWidgetContext); + pArray->Add(new String(argument)); - pArray->Construct(); - pArray->Add(pAppWidgetContext); - pArray->Add(new String(argument)); + result r = __handlerThread.SendUserEvent(LOCAL_EVENT_REQUEST_UPDATE, pArray); + SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Propagated.", GetErrorMessage(r)); - result r = __handlerThread.SendUserEvent(LOCAL_EVENT_REQUEST_UPDATE, pArray); - SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Propagated.", GetErrorMessage(r)); - - return E_SUCCESS; - } - } - SysLog(NID_SHELL, "Exit."); - return E_OBJ_NOT_FOUND; + return E_SUCCESS; } result @@ -747,11 +747,15 @@ AppWidgetManagerService::SendResult(const Tizen::App::AppId& appId, const Tizen: if (instanceId == INVALID_INSTANCE) { - for (int i = 0; i < __appWidgetContextList.GetCount(); i++) + unique_ptr< IMapEnumeratorT > pAppWidgetContextEnum((AppWidgetManagerService::GetInstance()->__appWidgetContextList).GetMapEnumeratorN()); + SysTryReturnResult(NID_SHELL, pAppWidgetContextEnum, E_SYSTEM, ""); + + while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - __appWidgetContextList.GetAt(i, pAppWidgetContext); + _AppWidgetContext* pValue = null; + pAppWidgetContextEnum->GetValue(pValue); - if (!pAppWidgetContext->IsRunning()) + if (!pValue->IsRunning()) { break; } @@ -809,12 +813,15 @@ AppWidgetManagerService::SendAccessStatus(const Tizen::App::AppId& appId, const result AppWidgetManagerService::RequestPendingEvent(void) { - for (int i = 0; i < __appWidgetContextList.GetCount(); i++ ) + unique_ptr< IMapEnumeratorT > pAppWidgetContextEnum((AppWidgetManagerService::GetInstance()->__appWidgetContextList).GetMapEnumeratorN()); + SysTryReturnResult(NID_SHELL, pAppWidgetContextEnum, E_SYSTEM, ""); + + while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pAppWidgetContext = null; - __appWidgetContextList.GetAt(i, pAppWidgetContext); + _AppWidgetContext* pValue = null; + pAppWidgetContextEnum->GetValue(pValue); - pAppWidgetContext->SendPendingEvent(); + pValue->SendPendingEvent(); } return E_SUCCESS; -- 2.34.1