From 3cb2fdb35a500a01ea06897e1fcb24ffcf1c8533 Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Thu, 11 Jul 2013 17:58:31 +0900 Subject: [PATCH] make code neat Change-Id: I278a394055690a7a68eee6e4612808f4b2c88720 Signed-off-by: jungmin76.park --- inc/FShell_AppWidgetContext.h | 50 +++--- inc/FShell_AppWidgetManagerService.h | 30 ++-- inc/FShell_AppWidgetManagerStub.h | 25 +-- inc/FShell_AppWidgetPopupContext.h | 16 +- inc/FShell_AppWidgetRemoteBuffer.h | 4 +- src/FShell_AppWidgetContext.cpp | 88 ++++----- src/FShell_AppWidgetManagerService.cpp | 318 +++++++++++++++------------------ src/FShell_AppWidgetManagerStub.cpp | 94 +++++----- src/FShell_AppWidgetPopupContext.cpp | 38 ++-- src/FShell_AppWidgetRemoteBuffer.cpp | 12 +- 10 files changed, 309 insertions(+), 366 deletions(-) diff --git a/inc/FShell_AppWidgetContext.h b/inc/FShell_AppWidgetContext.h index aa42d5c..412f2f5 100644 --- a/inc/FShell_AppWidgetContext.h +++ b/inc/FShell_AppWidgetContext.h @@ -97,7 +97,7 @@ class _AppWidgetContext , public Tizen::Base::Object { public: - _AppWidgetContext(_AppContext* pAppContext, const Tizen::Base::String& name, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int period, int priority); + _AppWidgetContext(_AppContext* pAppContext, const Tizen::Base::String& userInfo, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int period, int priority); virtual ~_AppWidgetContext(void); // handle dynamic box @@ -105,45 +105,41 @@ public: void OnUpdate(const Tizen::Base::String& argument); void OnResize(int width, int height); result OnRemoved(void); - result SendPendingEvent(void); - int GetPeriod(void) const; - long long GetLastUpdatedTime(void) const; - bool IsForeground(void) const; - void SetForeground(bool forground); - int GetSharedMemId(int w, int h) const; - void OnDisconnected(void); virtual void OnTouchEventReceived(buffer_event event, double timestamp, double x, double y); // dynamic box state - bool IsPaused(void) const; void OnForeground(void); void OnBackground(void); + // handle request from dynamic box + int AcquireRemoteBuffer(int w, int h) const; + result SyncRemoteBuffer(int width, int height); + result SendAccessStatus(int accessStatus) const; + // handle drop view void OnPopupCreated(double x, double y, int width, int height); void OnPopupDestoyed(void); _AppWidgetPopupContext* GetAppWidgetPopup(void) const; - result SendPopupRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); + result SendPopupRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs) const; + Tizen::Base::Collection::HashMap* CreateRequestArgsN(void) const; - // for common _AppContext* GetAppContext(void) const; - result SendAccessStatus(int accessStatus); - result RequestUpdateRemote(int width, int height); + void OnDisconnected(void); + result SendPendingEvent(void); + Tizen::Base::String GetAppId(void) const; Tizen::Base::String GetProviderName(void) const; - Tizen::Base::String GetUserInfo(void) const; - void SetUserInfo(const Tizen::Base::String& userInfo); Tizen::Base::String GetProviderId(void) const; - void SetProviderId(const Tizen::Base::String& providerId); Tizen::Base::String GetInstanceId(void) const; - void SetInstanceId(const Tizen::Base::String& instanceId); int GetWidth(void) const; - void SetWidth(int width); int GetHeight(void) const; - void SetHeight(int height); int GetPriority(void) const; - void SetPriority(int priority); + +// void SetUserInfo(const Tizen::Base::String& userInfo); +// void SetProviderId(const Tizen::Base::String& providerId); +// void SetInstanceId(const Tizen::Base::String& instanceId); +// void SetPriority(int priority); private: result SendAddRequest(int width, int height); @@ -154,10 +150,18 @@ private: result RequestUpdate(const Tizen::Base::String& argument); result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); - virtual Tizen::Base::Collection::HashMap* CreateRequestArgsN(void); - int GetClientId(void) const; virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + void SetForeground(bool forground); + void SetWidth(int width); + void SetHeight(int height); + int GetPeriod(void) const; + + int GetClientId(void) const; + bool IsForeground(void) const; + long long GetLastUpdatedTime(void) const; + +private: struct PendingTouchEvent { PendingTouchEvent(int eventType, double timeStamp, double x, double y) @@ -178,7 +182,6 @@ private: Tizen::Base::Collection::HashMap* pArg; }; -private: mutable bool __isTouchAvailable; bool __hasPendingRequest; bool __isForeground; @@ -200,6 +203,7 @@ private: _AppContext* __pAppContext; _AppWidgetPopupContext* __pAppWidgetPopup; _AppWidgetRemoteBuffer* __pAppWidgetRemoteBuffer; + Tizen::Base::Collection::ArrayListT* __pPendingTouchEventList; Tizen::Base::Collection::ArrayListT* __pPendingEventList; diff --git a/inc/FShell_AppWidgetManagerService.h b/inc/FShell_AppWidgetManagerService.h index 2ec25d8..a734776 100644 --- a/inc/FShell_AppWidgetManagerService.h +++ b/inc/FShell_AppWidgetManagerService.h @@ -46,8 +46,8 @@ class AppWidgetManagerService public: static AppWidgetManagerService* GetInstance(void); static AppWidgetManagerService* CreateInstance(const char* pServiceIdForCoreDaemon); - _AppWidgetContext* AddAppWidget(const Tizen::Base::String& name, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int period, int priority); - result RemoveAppWidget(const char* pPackageName, const char* pId, bool free); + _AppWidgetContext* AddAppWidget(const Tizen::Base::String& userInfo, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int period, int priority); + result RemoveAppWidget(const char* pProviderId, const char* pId); result RequestUpdate(_AppWidgetContext* pAppWidgetContext, const Tizen::Base::String& argument); int GetProviderCount(const Tizen::Base::String& appId) const; @@ -76,12 +76,12 @@ private: // stub implementations virtual result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument); virtual result RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument); - virtual result RequestSharedMemoryId(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int w, int h, int& shmId); - virtual result RequestSharedMemoryIdForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int w, int h, int& shmId); - virtual result RequestSyncSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height); - virtual result RequestSyncSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId); - virtual result RequestReleaseSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId); - virtual result RequestReleaseSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId); + virtual result AcquireRemoteBuffer(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int w, int h, int& bufferId); + virtual result AcquireRemoteBufferForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int w, int h, int& bufferId); + virtual result SyncRemoteBuffer(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height); + virtual result SyncRemoteBufferForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId); + virtual result ReleaseRemoteBuffer(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId); + virtual result ReleaseRemoteBufferForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId); virtual result RequestProviderCount(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int& providerCount); virtual result SendResult(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, bool isSucceeded); virtual result SendAccessStatus(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int accessStatus); @@ -90,20 +90,22 @@ private: AppWidgetManagerService(void); virtual ~AppWidgetManagerService(void); - // ipc + // _IIpcServerEventListener virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId); virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId); + + // ISettingEventListener virtual void OnSettingChanged(Tizen::Base::String & key); // helpers - int UpdateAllAppWidgetsByAppId(const Tizen::Base::String& appId); + _AppWidgetContext* Find(const Tizen::Base::String& instanceId) const; + int UpdateAppWidgetsByProviderId(const Tizen::Base::String& appId); + result RequestPendingEvent(void); void StartPingTimer(void); virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); - _AppWidgetContext* Find(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) const; - result RequestPendingEvent(void); - +private: class _TaskHandlerThread : public Tizen::Base::Runtime::Thread { @@ -113,13 +115,11 @@ private: }; -private: static AppWidgetManagerService* __pTheInstance; Tizen::Base::Collection::HashMapT __appWidgetContextList; Tizen::Base::Collection::HashMapT __appContextList; Tizen::Base::Runtime::Timer __pingTimer; _TaskHandlerThread __handlerThread; - }; // class AppWidgetManagerService }}} // Tizen::Shell::App diff --git a/inc/FShell_AppWidgetManagerStub.h b/inc/FShell_AppWidgetManagerStub.h index f03dcc1..7b3641c 100644 --- a/inc/FShell_AppWidgetManagerStub.h +++ b/inc/FShell_AppWidgetManagerStub.h @@ -57,12 +57,12 @@ protected: // handlers bool OnRequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument, result* pRes); bool OnRequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument, result* pRes); - bool OnRequestSharedMemoryId(const Tizen::Base::String& instanceId, int width, int height, int* pShmId); - bool OnRequestSharedMemoryIdForPD(const Tizen::Base::String& instanceId, int width, int height, int* pShmId); - bool OnRequestSyncSharedMemory(const Tizen::Base::String& instanceId, int width, int height, result* pRes); - bool OnRequestSyncSharedMemoryForPD(const Tizen::Base::String& instanceId, result* pRes); - bool OnRequestReleaseSharedMemory(const Tizen::Base::String& instanceId, result* pRes); - bool OnRequestReleaseSharedMemoryForPD(const Tizen::Base::String& instanceId, result* pRes); + bool OnAcquireRemoteBuffer(const Tizen::Base::String& instanceId, int width, int height, int* pShmId); + bool OnAcquireRemoteBufferForPD(const Tizen::Base::String& instanceId, int width, int height, int* pShmId); + bool OnSyncRemoteBuffer(const Tizen::Base::String& instanceId, int width, int height, result* pRes); + bool OnSyncRemoteBufferForPD(const Tizen::Base::String& instanceId, result* pRes); + bool OnReleaseRemoteBuffer(const Tizen::Base::String& instanceId, result* pRes); + bool OnReleaseRemoteBufferForPD(const Tizen::Base::String& instanceId, result* pRes); bool OnRequestProviderCount(const Tizen::Base::String& instanceId, int* pProviderCount); bool OnSendResult(const Tizen::Base::String& instanceId, bool isSucceeded); bool OnSendAccessStatus(const Tizen::Base::String& instanceId, int accessStatus); @@ -70,12 +70,13 @@ protected: // interface to service virtual result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument) = 0; virtual result RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument) = 0; - virtual result RequestSharedMemoryId(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId) = 0; - virtual result RequestSharedMemoryIdForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId) = 0; - virtual result RequestSyncSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height) = 0; - virtual result RequestSyncSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) = 0; - virtual result RequestReleaseSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) = 0; - virtual result RequestReleaseSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) = 0; + virtual result AcquireRemoteBuffer(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& bufferId) = 0; + virtual result AcquireRemoteBufferForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& bufferId) = 0; + virtual result SyncRemoteBuffer(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height) = 0; + virtual result SyncRemoteBufferForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) = 0; + virtual result ReleaseRemoteBuffer(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) = 0; + virtual result ReleaseRemoteBufferForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) = 0; + virtual result RequestProviderCount(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int& pProviderCount) = 0; virtual result SendResult(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, bool isSucceeded) = 0; virtual result SendAccessStatus(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int accessStatus) = 0; diff --git a/inc/FShell_AppWidgetPopupContext.h b/inc/FShell_AppWidgetPopupContext.h index 73bd333..563a0de 100644 --- a/inc/FShell_AppWidgetPopupContext.h +++ b/inc/FShell_AppWidgetPopupContext.h @@ -41,27 +41,27 @@ class _AppWidgetPopupContext , public _IAppWidgetRemoteBufferEventListener { public: - _AppWidgetPopupContext(_AppWidgetContext* pParent); + _AppWidgetPopupContext(const _AppWidgetContext* pParent); virtual ~_AppWidgetPopupContext(void); // event handler void OnPopupCreated(double x, double y, int width, int height); - void OnPopupDestoyed(void); + + // request from app + result SyncRemoteBuffer(void); + int AcquireRemoteBuffer(int w, int h) const; // request to app result SendPopupCreateRequest(double x, double y, int width, int height); result SendPopupDestroyRequest(void); - result RequestUpdateRemote(void); - int GetSharedMemId(int w, int h) const; - - virtual void OnTouchEventReceived(buffer_event event, double timestamp, double x, double y); private: - Tizen::Base::Collection::HashMap* CreateRequestArgsN(void); int GetClientId(void) const; + void OnPopupDestoyed(void); + virtual void OnTouchEventReceived(buffer_event event, double timestamp, double x, double y); private: - _AppWidgetContext* __pParent; + const _AppWidgetContext* __pParent; _AppWidgetRemoteBuffer* __pAppWidgetRemoteBuffer; }; // class _AppWidgetPopupContext diff --git a/inc/FShell_AppWidgetRemoteBuffer.h b/inc/FShell_AppWidgetRemoteBuffer.h index ab5cb80..d586caf 100644 --- a/inc/FShell_AppWidgetRemoteBuffer.h +++ b/inc/FShell_AppWidgetRemoteBuffer.h @@ -47,10 +47,10 @@ public: _AppWidgetRemoteBuffer(const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, target_type type, _IAppWidgetRemoteBufferEventListener* pListener); ~_AppWidgetRemoteBuffer(void); - int GetSharedMemId(int w, int h); + int Acquire(int w, int h); private: - result ReleaseSharedMem(void); + result Release(void); private: target_type __type; diff --git a/src/FShell_AppWidgetContext.cpp b/src/FShell_AppWidgetContext.cpp index 6fc0274..dcd7445 100644 --- a/src/FShell_AppWidgetContext.cpp +++ b/src/FShell_AppWidgetContext.cpp @@ -68,7 +68,7 @@ const wchar_t APPWIDGET_ON_TOUCH[] = L"http://tizen.org/appcontrol/appwidget/tou const int UPDATE_PERIOD_MSEC_MIN = 1800000; // 30min -_AppWidgetContext::_AppWidgetContext(_AppContext* pAppContext, const String& info, const String& providerId, const String& instanceId, int width, int height, int period, int priority) +_AppWidgetContext::_AppWidgetContext(_AppContext* pAppContext, const String& userInfo, const String& providerId, const String& instanceId, int width, int height, int period, int priority) :__isTouchAvailable(false) ,__hasPendingRequest(false) ,__isForeground(true) @@ -78,7 +78,7 @@ _AppWidgetContext::_AppWidgetContext(_AppContext* pAppContext, const String& inf ,__ipcClientId(-1) ,__updateMillis(period) ,__lastUpdatedTime(0) - ,__userInfo(info) + ,__userInfo(userInfo) ,__providerId(providerId) ,__instanceId(instanceId) ,__pAppContext(pAppContext) @@ -123,7 +123,6 @@ _AppWidgetContext::~_AppWidgetContext(void) if (__pAppWidgetPopup) { SysLog(NID_SHELL, "Destroying dangling AppWidgetPopup instance.."); - __pAppWidgetPopup->OnPopupDestoyed(); delete __pAppWidgetPopup; } @@ -184,13 +183,15 @@ _AppWidgetContext::OnRemoved(void) void _AppWidgetContext::OnUpdate(const String& argument) { + SysLog(NID_SHELL, "argument(%ls)", argument.GetPointer()); + ClearLastResult(); AppWidgetManagerService* pMgrService = AppWidgetManagerService::GetInstance(); SysTryReturnVoidResult(NID_SHELL, pMgrService, E_SYSTEM, "[E_SYSTEM] Failed to get an instance of AppWidgetManagerService."); // Queueing the pointer of paused context. - if (this->IsPaused()) + if (!this->IsForeground()) { // Saving the data if (!argument.IsEmpty()) @@ -240,9 +241,7 @@ _AppWidgetContext::RequestUpdate(const String& argument) void _AppWidgetContext::OnForeground(void) { - SysLog(NID_SHELL, "I"); - - if (!IsPaused()) + if (IsForeground()) { SysLog(NID_SHELL, "%ls is already resumed.", (this->GetAppId()).GetPointer()); return; @@ -272,8 +271,6 @@ _AppWidgetContext::OnForeground(void) } } } - - SysLog(NID_SHELL, "O"); } void @@ -281,7 +278,7 @@ _AppWidgetContext::OnBackground(void) { SysLog(NID_SHELL, "OnBackground"); - if (IsPaused()) + if (!IsForeground()) { SysLog(NID_SHELL, "%ls is already paused.", (this->GetAppId()).GetPointer()); return; @@ -289,12 +286,6 @@ _AppWidgetContext::OnBackground(void) SetForeground(false); } -bool -_AppWidgetContext::IsPaused(void) const -{ - return IsForeground() ? false : true; -} - void _AppWidgetContext::OnPopupCreated(double x, double y, int width, int height) { @@ -311,7 +302,7 @@ _AppWidgetContext::OnPopupDestoyed(void) if (__pAppWidgetPopup) { - __pAppWidgetPopup->OnPopupDestoyed(); +// __pAppWidgetPopup->OnPopupDestoyed(); delete __pAppWidgetPopup; __pAppWidgetPopup = null; } @@ -356,28 +347,24 @@ _AppWidgetContext::SendPendingEvent(void) { SysTryReturnResult(NID_SHELL, __pPendingEventList->GetCount() > 0 , E_DATA_NOT_FOUND, "There is no pending event."); - result r = E_SUCCESS; PendingEvent* pEvent = null; __pPendingEventList->GetAt(0, pEvent); - if (pEvent != null) - { - SysLog(NID_SHELL, "SendPendingEvent by IPC [%d existed.]", __pPendingEventList->GetCount()); - r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), pEvent->operation, pEvent->pArg); - - result r1 = __pPendingEventList->RemoveAt(0); - SysTryLog(NID_SHELL, !IsFailed(r1), "Failed to remove the context."); - delete pEvent; - - SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "SendIpcRequest failed."); - } - else + if (pEvent == null) { SysLog(NID_SHELL, "SendPendingEvent by IPC [0 existed.]"); - r = E_OBJ_NOT_FOUND; + GetAppContext()->__isWaitingResult = false; + return E_SYSTEM; } + SysLog(NID_SHELL, "SendPendingEvent by IPC [%d existed.]", __pPendingEventList->GetCount()); - return r; + __pPendingEventList->RemoveAt(0); + result r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), pEvent->operation, pEvent->pArg); + GetAppContext()->__isWaitingResult = false; + delete pEvent; + SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "SendIpcRequest failed."); + + return E_SUCCESS; } void @@ -457,19 +444,19 @@ _AppWidgetContext::SendRequestToApp(const AppId& appId, const String& operation, } result -_AppWidgetContext::SendPopupRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) +_AppWidgetContext::SendPopupRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) const { return _AppWidgetRequestHelper::SendAppControlRequest(appId, operation, pArgs);; } result -_AppWidgetContext::RequestUpdateRemote(int width, int height) +_AppWidgetContext::SyncRemoteBuffer(int width, int height) { - std::unique_ptr packageName(_StringConverter::CopyToCharArrayN(GetProviderId())); + std::unique_ptr providerId(_StringConverter::CopyToCharArrayN(GetProviderId())); std::unique_ptr id(_StringConverter::CopyToCharArrayN(GetInstanceId())); std::unique_ptr content_info(_StringConverter::CopyToCharArrayN(GetUserInfo())); - int ret = provider_send_updated(packageName.get(), id.get(), width, height, GetPriority(), content_info.get(), null); + int ret = provider_send_updated(providerId.get(), id.get(), width, height, GetPriority(), content_info.get(), null); SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated"); SendPendingTouchEvent(); @@ -478,12 +465,12 @@ _AppWidgetContext::RequestUpdateRemote(int width, int height) } result -_AppWidgetContext::SendAccessStatus(int accessStatus) +_AppWidgetContext::SendAccessStatus(int accessStatus) const { - std::unique_ptr packageName(_StringConverter::CopyToCharArrayN(GetProviderId())); + std::unique_ptr providerId(_StringConverter::CopyToCharArrayN(GetProviderId())); std::unique_ptr id(_StringConverter::CopyToCharArrayN(GetInstanceId())); - int ret = provider_send_access_status(packageName.get(), id.get(), accessStatus); + int ret = provider_send_access_status(providerId.get(), id.get(), accessStatus); SysLog(NID_SHELL, "[LB_ACCESS] provider_send_access_status is called. : ret = %d, status = %d", ret, accessStatus); SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_access_status"); @@ -491,7 +478,7 @@ _AppWidgetContext::SendAccessStatus(int accessStatus) } Tizen::Base::Collection::HashMap* -_AppWidgetContext::CreateRequestArgsN(void) +_AppWidgetContext::CreateRequestArgsN(void) const { HashMap* pArgs = new (nothrow) HashMap(SingleObjectDeleter); pArgs->Construct(); @@ -508,7 +495,6 @@ _AppWidgetContext::CreateRequestArgsN(void) int _AppWidgetContext::GetPeriod(void) const { - SysLog(NID_SHELL, "GetPeriod[%d]", __updateMillis); return __updateMillis; } @@ -554,11 +540,11 @@ _AppWidgetContext::GetProviderId(void) const return __providerId; } -void +/*void _AppWidgetContext::SetProviderId(const String& providerId) { __providerId = providerId; -} +}*/ String _AppWidgetContext::GetAppId(void) const @@ -572,11 +558,11 @@ _AppWidgetContext::GetPriority(void) const return __priority; } -void +/*void _AppWidgetContext::SetPriority(int priority) { __priority = priority; -} +}*/ String _AppWidgetContext::GetProviderName(void) const @@ -602,11 +588,11 @@ _AppWidgetContext::GetUserInfo(void) const return __userInfo; } -void +/*void _AppWidgetContext::SetUserInfo(const String& userInfo) { __userInfo = userInfo; -} +}*/ String _AppWidgetContext::GetInstanceId(void) const @@ -628,12 +614,16 @@ void _AppWidgetContext::OnDisconnected(void) { __isTouchAvailable = false; + if (GetAppWidgetPopup()) + { + OnPopupDestoyed(); + } } int -_AppWidgetContext::GetSharedMemId(int w, int h) const +_AppWidgetContext::AcquireRemoteBuffer(int w, int h) const { - int id = __pAppWidgetRemoteBuffer->GetSharedMemId(w, h); + int id = __pAppWidgetRemoteBuffer->Acquire(w, h); if (id != -1) { __isTouchAvailable = true; diff --git a/src/FShell_AppWidgetManagerService.cpp b/src/FShell_AppWidgetManagerService.cpp index ca98ad6..009484c 100644 --- a/src/FShell_AppWidgetManagerService.cpp +++ b/src/FShell_AppWidgetManagerService.cpp @@ -51,10 +51,12 @@ using namespace Tizen::Shell::App; namespace { static const RequestId LOCAL_EVENT_REQUEST_UPDATE = 0; +static const wchar_t INVALID_INSTANCE[] = L"file://invalid instance id"; +static const char APPNAME_OSP_APPWIDGET_SERVICE[] = "osp-appwidget-service"; +static const int TIMER_DURATION_PING = 120000; +//extern const int UPDATE_PERIOD_MSEC_MIN; } -extern const int UPDATE_PERIOD_MSEC_MIN; -const wchar_t INVALID_INSTANCE[] = L"file://invalid instance id"; AppWidgetManagerService* AppWidgetManagerService::__pTheInstance = null; @@ -65,8 +67,10 @@ AppWidgetManagerService::AppWidgetManagerService(void) AppWidgetManagerService::~AppWidgetManagerService(void) { + SysLog(NID_SHELL, "Enter."); __pingTimer.Cancel(); DeinitializeCoreDaemonEventReceiver(); + SysLog(NID_SHELL, "Exit."); } AppWidgetManagerService* @@ -74,20 +78,20 @@ AppWidgetManagerService::GetInstance(void) { if( __pTheInstance == null) { - __pTheInstance = CreateInstance("osp-appwidget-service"); + __pTheInstance = CreateInstance(APPNAME_OSP_APPWIDGET_SERVICE); } return __pTheInstance; } AppWidgetManagerService* -AppWidgetManagerService::CreateInstance(const char* pIdForCoreDaemon) +AppWidgetManagerService::CreateInstance(const char* pCoreDaemonId) { if( __pTheInstance == null) { __pTheInstance = new AppWidgetManagerService(); SysTryReturn(NID_SHELL, __pTheInstance != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); - result r = __pTheInstance->Construct(pIdForCoreDaemon); + result r = __pTheInstance->Construct(pCoreDaemonId); SysAssertf(!IsFailed(r), "Failed to construct AppWidgetManagerService"); SysLog(NID_SHELL, "AppWidgetManagerService is created."); } @@ -95,7 +99,7 @@ AppWidgetManagerService::CreateInstance(const char* pIdForCoreDaemon) } result -AppWidgetManagerService::Construct(const char* pIdForCoreDaemon) +AppWidgetManagerService::Construct(const char* pCoreDaemonId) { _AppWidgetManagerStub::StartIpcServer(); @@ -107,7 +111,16 @@ AppWidgetManagerService::Construct(const char* pIdForCoreDaemon) SettingInfo::AddSettingEventListener(*this); - return InitializeCoreDaemonEventReceiver(pIdForCoreDaemon); + static __HashMapDefaultProviderT strHashCodeProvider; + static ComparerT strComparer; + + r = __appWidgetContextList.Construct(0, 0, strHashCodeProvider, strComparer); + SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute Construct."); + + r = __appContextList.Construct(0, 0, strHashCodeProvider, strComparer); + SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute Construct."); + + return InitializeCoreDaemonEventReceiver(pCoreDaemonId); } int @@ -117,13 +130,13 @@ AppWidgetManagerService::AppWidgetConnected(struct event_arg *arg, void* data) ret = provider_send_hello(); if (ret == 0) { - SysLog(NID_SHELL, "success to be connected with master daemon"); + SysLog(NID_SHELL, "Success to be connected with master daemon"); AppWidgetManagerService::GetInstance()->StartPingTimer(); } else { - SysLog(NID_SHELL, "failed to provider_send_hello()"); + SysLog(NID_SHELL, "Failed to invoke provider_send_hello()"); } return ret; } @@ -131,7 +144,7 @@ AppWidgetManagerService::AppWidgetConnected(struct event_arg *arg, void* data) int AppWidgetManagerService::AppWidgetDisconnected(struct event_arg *arg, void* data) { - SysLog(NID_SHELL, "success to be disconnected with master daemon"); + SysLog(NID_SHELL, "Disconnected with master daemon"); return 0; } @@ -139,19 +152,17 @@ void AppWidgetManagerService::StartPingTimer(void) { __pingTimer.Construct(*this); - __pingTimer.StartAsRepeatable(120000); + __pingTimer.StartAsRepeatable(TIMER_DURATION_PING); } void AppWidgetManagerService::OnTimerExpired(Timer& timer) { - SysLog(NID_SHELL, "provider_send_ping"); provider_send_ping(); } -//TODO: remove unused param 'appId' _AppWidgetContext* -AppWidgetManagerService::Find(const String& appId, const String& instanceId) const +AppWidgetManagerService::Find(const String& instanceId) const { _AppWidgetContext* pAppWidgetContext = null; __appWidgetContextList.GetValue(instanceId, pAppWidgetContext); @@ -169,10 +180,10 @@ AppWidgetManagerService::GetProviderCount(const String& appId) const while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pValue = null; - pAppWidgetContextEnum->GetValue(pValue); + _AppWidgetContext* pContext = null; + pAppWidgetContextEnum->GetValue(pContext); - if (pValue->GetAppId() == appId) + if (pContext->GetAppId() == appId) { providerCount++; } @@ -187,7 +198,7 @@ void AppWidgetManagerService::OnIpcClientConnected(const _IpcServer& server, int clientId) { String appId = server.GetClientApplicationId(); - SysLog(NID_SHELL, "(%ls)\n", appId.GetPointer()); + SysLog(NID_SHELL, "appId(%ls)", appId.GetPointer()); _AppContext* pAppContext = null; __appContextList.GetValue(appId, pAppContext); @@ -202,7 +213,7 @@ void AppWidgetManagerService::OnIpcClientDisconnected(const _IpcServer& server, int clientId) { String appId = server.GetClientApplicationId(); - SysLog(NID_SHELL, "(%ls)\n", appId.GetPointer()); + SysLog(NID_SHELL, "appId(%ls)", appId.GetPointer()); _AppContext* pAppContext = null; __appContextList.GetValue(appId, pAppContext); @@ -215,41 +226,29 @@ AppWidgetManagerService::OnIpcClientDisconnected(const _IpcServer& server, int c unique_ptr< IMapEnumeratorT > pAppWidgetContextEnum(__appWidgetContextList.GetMapEnumeratorN()); SysTryReturnVoidResult(NID_SHELL, pAppWidgetContextEnum, E_SYSTEM, ""); - _AppWidgetContext* pValue = null; + _AppWidgetContext* pContext = null; while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - pAppWidgetContextEnum->GetValue(pValue); - SysSecureLog(NID_SHELL, "%ls, %ls, %ls", pValue->GetInstanceId().GetPointer(), pValue->GetProviderId().GetPointer(), appId.GetPointer()); + pAppWidgetContextEnum->GetValue(pContext); + SysSecureLog(NID_SHELL, "%ls, %ls, %ls", pContext->GetInstanceId().GetPointer(), pContext->GetProviderId().GetPointer(), appId.GetPointer()); - if (pValue->GetAppId() == appId) + if (pContext->GetAppId() == appId) { - if (clientId == -1) - { - SysLog(NID_SHELL, "client is unregistered."); - pValue->OnDisconnected(); - - if (pValue->GetAppWidgetPopup()) - { - pValue->OnPopupDestoyed(); - } - } - else - { - SysLog(NID_SHELL, "client is registered.(%d)", clientId); - } + SysLog(NID_SHELL, "client(%d) is unregistered.", clientId); + pContext->OnDisconnected(); } } } -wchar_t KEY_SETTING_FONT_SIZE[] = L"http://tizen.org/setting/font.size"; -wchar_t KEY_SETTING_FONT_TYPE[] = L"http://tizen.org/setting/font.type"; -wchar_t KEY_SETTING_LANGUAGE[] = L"http://tizen.org/setting/locale.language"; -wchar_t KEY_SETTING_COUNTRY[] = L"http://tizen.org/setting/locale.country"; - void AppWidgetManagerService::OnSettingChanged(Tizen::Base::String& key) { +// const static wchar_t KEY_SETTING_FONT_SIZE[] = L"http://tizen.org/setting/font.size"; + const static wchar_t KEY_SETTING_FONT_TYPE[] = L"http://tizen.org/setting/font.type"; + const static wchar_t KEY_SETTING_LANGUAGE[] = L"http://tizen.org/setting/locale.language"; + const static wchar_t KEY_SETTING_COUNTRY[] = L"http://tizen.org/setting/locale.country"; + if( key == KEY_SETTING_FONT_TYPE // || key == KEY_SETTING_FONT_SIZE || key == KEY_SETTING_LANGUAGE @@ -261,7 +260,7 @@ AppWidgetManagerService::OnSettingChanged(Tizen::Base::String& key) } _AppWidgetContext* -AppWidgetManagerService::AddAppWidget(const Tizen::Base::String& name, const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, int width, int height, int period, int priority) +AppWidgetManagerService::AddAppWidget(const Tizen::Base::String& userInfo, const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, int width, int height, int period, int priority) { AppId appId; String providerName; @@ -280,7 +279,7 @@ AppWidgetManagerService::AddAppWidget(const Tizen::Base::String& name, const Tiz __appContextList.GetValue(appId, pAppContext); } - _AppWidgetContext* pAppWidgetContext = new (std::nothrow)_AppWidgetContext(pAppContext, name, providerId, instanceId, width, height, period, priority); + _AppWidgetContext* pAppWidgetContext = new (std::nothrow)_AppWidgetContext(pAppContext, userInfo, providerId, instanceId, width, height, period, priority); SysTryReturn(NID_SHELL, pAppWidgetContext, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); __appWidgetContextList.Add(pAppWidgetContext->GetInstanceId(), pAppWidgetContext); @@ -291,18 +290,18 @@ AppWidgetManagerService::AddAppWidget(const Tizen::Base::String& name, const Tiz } result -AppWidgetManagerService::RemoveAppWidget(const char* pPackageName, const char* pId, bool free) +AppWidgetManagerService::RemoveAppWidget(const char* pProviderId, const char* pId) { - SysTryReturn(NID_SHELL, ( pPackageName != null && pId != null), null, E_INVALID_ARG, "[E_INVALID_ARG]"); + SysTryReturn(NID_SHELL, ( pProviderId != null && pId != null), null, E_INVALID_ARG, "[E_INVALID_ARG]"); - _AppWidgetContext* pAppWidgetContext = Find(pPackageName, pId); + _AppWidgetContext* pAppWidgetContext = Find(pId); SysTryReturn(NID_SHELL, pAppWidgetContext, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND]"); result r = __appWidgetContextList.Remove(pAppWidgetContext->GetInstanceId()); delete pAppWidgetContext; - SysLog(NID_SHELL, "AppWidget(%s, %s) is removed. remain count(%d)", pPackageName, pId, __appWidgetContextList.GetCount()); + SysLog(NID_SHELL, "AppWidget(%s, %s) is removed. remain count(%d)", pProviderId, pId, __appWidgetContextList.GetCount()); return r; } @@ -317,11 +316,11 @@ AppWidgetManagerService::OnAppWidgetCreate(struct event_arg *arg, int *width, in SysTryReturn(NID_SHELL, arg->id != null, EINVAL, E_INVALID_ARG, "[E_INVALID_ARG]"); SysTryReturn(NID_SHELL, arg->type == event_arg::EVENT_NEW, -EPERM, E_SUCCESS, "invalid argument from master"); - SysSecureLog(NID_SHELL, "packageName(%s) id(%s) content(%s) cluster(%s) category(%s)", arg->pkgname, arg->id, arg->info.lb_create.content, arg->info.lb_create.cluster, arg->info.lb_create.category); + SysSecureLog(NID_SHELL, "providerId(%s) id(%s) content(%s) cluster(%s) category(%s)", arg->pkgname, arg->id, arg->info.lb_create.content, arg->info.lb_create.cluster, arg->info.lb_create.category); AppWidgetManagerService* pAppWidgetService = AppWidgetManagerService::GetInstance(); - SysTryReturn (NID_SHELL, pAppWidgetService->Find(arg->pkgname, arg->id) == null, -EBUSY, E_SUCCESS,"already exist"); + SysTryReturn (NID_SHELL, pAppWidgetService->Find(arg->id) == null, -EBUSY, E_SUCCESS,"already exist"); - double default_priority = 1.0f; + const double default_priority = 1.0f; _AppWidgetContext* pAppWidgetContext = pAppWidgetService->AddAppWidget(arg->info.lb_create.content, arg->pkgname, arg->id, arg->info.lb_create.width, arg->info.lb_create.height, arg->info.lb_create.period * 1000, default_priority); *priority = pAppWidgetContext->GetPriority(); @@ -334,15 +333,15 @@ AppWidgetManagerService::OnAppWidgetCreate(struct event_arg *arg, int *width, in int AppWidgetManagerService::OnAppWidgetUpdate(struct event_arg *arg, void* data) { - if( arg->id == null || strlen(arg->id) < 1) + bool isInstanceIdSpecified = (arg->id == null || strlen(arg->id) < 1) ? false : true; + if (isInstanceIdSpecified == false) { - SysLog(NID_SHELL, "updating alls"); - AppWidgetManagerService::GetInstance()->UpdateAllAppWidgetsByAppId(arg->pkgname); + AppWidgetManagerService::GetInstance()->UpdateAppWidgetsByProviderId(arg->pkgname); } else { - _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id); - SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id); + _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->id); + SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for providerId(%s), instanceId(%s)", arg->pkgname, arg->id); pAppWidgetContext->OnUpdate(L""); } @@ -351,19 +350,21 @@ AppWidgetManagerService::OnAppWidgetUpdate(struct event_arg *arg, void* data) } int -AppWidgetManagerService::UpdateAllAppWidgetsByAppId(const String& providerId) +AppWidgetManagerService::UpdateAppWidgetsByProviderId(const String& providerId) { + SysLog(NID_SHELL, ""); + unique_ptr< IMapEnumeratorT > pAppWidgetContextEnum(__appWidgetContextList.GetMapEnumeratorN()); SysTryReturn(NID_SHELL, pAppWidgetContextEnum, 0, E_SYSTEM, "[E_SYSTEM]"); while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pValue = null; - pAppWidgetContextEnum->GetValue(pValue); + _AppWidgetContext* pContext = null; + pAppWidgetContextEnum->GetValue(pContext); - if (pValue->GetProviderId() == providerId) + if (pContext->GetProviderId() == providerId) { - pValue->OnUpdate(L""); + pContext->OnUpdate(L""); } } @@ -378,13 +379,13 @@ AppWidgetManagerService::OnAppWidgetDestroy(struct event_arg *arg, void* data) AppWidgetManagerService* pAppWidgetManagerService = AppWidgetManagerService::GetInstance(); - _AppWidgetContext* pAppWidgetContext = pAppWidgetManagerService->Find(arg->pkgname, arg->id); - SysSecureTryReturn(NID_SHELL, pAppWidgetContext, 0, E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id); + _AppWidgetContext* pAppWidgetContext = pAppWidgetManagerService->Find(arg->id); + SysSecureTryReturn(NID_SHELL, pAppWidgetContext, 0, E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for providerId(%s), instanceId(%s)", arg->pkgname, arg->id); result r = pAppWidgetContext->OnRemoved(); SysTryReturn(NID_SHELL, !IsFailed(r), 0, E_SYSTEM, "[E_SYSTEM] Failed to execute OnRemoved."); - r = pAppWidgetManagerService->RemoveAppWidget(arg->pkgname, arg->id, true); + r = pAppWidgetManagerService->RemoveAppWidget(arg->pkgname, arg->id); SysTryReturn(NID_SHELL, !IsFailed(r), 0, E_SYSTEM, "[E_SYSTEM] Failed to execute RemoveAppWidget."); SysLog(NID_SHELL, "Exit"); @@ -395,10 +396,10 @@ int AppWidgetManagerService::OnAppWidgetPopupCreate(struct event_arg *arg, void* data) { SysTryReturn (NID_SHELL, arg->type == event_arg::EVENT_PD_CREATE, -EPERM, E_SUCCESS, "invalid argument from master"); - SysSecureLog(NID_SHELL, "packageName(%s), id(%s), x(%d), y(%d), width(%f), height(%f), priority(%d)", arg->pkgname, arg->id, arg->info.pd_create.x, arg->info.pd_create.y, arg->info.pd_create.w, arg->info.pd_create.h); + SysSecureLog(NID_SHELL, "providerId(%s), id(%s), x(%d), y(%d), width(%f), height(%f), priority(%d)", arg->pkgname, arg->id, arg->info.pd_create.x, arg->info.pd_create.y, arg->info.pd_create.w, arg->info.pd_create.h); - _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id); - SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id); + _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->id); + SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for providerId(%s), instanceId(%s)", arg->pkgname, arg->id); pAppWidgetContext->OnPopupCreated(arg->info.pd_create.x, arg->info.pd_create.y, arg->info.pd_create.w, arg->info.pd_create.h); @@ -409,10 +410,10 @@ AppWidgetManagerService::OnAppWidgetPopupCreate(struct event_arg *arg, void* dat AppWidgetManagerService::OnAppWidgetPopupDestroy(struct event_arg *arg, void* data) { SysTryReturn (NID_SHELL, arg->type == event_arg::EVENT_PD_DESTROY, -EPERM, E_SUCCESS, "invalid argument from master"); - _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id); - SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id); + _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->id); + SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for providerId(%s), instanceId(%s)", arg->pkgname, arg->id); - SysSecureLog(NID_SHELL, "packageName(%s), id(%s)", arg->pkgname, arg->id); + SysSecureLog(NID_SHELL, "providerId(%s), id(%s)", arg->pkgname, arg->id); pAppWidgetContext->OnPopupDestoyed(); return 0; @@ -423,10 +424,10 @@ AppWidgetManagerService::OnAppWidgetPause(struct event_arg *arg, void* data) { SysTryReturn(NID_SHELL, arg, 0, E_SUCCESS, "arg is null!"); - _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id); - SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , 0, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id); + _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->id); + SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , 0, "[E_SYSTEM] pAppWidgetContext is null for providerId(%s), instanceId(%s)", arg->pkgname, arg->id); - SysSecureLog(NID_SHELL, "packageName(%s), id(%s)", arg->pkgname, arg->id); + SysSecureLog(NID_SHELL, "providerId(%s), id(%s)", arg->pkgname, arg->id); pAppWidgetContext->OnBackground(); return 0; @@ -440,10 +441,10 @@ AppWidgetManagerService::OnAppWidgetPauseAll(struct event_arg *arg, void* data) while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pValue = null; - pAppWidgetContextEnum->GetValue(pValue); + _AppWidgetContext* pContext = null; + pAppWidgetContextEnum->GetValue(pContext); - pValue->OnBackground(); + pContext->OnBackground(); } return 0; @@ -454,10 +455,10 @@ AppWidgetManagerService::OnAppWidgetResume(struct event_arg *pArg, void* pData) { SysTryReturn(NID_SHELL, pArg || pArg->id || pArg->pkgname, 0, E_SUCCESS, "pArg is null!"); - _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(pArg->pkgname, pArg->id); - SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", pArg->pkgname, pArg->id); + _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(pArg->id); + SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for providerId(%s), instanceId(%s)", pArg->pkgname, pArg->id); - SysSecureLog(NID_SHELL, "packageName(%s), id(%s)", pArg->pkgname, pArg->id); + SysSecureLog(NID_SHELL, "providerId(%s), id(%s)", pArg->pkgname, pArg->id); pAppWidgetContext->OnForeground(); return 0; } @@ -470,10 +471,10 @@ AppWidgetManagerService::OnAppWidgetResumeAll(struct event_arg *pArg, void* pDat while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pValue = null; - pAppWidgetContextEnum->GetValue(pValue); + _AppWidgetContext* pContext = null; + pAppWidgetContextEnum->GetValue(pContext); - pValue->OnForeground(); + pContext->OnForeground(); } return 0; @@ -484,7 +485,7 @@ AppWidgetManagerService::OnAppWidgetClick(struct event_arg *arg, void* data) { SysTryReturn (NID_SHELL, arg->type == event_arg::EVENT_CLICKED, -EPERM, E_SUCCESS, "invalid argument from master"); SysTryReturn(NID_SHELL, arg != null, -EPERM, E_SUCCESS, "arg is null!"); - SysSecureLog(NID_SHELL, "packageName(%s), id(%s), clicked.event(%s), clicked.x(%f), clicked.y(%f)", arg->pkgname, arg->id, arg->info.clicked.event, arg->info.clicked.x, arg->info.clicked.y); + SysSecureLog(NID_SHELL, "providerId(%s), id(%s), clicked.event(%s), clicked.x(%f), clicked.y(%f)", arg->pkgname, arg->id, arg->info.clicked.event, arg->info.clicked.x, arg->info.clicked.y); return 0; } @@ -495,10 +496,10 @@ AppWidgetManagerService::OnAppWidgetResize(struct event_arg *arg, void* data) SysTryReturn(NID_SHELL, arg || arg->id || arg->pkgname, 0, E_SUCCESS, "arg is null!"); SysTryReturn (NID_SHELL, arg->type == event_arg::EVENT_RESIZE, -EPERM, E_SUCCESS, "invalid argument from master"); - SysSecureLog(NID_SHELL, "packageName(%s), id(%s), resize.w(%d), resize.h(%d)", arg->pkgname, arg->id, arg->info.resize.w, arg->info.resize.h); + SysSecureLog(NID_SHELL, "providerId(%s), id(%s), resize.w(%d), resize.h(%d)", arg->pkgname, arg->id, arg->info.resize.w, arg->info.resize.h); - _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->pkgname, arg->id); - SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for appId(%s), instanceId(%s)", arg->pkgname, arg->id); + _AppWidgetContext* pAppWidgetContext = AppWidgetManagerService::GetInstance()->Find(arg->id); + SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for providerId(%s), instanceId(%s)", arg->pkgname, arg->id); pAppWidgetContext->OnResize(arg->info.resize.w, arg->info.resize.h); @@ -509,7 +510,7 @@ int AppWidgetManagerService::OnAppWidgetPeriodChanged(struct event_arg *arg, void* data) { SysTryReturn(NID_SHELL, arg != null, 0, E_SUCCESS, "arg is null!"); - SysSecureLog(NID_SHELL, "packageName(%s), id(%s), width(%d), height(%d), priority(%d)", arg->pkgname, arg->id); + SysSecureLog(NID_SHELL, "providerId(%s), id(%s), width(%d), height(%d), priority(%d)", arg->pkgname, arg->id); return 0; } @@ -520,12 +521,12 @@ AppWidgetManagerService::OnAppWidgetRecreate(struct event_arg *arg, void* data) SysTryReturn(NID_SHELL, arg->pkgname != null, EINVAL, E_INVALID_ARG, "[E_INVALID_ARG]"); SysTryReturn(NID_SHELL, arg->id != null, EINVAL, E_INVALID_ARG, "[E_INVALID_ARG]"); - SysSecureLog(NID_SHELL, "packageName(%s) id(%s) content(%s) cluster(%s) category(%s)", arg->pkgname, arg->id, arg->info.lb_recreate.content, arg->info.lb_recreate.cluster, arg->info.lb_recreate.category); + SysSecureLog(NID_SHELL, "providerId(%s) id(%s) content(%s) cluster(%s) category(%s)", arg->pkgname, arg->id, arg->info.lb_recreate.content, arg->info.lb_recreate.cluster, arg->info.lb_recreate.category); AppWidgetManagerService* pAppWidgetManagerService = AppWidgetManagerService::GetInstance(); SysTryReturn(NID_SHELL, pAppWidgetManagerService != null, -EBUSY, E_SYSTEM, "Failed to get the instance for AppWidgetManagerService."); - double default_priority = 1.0f; + const double default_priority = 1.0f; _AppWidgetContext* pAppWidgetContext = pAppWidgetManagerService->AddAppWidget(arg->info.lb_create.content, arg->pkgname, arg->id, arg->info.lb_create.width, arg->info.lb_create.height, arg->info.lb_create.period * 1000, default_priority); SysTryReturn(NID_SHELL, pAppWidgetContext != null, -EBUSY, E_SYSTEM, "Failed to add the appwidget."); @@ -533,23 +534,10 @@ AppWidgetManagerService::OnAppWidgetRecreate(struct event_arg *arg, void* data) } result -AppWidgetManagerService::InitializeCoreDaemonEventReceiver(const char *pIdForCoreDaemon) +AppWidgetManagerService::InitializeCoreDaemonEventReceiver(const char *pCoreDaemonId) { - SysTryReturnResult(NID_SHELL, pIdForCoreDaemon != null, E_INVALID_ARG, "pIdForCoreDaemon should not be null!"); - - 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."); - - r = __appContextList.Construct(0, 0, strHashCodeProvider, strComparer); - SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute Construct."); + SysTryReturnResult(NID_SHELL, pCoreDaemonId != null, E_INVALID_ARG, "pCoreDaemonId should not be null!"); - /*! - * \note - * Only for the buffer type - */ struct event_handler cbs; memset(&cbs, 0, sizeof(event_handler)); @@ -570,19 +558,17 @@ AppWidgetManagerService::InitializeCoreDaemonEventReceiver(const char *pIdForCor cbs.lb_recreate = OnAppWidgetRecreate;/* Recover from the fault of slave */ //cbs.content_event = OnAppWidgetContentEvent, - int ret = provider_init(null, pIdForCoreDaemon, &cbs, this); + int ret = provider_init(null, pCoreDaemonId, &cbs, this); SysTryReturnResult(NID_SHELL, ret == 0, E_SYSTEM, "provider_init failed."); - SysLog(NID_SHELL, "provider_init is invoked with (%s)", pIdForCoreDaemon); + SysLog(NID_SHELL, "provider_init is invoked with (%s)", pCoreDaemonId); return E_SUCCESS; } result AppWidgetManagerService::DeinitializeCoreDaemonEventReceiver(void) { - SysLog(NID_SHELL, "Enter."); provider_fini(); - SysLog(NID_SHELL, "Exit."); return E_SUCCESS; } @@ -602,23 +588,13 @@ AppWidgetManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tiz while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pValue = null; - pAppWidgetContextEnum->GetValue(pValue); + _AppWidgetContext* pContext = null; + pAppWidgetContextEnum->GetValue(pContext); if ( (updateAllSuspended == true && AppManager::GetInstance()->IsRunning(appId) == false ) - || ( pValue->GetAppId() == appId && pValue->GetProviderName() == providerName ) ) + || ( pContext->GetAppId() == appId && pContext->GetProviderName() == providerName ) ) { - ArrayList* pArray = new (std::nothrow) ArrayList(); - SysTryReturnResult(NID_SHELL, pArray, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); - - pArray->Construct(); - 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, pValue->GetAppId().GetPointer(), pValue->GetProviderName().GetPointer() ); + RequestUpdate(pContext, argument); found = true; } } @@ -631,34 +607,11 @@ AppWidgetManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tiz result AppWidgetManagerService::RequestUpdate(_AppWidgetContext* pAppWidgetContext, const String& argument) { - if (pAppWidgetContext) - { - 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)); - - result r = __handlerThread.SendUserEvent(LOCAL_EVENT_REQUEST_UPDATE, pArray); - SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Propagated.", GetErrorMessage(r)); - } - else + if (pAppWidgetContext == null) { SysLog(NID_SHELL, "pAppWidgetContext is null."); } - return E_SUCCESS; -} - -result -AppWidgetManagerService::RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument) -{ - SysSecureLog(NID_SHELL, "%ls, %ls", instanceId.GetPointer(), argument.GetPointer() ); - - _AppWidgetContext* pAppWidgetContext = Find(L"", instanceId); - SysTryReturnResult(NID_SHELL, pAppWidgetContext, E_OBJ_NOT_FOUND, "Failed to find the object."); - ArrayList* pArray = new (std::nothrow) ArrayList(); SysTryReturnResult(NID_SHELL, pArray, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); @@ -668,64 +621,77 @@ AppWidgetManagerService::RequestUpdateInstance(const Tizen::Base::String& instan 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() ); + + return E_SUCCESS; +} + +result +AppWidgetManagerService::RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument) +{ + SysSecureLog(NID_SHELL, "%ls, %ls", instanceId.GetPointer(), argument.GetPointer() ); + + _AppWidgetContext* pAppWidgetContext = Find(instanceId); + SysTryReturnResult(NID_SHELL, pAppWidgetContext, E_OBJ_NOT_FOUND, "Failed to find the object(%ls).", instanceId.GetPointer()); + RequestUpdate(pAppWidgetContext, argument); return E_SUCCESS; } result -AppWidgetManagerService::RequestSharedMemoryId(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId) +AppWidgetManagerService::AcquireRemoteBuffer(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& bufferId) { - _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId); + _AppWidgetContext* pAppWidgetContext = this->Find(instanceId); SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); - shmId = pAppWidgetContext->GetSharedMemId(width, height); - SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , shmId != -1, "[E_SYSTEM] failed to GetSharedMemId for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); + bufferId = pAppWidgetContext->AcquireRemoteBuffer(width, height); + SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , bufferId != -1, "[E_SYSTEM] failed to AcquireRemoteBuffer for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); return E_SUCCESS; } result -AppWidgetManagerService::RequestSharedMemoryIdForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId) +AppWidgetManagerService::AcquireRemoteBufferForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& bufferId) { - _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId); + _AppWidgetContext* pAppWidgetContext = this->Find(instanceId); SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); _AppWidgetPopupContext* pPopupContext = pAppWidgetContext->GetAppWidgetPopup(); SysSecureTryReturnResult(NID_SHELL, pPopupContext , E_SYSTEM, "[E_SYSTEM] pPd is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); - shmId = pPopupContext->GetSharedMemId(width, height); - SysSecureTryReturnResult(NID_SHELL, shmId != -1, E_SYSTEM, "Failed to GetSharedMemId for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); + bufferId = pPopupContext->AcquireRemoteBuffer(width, height); + SysSecureTryReturnResult(NID_SHELL, bufferId != -1, E_SYSTEM, "Failed to AcquireRemoteBuffer for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); return E_SUCCESS; } result -AppWidgetManagerService::RequestSyncSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height) +AppWidgetManagerService::SyncRemoteBuffer(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height) { - _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId); + _AppWidgetContext* pAppWidgetContext = this->Find(instanceId); SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); - return pAppWidgetContext->RequestUpdateRemote(width, height); + return pAppWidgetContext->SyncRemoteBuffer(width, height); } result -AppWidgetManagerService::RequestSyncSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) +AppWidgetManagerService::SyncRemoteBufferForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) { - _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId); + _AppWidgetContext* pAppWidgetContext = this->Find(instanceId); SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext->GetAppWidgetPopup(), E_SYSTEM, "[E_SYSTEM] GetAppWidgetPopup() returns null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); - return pAppWidgetContext->GetAppWidgetPopup()->RequestUpdateRemote(); + return pAppWidgetContext->GetAppWidgetPopup()->SyncRemoteBuffer(); } result -AppWidgetManagerService::RequestReleaseSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) +AppWidgetManagerService::ReleaseRemoteBuffer(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) { return E_SUCCESS; } result -AppWidgetManagerService::RequestReleaseSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) +AppWidgetManagerService::ReleaseRemoteBufferForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) { return E_SUCCESS; } @@ -735,21 +701,21 @@ AppWidgetManagerService::RequestProviderCount(const Tizen::App::AppId& appId, co { SysLog(NID_SHELL, "ENTER"); - _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId); + _AppWidgetContext* pAppWidgetContext = this->Find(instanceId); SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext, E_SYSTEM, "pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); providerCount = GetProviderCount(pAppWidgetContext->GetAppId()); - std::unique_ptr packageName(_StringConverter::CopyToCharArrayN(pAppWidgetContext->GetProviderId())); + std::unique_ptr providerId(_StringConverter::CopyToCharArrayN(pAppWidgetContext->GetProviderId())); std::unique_ptr id(_StringConverter::CopyToCharArrayN(pAppWidgetContext->GetInstanceId())); - int ret = provider_send_deleted(packageName.get(), id.get()); + int ret = provider_send_deleted(providerId.get(), id.get()); SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "Failed to execute provider_send_deleted."); //result r = pAppWidgetContext->OnRemoved(); //SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute OnRemoved."); - result r = RemoveAppWidget(packageName.get(), id.get(), true); + result r = RemoveAppWidget(providerId.get(), id.get()); SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute RemoveAppWidget."); providerCount--; @@ -786,21 +752,21 @@ AppWidgetManagerService::SendResult(const Tizen::App::AppId& appId, const Tizen: } else { - pAppWidgetContext = this->Find(appId, instanceId); + pAppWidgetContext = this->Find(instanceId); } SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext, E_SYSTEM, "pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); - std::unique_ptr packageName(_StringConverter::CopyToCharArrayN(pAppWidgetContext->GetProviderId())); + std::unique_ptr providerId(_StringConverter::CopyToCharArrayN(pAppWidgetContext->GetProviderId())); std::unique_ptr id(_StringConverter::CopyToCharArrayN(pAppWidgetContext->GetInstanceId())); - int ret = provider_send_deleted(packageName.get(), id.get()); + int ret = provider_send_deleted(providerId.get(), id.get()); SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "Failed to execute provider_send_deleted."); //result r = pAppWidgetContext->OnRemoved(); //SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute OnRemoved."); - result r = RemoveAppWidget(packageName.get(), id.get(), true); + result r = RemoveAppWidget(providerId.get(), id.get()); SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute RemoveAppWidget."); } else // for pending event excluding touch event. @@ -816,7 +782,7 @@ AppWidgetManagerService::SendResult(const Tizen::App::AppId& appId, const Tizen: result AppWidgetManagerService::SendAccessStatus(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int accessStatus) { - _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId); + _AppWidgetContext* pAppWidgetContext = this->Find(instanceId); SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); return pAppWidgetContext->SendAccessStatus(accessStatus); @@ -832,13 +798,13 @@ AppWidgetManagerService::RequestPendingEvent(void) while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS) { - _AppWidgetContext* pValue = null; - pAppWidgetContextEnum->GetValue(pValue); + _AppWidgetContext* pContext = null; + pAppWidgetContextEnum->GetValue(pContext); - r = pValue->SendPendingEvent(); + r = pContext->SendPendingEvent(); if (r == E_SUCCESS) { - (pValue->GetAppContext())->__isWaitingResult = false; + (pContext->GetAppContext())->__isWaitingResult = false; SysLog(NID_SHELL, "Found pending event."); break; } @@ -846,7 +812,7 @@ AppWidgetManagerService::RequestPendingEvent(void) { if (E_DATA_NOT_FOUND) { - (pValue->GetAppContext())->__isWaitingResult = false; + (pContext->GetAppContext())->__isWaitingResult = false; } } } diff --git a/src/FShell_AppWidgetManagerStub.cpp b/src/FShell_AppWidgetManagerStub.cpp index 09c2d78..4645551 100644 --- a/src/FShell_AppWidgetManagerStub.cpp +++ b/src/FShell_AppWidgetManagerStub.cpp @@ -42,9 +42,6 @@ using namespace Tizen::Security; _AppWidgetManagerStub::_AppWidgetManagerStub(void) :__pIpcServer(null) { - SysLog(NID_SHELL, "Enter\n"); - - SysLog(NID_SHELL, "Exit\n"); } _AppWidgetManagerStub::~_AppWidgetManagerStub(void) @@ -96,61 +93,61 @@ _AppWidgetManagerStub::OnRequestUpdateInstance(const Tizen::Base::String& instan } bool -_AppWidgetManagerStub::OnRequestSharedMemoryId(const String& instanceId, int w, int h, int* pShmId) +_AppWidgetManagerStub::OnAcquireRemoteBuffer(const String& instanceId, int w, int h, int* pShmId) { SysSecureLog(NID_SHELL, "(instanceId:%ls)", instanceId.GetPointer()); - RequestSharedMemoryId(__pIpcServer->GetClientPackageId(), instanceId, w, h, *pShmId); + AcquireRemoteBuffer(__pIpcServer->GetClientPackageId(), instanceId, w, h, *pShmId); return true; } bool -_AppWidgetManagerStub::OnRequestSharedMemoryIdForPD(const String& instanceId, int w, int h, int* pShmId) +_AppWidgetManagerStub::OnAcquireRemoteBufferForPD(const String& instanceId, int w, int h, int* pShmId) { SysSecureLog(NID_SHELL, "(instanceId:%ls)", instanceId.GetPointer()); - RequestSharedMemoryIdForPD(__pIpcServer->GetClientPackageId(), instanceId, w, h, *pShmId); + AcquireRemoteBufferForPD(__pIpcServer->GetClientPackageId(), instanceId, w, h, *pShmId); return true; } bool -_AppWidgetManagerStub::OnRequestSyncSharedMemory(const String& instanceId, int w, int h, result* pRes) +_AppWidgetManagerStub::OnSyncRemoteBuffer(const String& instanceId, int w, int h, result* pRes) { SysSecureLog(NID_SHELL, "(instanceId:%ls)", instanceId.GetPointer()); - *pRes = RequestSyncSharedMemory(__pIpcServer->GetClientPackageId(), instanceId, w, h); + *pRes = SyncRemoteBuffer(__pIpcServer->GetClientPackageId(), instanceId, w, h); return true; } bool -_AppWidgetManagerStub::OnRequestSyncSharedMemoryForPD(const String& instanceId, result* pRes) +_AppWidgetManagerStub::OnSyncRemoteBufferForPD(const String& instanceId, result* pRes) { SysSecureLog(NID_SHELL, "(instanceId:%ls)", instanceId.GetPointer()); - *pRes = RequestSyncSharedMemoryForPD(__pIpcServer->GetClientPackageId(), instanceId); + *pRes = SyncRemoteBufferForPD(__pIpcServer->GetClientPackageId(), instanceId); return true; } bool -_AppWidgetManagerStub::OnRequestReleaseSharedMemory(const String& instanceId, result* pRes) +_AppWidgetManagerStub::OnReleaseRemoteBuffer(const String& instanceId, result* pRes) { SysSecureLog(NID_SHELL, "(instanceId:%ls)", instanceId.GetPointer()); - *pRes = RequestReleaseSharedMemory(__pIpcServer->GetClientPackageId(), instanceId); + *pRes = ReleaseRemoteBuffer(__pIpcServer->GetClientPackageId(), instanceId); return true; } bool -_AppWidgetManagerStub::OnRequestReleaseSharedMemoryForPD(const String& instanceId, result* pRes) +_AppWidgetManagerStub::OnReleaseRemoteBufferForPD(const String& instanceId, result* pRes) { SysSecureLog(NID_SHELL, "(instanceId:%ls)", instanceId.GetPointer()); - *pRes = RequestReleaseSharedMemoryForPD(__pIpcServer->GetClientPackageId(), instanceId); + *pRes = ReleaseRemoteBufferForPD(__pIpcServer->GetClientPackageId(), instanceId); return true; } @@ -185,6 +182,40 @@ _AppWidgetManagerStub::OnSendAccessStatus(const String& instanceId, int accessSt return true; } +void +_AppWidgetManagerStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message) +{ + SysLog(NID_SHELL, "(appId:%ls, clientId:%d)\n", server.GetClientApplicationId().GetPointer(), server.GetClientId()); + + SysAssertf(__pIpcServer, "__pIpcServer is null!"); + + IPC_BEGIN_MESSAGE_MAP(_AppWidgetManagerStub, message) + IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestUpdate, &server, OnRequestUpdate) + IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestUpdateInstance, &server, OnRequestUpdateInstance) + IPC_MESSAGE_HANDLER_EX(AppWidgetManager_AcquireRemoteBuffer, &server, OnAcquireRemoteBuffer) + IPC_MESSAGE_HANDLER_EX(AppWidgetManager_AcquireRemoteBufferForPD, &server, OnAcquireRemoteBufferForPD) + IPC_MESSAGE_HANDLER_EX(AppWidgetManager_SyncRemoteBuffer, &server, OnSyncRemoteBuffer) + IPC_MESSAGE_HANDLER_EX(AppWidgetManager_SyncRemoteBufferForPD, &server, OnSyncRemoteBufferForPD) + IPC_MESSAGE_HANDLER_EX(AppWidgetManager_ReleaseRemoteBuffer, &server, OnReleaseRemoteBuffer) + IPC_MESSAGE_HANDLER_EX(AppWidgetManager_ReleaseRemoteBufferForPD, &server, OnReleaseRemoteBufferForPD) + IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestProviderCount, &server, OnRequestProviderCount) + IPC_MESSAGE_HANDLER_EX(AppWidgetManager_SendResult, &server, OnSendResult) +// IPC_MESSAGE_HANDLER_EX(AppWidgetManager_SendAccessStatus, &server, OnSendAccessStatus) + IPC_END_MESSAGE_MAP() +} + +void +_AppWidgetManagerStub::OnIpcServerStarted(const _IpcServer& server) +{ + SysLog(NID_SHELL, "\n"); +} + +void +_AppWidgetManagerStub::OnIpcServerStopped(const _IpcServer& server) +{ + SysLog(NID_SHELL, "\n"); +} + bool _AppWidgetManagerStub::SendAppWidgetEvent(const int clientId, const String& instanceId, const String& operationId, HashMap* pArgs) { @@ -215,38 +246,5 @@ _AppWidgetManagerStub::SendTouchEventForPD(const int clientId, const String& ins return true; } -void -_AppWidgetManagerStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message) -{ - SysLog(NID_SHELL, "(appId:%ls, clientId:%d)\n", server.GetClientApplicationId().GetPointer(), server.GetClientId()); - - SysAssertf(__pIpcServer, "__pIpcServer is null!"); - - IPC_BEGIN_MESSAGE_MAP(_AppWidgetManagerStub, message) - IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestUpdate, &server, OnRequestUpdate) - IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestUpdateInstance, &server, OnRequestUpdateInstance) - IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSharedMemoryId, &server, OnRequestSharedMemoryId) - IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSharedMemoryIdForPD, &server, OnRequestSharedMemoryIdForPD) - IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSyncSharedMemory, &server, OnRequestSyncSharedMemory) - IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSyncSharedMemoryForPD, &server, OnRequestSyncSharedMemoryForPD) - IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestReleaseSharedMemory, &server, OnRequestReleaseSharedMemory) - IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestReleaseSharedMemoryForPD, &server, OnRequestReleaseSharedMemoryForPD) - IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestProviderCount, &server, OnRequestProviderCount) - IPC_MESSAGE_HANDLER_EX(AppWidgetManager_SendResult, &server, OnSendResult) -// IPC_MESSAGE_HANDLER_EX(AppWidgetManager_SendAccessStatus, &server, OnSendAccessStatus) - IPC_END_MESSAGE_MAP() -} - -void -_AppWidgetManagerStub::OnIpcServerStarted(const _IpcServer& server) -{ - SysLog(NID_SHELL, "\n"); -} - -void -_AppWidgetManagerStub::OnIpcServerStopped(const _IpcServer& server) -{ - SysLog(NID_SHELL, "\n"); -} }}} // Tizen::Shell::App diff --git a/src/FShell_AppWidgetPopupContext.cpp b/src/FShell_AppWidgetPopupContext.cpp index e99d027..fffea88 100644 --- a/src/FShell_AppWidgetPopupContext.cpp +++ b/src/FShell_AppWidgetPopupContext.cpp @@ -46,7 +46,7 @@ const wchar_t APPWIDGET_POPUP_ON_CREATE[] = L"http://tizen.org/appcontrol/appwid const wchar_t APPWIDGET_POPUP_ON_DESTROY[] = L"http://tizen.org/appcontrol/appwidgetpopup/destroy"; const wchar_t APPWIDGET_POPUP_ON_TOUCH[] = L"http://tizen.org/appcontrol/appwidgetpopup/touch"; -_AppWidgetPopupContext::_AppWidgetPopupContext(_AppWidgetContext* pParent) +_AppWidgetPopupContext::_AppWidgetPopupContext(const _AppWidgetContext* pParent) : __pParent(pParent) { __pAppWidgetRemoteBuffer = new (nothrow) _AppWidgetRemoteBuffer(__pParent->GetProviderId(), __pParent->GetInstanceId(), TYPE_PD, this); @@ -57,12 +57,10 @@ _AppWidgetPopupContext::_AppWidgetPopupContext(_AppWidgetContext* pParent) _AppWidgetPopupContext::~_AppWidgetPopupContext(void) { - SysLog(NID_SHELL, "The drop view for %ls destructed.", (__pParent->GetInstanceId()).GetPointer()); + OnPopupDestoyed(); + delete __pAppWidgetRemoteBuffer; - if (__pAppWidgetRemoteBuffer) - { - delete __pAppWidgetRemoteBuffer; - } + SysLog(NID_SHELL, "The drop view for %ls destructed.", (__pParent->GetInstanceId()).GetPointer()); } void @@ -82,7 +80,7 @@ _AppWidgetPopupContext::OnPopupDestoyed(void) result _AppWidgetPopupContext::SendPopupCreateRequest(double x, double y, int width, int height) { - std::unique_ptr pArgs (CreateRequestArgsN() ); + std::unique_ptr pArgs (__pParent->CreateRequestArgsN() ); pArgs->Add(new String(ARG_KEY_X), new String(Double::ToString(x))); pArgs->Add(new String(ARG_KEY_Y), new String(Double::ToString(y))); @@ -95,7 +93,7 @@ _AppWidgetPopupContext::SendPopupCreateRequest(double x, double y, int width, in result _AppWidgetPopupContext::SendPopupDestroyRequest(void) { - std::unique_ptr pArgs (CreateRequestArgsN() ); + std::unique_ptr pArgs (__pParent->CreateRequestArgsN() ); return __pParent->SendPopupRequestToApp(__pParent->GetAppId(), APPWIDGET_POPUP_ON_DESTROY, pArgs.get()); } @@ -108,32 +106,18 @@ _AppWidgetPopupContext::OnTouchEventReceived(buffer_event event, double timestam } result -_AppWidgetPopupContext::RequestUpdateRemote(void) +_AppWidgetPopupContext::SyncRemoteBuffer(void) { - std::unique_ptr packageName(_StringConverter::CopyToCharArrayN(__pParent->GetProviderId())); + std::unique_ptr providerId(_StringConverter::CopyToCharArrayN(__pParent->GetProviderId())); std::unique_ptr id(_StringConverter::CopyToCharArrayN(__pParent->GetInstanceId())); - int ret = provider_send_desc_updated(packageName.get(), id.get(), null); + int ret = provider_send_desc_updated(providerId.get(), id.get(), null); SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated"); SysLog(NID_SHELL, "Done"); return E_SUCCESS; } -Tizen::Base::Collection::HashMap* -_AppWidgetPopupContext::CreateRequestArgsN(void) -{ - HashMap* pArgs = new (nothrow) HashMap(SingleObjectDeleter); - pArgs->Construct(); - pArgs->Add(new String(ARG_KEY_INSTANCE_ID), new String(__pParent->GetInstanceId())); - pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(__pParent->GetProviderName())); - pArgs->Add(new String(ARG_KEY_USER_INFO), new String(__pParent->GetUserInfo())); - pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(__pParent->GetWidth()))); - pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(__pParent->GetHeight()))); - - return pArgs; -} - int _AppWidgetPopupContext::GetClientId(void) const { @@ -141,9 +125,9 @@ _AppWidgetPopupContext::GetClientId(void) const } int -_AppWidgetPopupContext::GetSharedMemId(int w, int h) const +_AppWidgetPopupContext::AcquireRemoteBuffer(int w, int h) const { - return __pAppWidgetRemoteBuffer->GetSharedMemId(w, h); + return __pAppWidgetRemoteBuffer->Acquire(w, h); } }}} // Tizen::Shell::App diff --git a/src/FShell_AppWidgetRemoteBuffer.cpp b/src/FShell_AppWidgetRemoteBuffer.cpp index 677e028..4db81c0 100644 --- a/src/FShell_AppWidgetRemoteBuffer.cpp +++ b/src/FShell_AppWidgetRemoteBuffer.cpp @@ -83,27 +83,27 @@ _AppWidgetRemoteBuffer::_AppWidgetRemoteBuffer(const String& providerId, const S _AppWidgetRemoteBuffer::~_AppWidgetRemoteBuffer(void) { - ReleaseSharedMem(); + Release(); SysLog(NID_SHELL, "_AppWidgetRemoteBuffer is destructed."); } int -_AppWidgetRemoteBuffer::GetSharedMemId(int w, int h) +_AppWidgetRemoteBuffer::Acquire(int w, int h) { SysLog(NID_SHELL, "Enter"); bool isResized = (__buffer_info != null) && (__buffer_info->width != w || __buffer_info->height != h); if ( isResized ) { - ReleaseSharedMem(); + Release(); } if( __buffer_info == null) { - std::unique_ptr packageName(_StringConverter::CopyToCharArrayN(__providerId)); + std::unique_ptr providerId(_StringConverter::CopyToCharArrayN(__providerId)); std::unique_ptr id(_StringConverter::CopyToCharArrayN(__instanceId)); - __buffer_info = provider_buffer_acquire(__type, packageName.get(), id.get(), w, h, sizeof(int), AppWidgetHandleBufferEventCallback, __pListener); + __buffer_info = provider_buffer_acquire(__type, providerId.get(), id.get(), w, h, sizeof(int), AppWidgetHandleBufferEventCallback, __pListener); SysTryReturn(NID_SHELL, __buffer_info, -1, E_SYSTEM, "[E_SYSTEM] Failed to execute provider_buffer_acquire"); SysLog(NID_SHELL, "provider_buffer_acquire successed"); @@ -119,7 +119,7 @@ _AppWidgetRemoteBuffer::GetSharedMemId(int w, int h) } result -_AppWidgetRemoteBuffer::ReleaseSharedMem(void) +_AppWidgetRemoteBuffer::Release(void) { SysLog(NID_SHELL, "Enter"); -- 2.7.4