From 80a2d61323f3ca4170bd78a8a904377ec3e88105 Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Wed, 13 Nov 2013 13:42:58 +0900 Subject: [PATCH] Merge branch 'tizen_2.2' into tizen - clean up code - fix to send pending request in main thread using local event. fix double delete problem. - fix to delete _AppContext in OnApplicationTerminated, instead of OnAppWidgetDestroy.(fix tct fails) - fix to stop ipc server in AppWidgetManagerService destructor to avoid SIGABORT - fix problem that AppWidgetProviderManager::RequestUpdate() doesn't return E_OBJ_NOT_FOUND properly - fix to destroy AppWidgetManagerService in OnAppTerminating(), not by std::atexit() Change-Id: Ife2e0e01f177ce37a2c6e97eea0d1dbf41c76b76 Signed-off-by: jungmin76.park --- inc/FShell_AppContext.h | 62 +++++++++-------- inc/FShell_AppWidgetContext.h | 6 +- inc/FShell_AppWidgetManagerService.h | 12 ++-- inc/FShell_AppWidgetManagerStub.h | 6 +- inc/FShell_AppWidgetRemoteBuffer.h | 6 +- src/FShell_AppContext.cpp | 121 ++++++++++++++++++++++----------- src/FShell_AppWidgetContext.cpp | 61 +++++------------ src/FShell_AppWidgetManagerService.cpp | 77 ++++++++------------- src/FShell_AppWidgetManagerStub.cpp | 27 ++++---- src/FShell_AppWidgetPopupContext.cpp | 17 ++--- src/FShell_AppWidgetRemoteBuffer.cpp | 46 ++++++++++++- src/OspAppWidgetService.cpp | 4 +- 12 files changed, 247 insertions(+), 198 deletions(-) diff --git a/inc/FShell_AppContext.h b/inc/FShell_AppContext.h index 9699e00..57999da 100644 --- a/inc/FShell_AppContext.h +++ b/inc/FShell_AppContext.h @@ -25,7 +25,7 @@ #define _FSHELL_INTERNAL_APP_CONTEXT_H_ #include -#include +#include #include #include @@ -54,12 +54,34 @@ class _AppWidgetContext; class _AppContext :public Tizen::Base::Object { - public: + + class Request + { + public: + Request(const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs) + : __operation(operation), __pArgs(pArgs){ } + + ~Request(void) + { + if (__pArgs) + { + __pArgs->RemoveAll(); + delete __pArgs; + } + } + + private: + Tizen::Base::String __operation; + Tizen::Base::Collection::HashMap* __pArgs; + + friend class _AppContext; + }; + _AppContext(const Tizen::App::AppId& appId); ~_AppContext(void); - result AddAppWidget(const Tizen::Base::String& userInfo, const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, int width, int height, int period, int priority); + result AddAppWidget(const Tizen::Base::String& userInfo, const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, int width, int height, int period); result UpdateAppWidget(const Tizen::Base::String& instanceId); result DestroyAppWidget(const Tizen::Base::String& instanceId, bool isTriggeredByViewer = true); result ResizeAppWidget(const Tizen::Base::String& instanceId, int width, int height); @@ -72,10 +94,9 @@ public: result OnAppWidgetBackgroundAll(void); result OnAppWidgetForegroundAll(void); - result RequestUpdate(const Tizen::Base::String& providerName, const Tizen::Base::String& argument); - result RequestUpdateAllInactiveted(void); - result SendRequestToApp(const Tizen::App::AppId& providerAppId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); - result SendPendingEvent(void); + result SendRequestToApp(const Tizen::App::AppId& providerAppId, Request* pRequest); + void OnResponseReceived(const Tizen::Base::String& instanceId, bool isSucceeded); + result SendPendingRequests(void); void OnIpcConnected(int clientId); void OnIpcDisconnected(void); @@ -89,13 +110,16 @@ public: _AppWidgetContext* FindAppWidget(const Tizen::Base::String& instanceId) const; int GetProviderCount(void) const; - result RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument); result AcquireRemoteBuffer(const Tizen::Base::String& instanceId, int width, int height, int& bufferId); result AcquireRemoteBufferForPD(const Tizen::Base::String& instanceId, int width, int height, int& bufferId); result SyncRemoteBuffer(const Tizen::Base::String& instanceId, int width, int height); result SyncRemoteBufferForPD(const Tizen::Base::String& instanceId); result SendAccessStatus(const Tizen::Base::String& instanceId, int accessStatus); - void HandleUserEvent(Tizen::Base::Collection::IList* pArgs); + result RequestUpdate(const Tizen::Base::String& providerName, const Tizen::Base::String& argument); + result RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument); + result RequestUpdateAllInactiveted(void); + + static void OnLocalEventReceived( RequestId reqId, Tizen::Base::Collection::IList* pArgs); private: void SetConnectionState(_ConnectionState state); @@ -104,30 +128,12 @@ private: _AppWidgetContext* FindInvalidAppWidget(void) const; private: - struct PendingEvent - { - PendingEvent(const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pHashMap) - : operation(operation), pArgs(pHashMap) { } - - ~PendingEvent(void) - { - if (pArgs) - { - pArgs->RemoveAll(true); - delete pArgs; - } - } - - Tizen::Base::String operation; - Tizen::Base::Collection::HashMap* pArgs; - }; - const Tizen::App::AppId __appId; bool __isWaitingResult; int __ipcClientId; _ConnectionState __connectionState; Tizen::Base::Collection::HashMapT __appWidgetContexts; - Tizen::Base::Collection::ArrayListT* __pPendingEventList; + Tizen::Base::Collection::QueueT* __pRequestQueue; }; }}} // Tizen::Shell::App diff --git a/inc/FShell_AppWidgetContext.h b/inc/FShell_AppWidgetContext.h index 3ded99f..3347536 100644 --- a/inc/FShell_AppWidgetContext.h +++ b/inc/FShell_AppWidgetContext.h @@ -67,7 +67,7 @@ class _AppWidgetContext , public Tizen::Base::Object { public: - _AppWidgetContext(_AppContext* pAppContext, const Tizen::Base::String& instanceId, const Tizen::Base::String& providerId, int width, int height, const Tizen::Base::String& userInfo, int period, int priority); + _AppWidgetContext(_AppContext* pAppContext, const Tizen::Base::String& instanceId, const Tizen::Base::String& providerId, int width, int height, const Tizen::Base::String& userInfo, int period); virtual ~_AppWidgetContext(void); // handle dynamic box @@ -146,7 +146,6 @@ private: int __width; int __height; - const int __priority; const int __updateMillis; int __ipcClientId; @@ -164,7 +163,8 @@ private: Tizen::Base::Collection::ArrayListT* __pPendingTouchEventList; }; // class _AppWidgetContext -static const RequestId LOCAL_EVENT_REQUEST_UPDATE = 0; +static const RequestId LOCAL_EVENT_REQUEST_UPDATE = 1; +static const RequestId LOCAL_EVENT_REQUEST_SEND_PENDING_REQUEST = 2; }}} // Tizen::Shell::App diff --git a/inc/FShell_AppWidgetManagerService.h b/inc/FShell_AppWidgetManagerService.h index e6a6a79..a5cce59 100644 --- a/inc/FShell_AppWidgetManagerService.h +++ b/inc/FShell_AppWidgetManagerService.h @@ -47,14 +47,15 @@ class _AppContext; */ class AppWidgetManagerService :public Tizen::Shell::App::_AppWidgetManagerStub - ,public Tizen::App::_IAppEventListener - ,public Tizen::Base::Runtime::ITimerEventListener - ,public Tizen::System::ISettingEventListener + ,private Tizen::App::_IAppEventListener + ,private Tizen::Base::Runtime::ITimerEventListener + ,private Tizen::System::ISettingEventListener { public: static AppWidgetManagerService* GetInstance(void); static AppWidgetManagerService* CreateInstance(const char* pServiceIdForCoreDaemon); - result AddAppWidget(const Tizen::Base::String& userInfo, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int period, int priority); + static void DestroySingleton(void); + result AddAppWidget(const Tizen::Base::String& userInfo, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int period); result RequestUpdate(_AppWidgetContext* pAppWidgetContext, const Tizen::Base::String& argument) const; void OnUserEventReceivedN(RequestId reqId, Tizen::Base::Collection::IList* pArgs); virtual ~AppWidgetManagerService(void); @@ -97,7 +98,7 @@ private: virtual result SendAccessStatus(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int accessStatus); // stub implementations(response) - virtual result SendResult(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, bool isSucceeded); + virtual result OnResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, bool isSucceeded); // stub implementations(ipc connection) virtual void OnIpcClientConnected(const Tizen::App::AppId& appId, int clientId); @@ -119,7 +120,6 @@ private: virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); result RequestUpdateAllInactiveted(void) const; static void InitSingleton(void); - static void DestroySingleton(void); static bool SetSettingEventListener(Tizen::System::ISettingEventListener& listener); diff --git a/inc/FShell_AppWidgetManagerStub.h b/inc/FShell_AppWidgetManagerStub.h index 1e4082b..9bd2215 100644 --- a/inc/FShell_AppWidgetManagerStub.h +++ b/inc/FShell_AppWidgetManagerStub.h @@ -62,7 +62,7 @@ protected: 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 OnSendResult(const Tizen::Base::String& instanceId, bool isSucceeded); + bool OnSendResponse(const Tizen::Base::String& instanceId, bool isSucceeded); bool OnSendAccessStatus(const Tizen::Base::String& instanceId, int accessStatus); // interface to service @@ -76,7 +76,8 @@ protected: virtual result ReleaseRemoteBufferForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) = 0; virtual result SendAccessStatus(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int accessStatus) = 0; - virtual result SendResult(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, bool isSucceeded) = 0; + virtual result OnResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, bool isSucceeded) = 0; +// virtual result OnResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, bool isSucceeded) = 0; virtual void OnIpcClientConnected(const Tizen::App::AppId& appId, int clientId) = 0; virtual void OnIpcClientDisconnected(const Tizen::App::AppId& appId, int clientId) = 0; @@ -90,6 +91,7 @@ protected: result StartIpcServer(void); + void StopIpcServer(void); private: _AppWidgetManagerStub(const _AppWidgetManagerStub& value); diff --git a/inc/FShell_AppWidgetRemoteBuffer.h b/inc/FShell_AppWidgetRemoteBuffer.h index 67accde..9560a71 100644 --- a/inc/FShell_AppWidgetRemoteBuffer.h +++ b/inc/FShell_AppWidgetRemoteBuffer.h @@ -49,10 +49,13 @@ class _AppWidgetRemoteBuffer :public Tizen::Base::Object { public: - _AppWidgetRemoteBuffer(const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, target_type type, _IAppWidgetRemoteBufferEventListener* pListener); + _AppWidgetRemoteBuffer(const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, target_type type, _IAppWidgetRemoteBufferEventListener* pListener, bool isPopup = false); ~_AppWidgetRemoteBuffer(void); int Acquire(int w, int h); + result Sync(int width, int height, const Tizen::Base::String& contentInfo) const; + result SyncPopup(void) const; + result SendAccessStatus(int accessStatus) const; private: result Release(void); @@ -66,6 +69,7 @@ private: _IAppWidgetRemoteBufferEventListener* __pListener; Tizen::Base::Runtime::Mutex __mutex; + bool __isPopup; }; // class _AppWidgetRemoteBuffer diff --git a/src/FShell_AppContext.cpp b/src/FShell_AppContext.cpp index 69b0f01..04f51a2 100644 --- a/src/FShell_AppContext.cpp +++ b/src/FShell_AppContext.cpp @@ -25,9 +25,10 @@ #include #include #include +#include #include "FShell_AppWidgetContext.h" #include "FShell_AppWidgetContextHelper.h" -#include "FShell_TemplateUtil.h" + namespace Tizen { namespace Shell { namespace App { @@ -48,13 +49,13 @@ _AppContext::_AppContext(const AppId& appId) ,__isWaitingResult(false) ,__ipcClientId(0) ,__connectionState(CONNECTION_STATE_NONE) - ,__pPendingEventList(null) + ,__pRequestQueue(null) { - __pPendingEventList = new (nothrow) ArrayListT(); - SysTryReturnVoidResult(NID_SHELL, __pPendingEventList, E_OUT_OF_MEMORY, ""); + __pRequestQueue = new (nothrow) QueueT(); + SysTryReturnVoidResult(NID_SHELL, __pRequestQueue, E_OUT_OF_MEMORY, ""); - result r = __pPendingEventList->Construct(); + result r = __pRequestQueue->Construct(); SysTryReturnVoidResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute Construct."); r = __appWidgetContexts.Construct(); @@ -67,16 +68,15 @@ _AppContext::~_AppContext(void) { SysLog(NID_SHELL, "Enter"); - if (__pPendingEventList) + if (__pRequestQueue) { - for (int i = 0; i < __pPendingEventList->GetCount(); i++) + while ( __pRequestQueue->GetCount() > 0) { - PendingEvent* pEvent = null; - __pPendingEventList->GetAt(i, pEvent); - delete pEvent; + Request* pRequest = null; + __pRequestQueue->Dequeue(pRequest); + delete pRequest; } - __pPendingEventList->RemoveAll(); - delete __pPendingEventList; + delete __pRequestQueue; } IMapEnumeratorT* pMapEnum = __appWidgetContexts.GetMapEnumeratorN(); @@ -96,7 +96,7 @@ _AppContext::~_AppContext(void) } result -_AppContext::AddAppWidget(const Tizen::Base::String& userInfo, const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, int width, int height, int period, int priority) +_AppContext::AddAppWidget(const Tizen::Base::String& userInfo, const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, int width, int height, int period) { _AppWidgetContext* pAppWidgetContext = null; bool containsKey = false; @@ -111,7 +111,7 @@ _AppContext::AddAppWidget(const Tizen::Base::String& userInfo, const Tizen::Base } else { - pAppWidgetContext = new (std::nothrow)_AppWidgetContext(this, instanceId, providerId, width, height, userInfo, period, priority); + pAppWidgetContext = new (std::nothrow)_AppWidgetContext(this, instanceId, providerId, width, height, userInfo, period); SysTryReturnResult(NID_SHELL, pAppWidgetContext, E_OUT_OF_MEMORY, ""); __appWidgetContexts.Add(instanceId, pAppWidgetContext); @@ -192,7 +192,7 @@ _AppContext::GetConnectionState(void) const void _AppContext::SetConnectionState(_ConnectionState state) { - SysLog(NID_SHELL, "state transition has occurred: %ls -> %ls", GetConnectionStateString(__connectionState), GetConnectionStateString(state)); + SysSecureLog(NID_SHELL, "[%ls] state transition of has occurred: %ls -> %ls", __appId.GetPointer(), GetConnectionStateString(__connectionState), GetConnectionStateString(state)); __connectionState = state; } @@ -278,21 +278,20 @@ _AppContext::GetWaitingStatus(void) const } result -_AppContext::SendRequestToApp(const AppId& providerAppId, const String& operation, HashMap* pArgs) +_AppContext::SendRequestToApp(const AppId& providerAppId, Request* pRequest) { + SysAssert(pRequest); result r = E_SUCCESS; const _ConnectionState connectionState = GetConnectionState(); - SysLog(NID_SHELL, "Connection(%ls), Waiting response(%d)", GetConnectionStateString(connectionState), GetWaitingStatus() ? "true":"false"); + SysLog(NID_SHELL, "Connection(%ls), Waiting response(%s)", GetConnectionStateString(connectionState), GetWaitingStatus() ? "true":"false"); if (connectionState == CONNECTION_STATE_NONE || connectionState == CONNECTION_STATE_DISCONNECTED) { const _ConnectionState oldConnectionState = connectionState; SetConnectionState(CONNECTION_STATE_CONNECTING); - r = _AppWidgetRequestHelper::SendAppControlRequest(providerAppId, operation, pArgs); - pArgs->RemoveAll(true); - delete pArgs; - + r = _AppWidgetRequestHelper::SendAppControlRequest(providerAppId, pRequest->__operation, pRequest->__pArgs); + delete pRequest; SysTryCatch(NID_SHELL, !IsFailed(r), , r, "[%s] Failed to SendRequestToApp", GetErrorMessage(r)); SetWaitingStatus(true); @@ -306,14 +305,13 @@ _AppContext::SendRequestToApp(const AppId& providerAppId, const String& operatio { if (GetWaitingStatus() == true || GetConnectionState() == CONNECTION_STATE_CONNECTING) { - SysLog(NID_SHELL, "Queueing the request (%ls).", operation.GetPointer() ); - __pPendingEventList->Add(new (nothrow) PendingEvent(operation, pArgs)); + SysLog(NID_SHELL, "Queueing the request (%ls).", pRequest->__operation.GetPointer() ); + __pRequestQueue->Enqueue(pRequest); } else { - r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), operation, pArgs); - pArgs->RemoveAll(true); - delete pArgs; + r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), pRequest->__operation, pRequest->__pArgs); + delete pRequest; SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "[%s] Failed to SendRequestToApp", GetErrorMessage(r)); SetWaitingStatus(true); @@ -323,20 +321,39 @@ _AppContext::SendRequestToApp(const AppId& providerAppId, const String& operatio return E_SUCCESS; } +void +_AppContext::OnResponseReceived(const String& instanceId, bool isSucceeded) +{ + SysLog(NID_SHELL, "app(%ls) responded (%d)", __appId.GetPointer(), isSucceeded); + + if (!isSucceeded) + { + result r = DestroyAppWidget(instanceId, false); + SysTryLog(NID_SHELL, !IsFailed(r), "Failed to invoke DestroyAppWidget."); + } + + ArrayList* pArray = new (std::nothrow) ArrayList(); + SysTryReturnVoidResult(NID_SHELL, pArray, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); + pArray->Construct(); + pArray->Add(this); + + Tizen::App::App::GetInstance()->SendUserEvent(LOCAL_EVENT_REQUEST_SEND_PENDING_REQUEST, pArray); +} + result -_AppContext::SendPendingEvent(void) +_AppContext::SendPendingRequests(void) { SetWaitingStatus(false); - TryReturn(__pPendingEventList->GetCount() > 0, E_DATA_NOT_FOUND, "No pending event."); + TryReturn(__pRequestQueue->GetCount() > 0, E_DATA_NOT_FOUND, "No pending event."); - PendingEvent* pEvent = null; - __pPendingEventList->GetAt(0, pEvent); - __pPendingEventList->RemoveAt(0); - SysLog(NID_SHELL, "(%d) pending event(s) remains.", __pPendingEventList->GetCount()); + Request* pRequest = null; + __pRequestQueue->Dequeue(pRequest); + SysLog(NID_SHELL, "(%d) pending event(s) remains.", __pRequestQueue->GetCount()); - result r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), pEvent->operation, pEvent->pArgs); - delete pEvent; + result r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), pRequest->__operation, pRequest->__pArgs); + delete pRequest; SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "SendIpcRequest failed."); + SetWaitingStatus(true); return E_SUCCESS; } @@ -551,15 +568,39 @@ _AppContext::OnAppWidgetForegroundAll(void) } void -_AppContext::HandleUserEvent(Tizen::Base::Collection::IList* pArgs) +_AppContext::OnLocalEventReceived(RequestId reqId, IList* pArgs) { - _AppWidgetContext* pAppWidgetContext = dynamic_cast<_AppWidgetContext*>( pArgs->GetAt(1) ); - SysTryReturnVoidResult(NID_SHELL, pAppWidgetContext != null, E_INVALID_STATE, "_AppWidget is null!."); + SysTryReturnVoidResult(NID_SHELL, pArgs != null, E_INVALID_STATE, "pArgs is null!."); + + switch (reqId) + { + case LOCAL_EVENT_REQUEST_UPDATE: + { + _AppWidgetContext* pAppWidgetContext = dynamic_cast<_AppWidgetContext*>( pArgs->GetAt(1) ); + SysTryCatch(NID_SHELL, pAppWidgetContext != null, , E_INVALID_STATE, "[E_INVALID_STATE]"); + + String* pArgument = dynamic_cast( pArgs->GetAt(2) ); + SysTryCatch(NID_SHELL, pArgument != null, , E_INVALID_STATE, "[E_INVALID_STATE]"); + pAppWidgetContext->OnUpdate(*pArgument); + } + break; - String* pArgument = dynamic_cast( pArgs->GetAt(2) ); - SysTryReturnVoidResult(NID_SHELL, pArgument != null, E_INVALID_STATE, "pArgument is null!."); + case LOCAL_EVENT_REQUEST_SEND_PENDING_REQUEST: + { + _AppContext* pAppContext = dynamic_cast<_AppContext*>( pArgs->GetAt(0) ); + SysTryCatch(NID_SHELL, pAppContext != null, , E_INVALID_STATE, "[E_INVALID_STATE]"); + pAppContext->SendPendingRequests(); + } + break; + + default: + SysAssertf(false, "Never get here!"); + break; + } - pAppWidgetContext->OnUpdate(*pArgument); +CATCH: + pArgs->RemoveAll(); + delete pArgs; } }}} // Tizen::Shell::App diff --git a/src/FShell_AppWidgetContext.cpp b/src/FShell_AppWidgetContext.cpp index bb451e6..d00465f 100644 --- a/src/FShell_AppWidgetContext.cpp +++ b/src/FShell_AppWidgetContext.cpp @@ -28,7 +28,6 @@ #include #include #include -#include "FShell_AppWidgetManagerImpl.h" #include "FShell_AppWidgetManagerService.h" #include "FShell_AppWidgetPopupContext.h" #include "FShell_AppWidgetContext.h" @@ -66,7 +65,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& instanceId, const String& providerId, int width, int height, const Tizen::Base::String& userInfo, int period, int priority) +_AppWidgetContext::_AppWidgetContext(_AppContext* pAppContext, const String& instanceId, const String& providerId, int width, int height, const Tizen::Base::String& userInfo, int period) :__instanceId(instanceId) ,__providerId(providerId) ,__appId(_AppWidgetHelper::ExtractAppId(providerId)) @@ -74,7 +73,6 @@ _AppWidgetContext::_AppWidgetContext(_AppContext* pAppContext, const String& ins ,__userInfo(userInfo) ,__width(width) ,__height(height) - ,__priority(priority) ,__updateMillis( (period > UPDATE_PERIOD_MSEC_MIN) ? period : UPDATE_PERIOD_MSEC_MIN ) ,__ipcClientId(-1) ,__isForeground(true) @@ -86,7 +84,7 @@ _AppWidgetContext::_AppWidgetContext(_AppContext* pAppContext, const String& ins ,__pAppWidgetRemoteBuffer(null) ,__pPendingTouchEventList(null) { - SysSecureLog(NID_SHELL, "appId(%ls), providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d), period(%d)", __appId.GetPointer(), __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority, __updateMillis); + SysSecureLog(NID_SHELL, "appId(%ls), providerId(%ls), instanceId(%ls), width(%d), height(%d), period(%d)", __appId.GetPointer(), __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __updateMillis); // for updating period if (__updateMillis > 0) @@ -110,7 +108,7 @@ _AppWidgetContext::_AppWidgetContext(_AppContext* pAppContext, const String& ins _AppWidgetContext::~_AppWidgetContext(void) { - SysSecureLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", GetProviderId().GetPointer(), GetInstanceId().GetPointer(), GetWidth(), GetHeight(), GetPriority()); + SysSecureLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d)", GetProviderId().GetPointer(), GetInstanceId().GetPointer(), GetWidth(), GetHeight()); __updateTimer.Cancel(); @@ -177,7 +175,6 @@ _AppWidgetContext::OnRemoved(bool isTriggeredByViewer) void _AppWidgetContext::OnUpdate(const String& argument) { - SysLog(NID_SHELL, "argument(%ls)", argument.GetPointer()); ClearLastResult(); if (this->IsForeground()) @@ -186,7 +183,7 @@ _AppWidgetContext::OnUpdate(const String& argument) SysTryLog(NID_SHELL, !IsFailed(r), "Failed to execute SendUpdateRequest."); SystemTime::GetTicks(this->__lastUpdatedTime); - SysLog(NID_SHELL, "The last updated time is %lld.", this->__lastUpdatedTime); + SysLog(NID_SHELL, "Updated with argument(%ls), The last updated time is %lld.", argument.GetPointer(), this->__lastUpdatedTime); __hasPendingRequest = false; __pendingArgument.Clear(); @@ -200,7 +197,7 @@ _AppWidgetContext::OnUpdate(const String& argument) } __hasPendingRequest = true; - SysLog(NID_SHELL, "Update is requested but the %ls is background.", (this->GetProviderId()).GetPointer()); + SysLog(NID_SHELL, "Update pending. The %ls is background. argument(%ls), ", argument.GetPointer(), GetProviderId().GetPointer()); } } @@ -217,7 +214,7 @@ _AppWidgetContext::OnUpdateAsync(_AppContext* pAppContext, const String& argumen result r = Tizen::App::App::GetInstance()->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, GetAppId().GetPointer(), GetProviderName().GetPointer() ); + SysLog(NID_SHELL, "Local event is sent for '%ls.%ls'.", GetAppId().GetPointer(), GetProviderName().GetPointer() ); return E_SUCCESS; } @@ -315,34 +312,33 @@ result _AppWidgetContext::SendAddRequest(int width, int height) const { std::unique_ptr pArgs (CreateRequestArgsN()); - - return __pAppContext->SendRequestToApp(GetAppId(), APPWIDGET_ON_ADD, pArgs.release()); + _AppContext::Request* pRequest = new _AppContext::Request(APPWIDGET_ON_ADD, pArgs.release()); + return __pAppContext->SendRequestToApp(GetAppId(), pRequest); } result _AppWidgetContext::SendUpdateRequest(int width, int height, const String& argument) const { std::unique_ptr pArgs (CreateRequestArgsN()); - pArgs->Add(new (nothrow) String(ARG_KEY_ARGUMENT), new (nothrow) String(argument)); - - return __pAppContext->SendRequestToApp(GetAppId(), APPWIDGET_ON_UPDATE, pArgs.release()); + _AppContext::Request* pRequest = new _AppContext::Request(APPWIDGET_ON_UPDATE, pArgs.release()); + return __pAppContext->SendRequestToApp(GetAppId(), pRequest); } result _AppWidgetContext::SendResizeRequest(int width, int height) const { std::unique_ptr pArgs (CreateRequestArgsN() ); - - return __pAppContext->SendRequestToApp(GetAppId(), APPWIDGET_ON_RESIZE, pArgs.release()); + _AppContext::Request* pRequest = new _AppContext::Request(APPWIDGET_ON_RESIZE, pArgs.release()); + return __pAppContext->SendRequestToApp(GetAppId(), pRequest); } result _AppWidgetContext::SendRemoveRequest(void) const { std::unique_ptr pArgs (CreateRequestArgsN()); - - return __pAppContext->SendRequestToApp(GetAppId(), APPWIDGET_ON_REMOVE, pArgs.release()); + _AppContext::Request* pRequest = new _AppContext::Request(APPWIDGET_ON_REMOVE, pArgs.release()); + return __pAppContext->SendRequestToApp(GetAppId(), pRequest); } void @@ -390,15 +386,10 @@ _AppWidgetContext::OnTouchEventReceived(buffer_event event, double timestamp, do result _AppWidgetContext::SyncRemoteBuffer(int width, int height) { - 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(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"); + result r = __pAppWidgetRemoteBuffer->Sync(width, height, GetUserInfo()); + SysSecureTryReturnResult(NID_SHELL, !IsFailed(r) , r, "Failed to sync (%ls)", GetProviderId().GetPointer()); SendPendingTouchEvent(); - SysLog(NID_SHELL, "Done"); return E_SUCCESS; } @@ -414,13 +405,7 @@ _AppWidgetContext::SyncRemoteBufferForPD(void) const result _AppWidgetContext::SendAccessStatus(int accessStatus) const { - std::unique_ptr providerId(_StringConverter::CopyToCharArrayN(GetProviderId())); - std::unique_ptr id(_StringConverter::CopyToCharArrayN(GetInstanceId())); - - int ret = provider_send_access_status(providerId.get(), id.get(), accessStatus); - SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_access_status"); - - return E_SUCCESS; + return __pAppWidgetRemoteBuffer->SendAccessStatus(accessStatus); } Tizen::Base::Collection::HashMap* @@ -498,18 +483,6 @@ _AppWidgetContext::GetAppId(void) const return __appId; } -int -_AppWidgetContext::GetPriority(void) const -{ - return __priority; -} - -/*void -_AppWidgetContext::SetPriority(int priority) -{ - __priority = priority; -}*/ - String _AppWidgetContext::GetProviderName(void) const { diff --git a/src/FShell_AppWidgetManagerService.cpp b/src/FShell_AppWidgetManagerService.cpp index b335295..b2c3494 100644 --- a/src/FShell_AppWidgetManagerService.cpp +++ b/src/FShell_AppWidgetManagerService.cpp @@ -34,11 +34,11 @@ #include #include #include +#include #include "FShell_AppContext.h" #include "FShell_AppWidgetPopupContext.h" #include "FShell_AppWidgetManagerService.h" -#include "FShell_TemplateUtil.h" namespace Tizen { namespace Shell { namespace App { @@ -70,6 +70,7 @@ AppWidgetManagerService::~AppWidgetManagerService(void) { SysLog(NID_SHELL, "Enter"); + _AppWidgetManagerStub::StopIpcServer(); __pingTimer.Cancel(); _AppManagerImpl::GetInstance()->RemoveAppEventListener(*this); @@ -102,13 +103,13 @@ AppWidgetManagerService::InitSingleton(void) SysTryReturnVoidResult(NID_SHELL, pInstance, E_OUT_OF_MEMORY, "The memory is insufficient."); __pTheInstance = pInstance.release(); - std::atexit(DestroySingleton); } void AppWidgetManagerService::DestroySingleton(void) { delete __pTheInstance; + __pTheInstance = null; } AppWidgetManagerService* @@ -262,16 +263,26 @@ AppWidgetManagerService::OnApplicationTerminated(const AppId& appId, int pid) __appContexts.GetValue(appId, pAppContext); if (pAppContext) { - pAppContext->OnApplicationTerminated(); + if (pAppContext->GetProviderCount() == 0) + { + SysSecureLog(NID_SHELL, "The provider count for (%ls) is 0.", appId.GetPointer()); + AppWidgetManagerService::GetInstance()->RemoveAppContext(appId); + delete pAppContext; + } + else + { + pAppContext->OnApplicationTerminated(); + } } } void AppWidgetManagerService::OnIpcClientConnected(const AppId& appId, int clientId) { - SysLog(NID_SHELL, "appId(%ls)", appId.GetPointer()); + SysLog(NID_SHELL, "appId(%ls), clientId(%d)", appId.GetPointer(), clientId); - _AppContext* pAppContext = GetOrCreateAppContext(appId); + _AppContext* pAppContext = null; + __appContexts.GetValue(appId, pAppContext); if (pAppContext) { pAppContext->OnIpcConnected(clientId); @@ -330,7 +341,7 @@ AppWidgetManagerService::GetOrCreateAppContext(const AppId& appId) } result -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) +AppWidgetManagerService::AddAppWidget(const Tizen::Base::String& userInfo, const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, int width, int height, int period) { AppId appId; String providerName; @@ -339,7 +350,7 @@ AppWidgetManagerService::AddAppWidget(const Tizen::Base::String& userInfo, const _AppContext* pAppContext = GetOrCreateAppContext(appId); SysTryReturnResult(NID_SHELL, pAppContext, E_OUT_OF_MEMORY, "The memory is insufficient."); - return pAppContext->AddAppWidget(userInfo, providerId, instanceId, width, height, period, priority); + return pAppContext->AddAppWidget(userInfo, providerId, instanceId, width, height, period); } /////////////////////////////////////////////////////// @@ -352,12 +363,13 @@ AppWidgetManagerService::OnAppWidgetCreate(struct event_arg *arg, int *width, in SysSecureLog(NID_SHELL, "providerId(%s) id(%s) content(%s)", arg->pkgname, arg->id, arg->info.lb_create.content); const int MAX_LENGTH = 0xFFFF;// FUi_Control.h + const double DUMMY_PRIORITY = 1.0f;// Fixed as default *width = arg->info.lb_create.width; *height= arg->info.lb_create.height; - *priority = 1.0f;// Fixed as default + *priority = DUMMY_PRIORITY; SysAssertf(*width >= 0 && *height >= 0 && *width <= MAX_LENGTH && *height <= MAX_LENGTH, "w:%d, h:%d", *width, *height); - result r = AppWidgetManagerService::GetInstance()->AddAppWidget(arg->info.lb_create.content, arg->pkgname, arg->id, *width, *height, arg->info.lb_create.period*1000, *priority); + result r = AppWidgetManagerService::GetInstance()->AddAppWidget(arg->info.lb_create.content, arg->pkgname, arg->id, *width, *height, arg->info.lb_create.period * 1000); SysTryReturn(NID_SHELL, !IsFailed(r), -1, r, "[%s] Failed to execute AddAppWidget.", GetErrorMessage(r)); return 0; @@ -406,14 +418,6 @@ AppWidgetManagerService::OnAppWidgetDestroy(struct event_arg *arg, void* data) SysTryReturn(NID_SHELL, pAppContext != null, -1, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Failed to find _AppContext."); pAppContext->DestroyAppWidget(arg->id); - - if (pAppContext->GetProviderCount() == 0) - { - SysLog(NID_SHELL, "The provider count for (%ls) is 0.", appId.GetPointer()); - AppWidgetManagerService::GetInstance()->RemoveAppContext(appId); - delete pAppContext; - } - return 0; } @@ -422,7 +426,7 @@ AppWidgetManagerService::OnAppWidgetPopupCreate(struct event_arg *arg, void* dat { SysAssertf(arg != null && arg->type == event_arg::EVENT_PD_CREATE, "The status of data-provider-master is invalid."); - 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); + SysSecureLog(NID_SHELL, "providerId(%s), id(%s), x(%d), y(%d), width(%f), height(%f)", arg->pkgname, arg->id, arg->info.pd_create.x, arg->info.pd_create.y, arg->info.pd_create.w, arg->info.pd_create.h); _AppContext* pAppContext = AppWidgetManagerService::GetInstance()->FindAppContext(_AppWidgetHelper::ExtractAppId(arg->pkgname)); SysTryReturn(NID_SHELL, pAppContext != null, -1, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Failed to find _AppContext."); @@ -552,7 +556,7 @@ AppWidgetManagerService::OnAppWidgetPeriodChanged(struct event_arg *arg, void* d { SysAssertf(arg != null && arg->type == event_arg::EVENT_SET_PERIOD, "The status of data-provider-master is invalid."); - SysSecureLog(NID_SHELL, "providerId(%s), id(%s), width(%d), height(%d), priority(%d)", arg->pkgname, arg->id); + SysSecureLog(NID_SHELL, "providerId(%s), id(%s)", arg->pkgname, arg->id); return 0; } @@ -569,8 +573,7 @@ AppWidgetManagerService::OnAppWidgetRecreate(struct event_arg *arg, void* data) AppWidgetManagerService* pAppWidgetManagerService = AppWidgetManagerService::GetInstance(); SysTryReturn(NID_SHELL, pAppWidgetManagerService != null, -EBUSY, E_SYSTEM, "Failed to get the instance for AppWidgetManagerService."); - const double default_priority = 1.0f; - result r = pAppWidgetManagerService->AddAppWidget(arg->info.lb_recreate.content, arg->pkgname, arg->id, arg->info.lb_recreate.width, arg->info.lb_recreate.height, arg->info.lb_recreate.period * 1000, default_priority); + result r = pAppWidgetManagerService->AddAppWidget(arg->info.lb_recreate.content, arg->pkgname, arg->id, arg->info.lb_recreate.width, arg->info.lb_recreate.height, arg->info.lb_recreate.period * 1000); SysTryReturn(NID_SHELL, !IsFailed(r), -EBUSY, r, "[%s] Failed to execute AddAppWidget.", GetErrorMessage(r)); return 0; @@ -623,7 +626,7 @@ AppWidgetManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tiz { _AppContext* pAppContext = null; result r = __appContexts.GetValue(appId, pAppContext); - SysTryReturn(NID_SHELL, !IsFailed(r), null, E_OBJ_NOT_FOUND, "appId(%ls) is not found", appId.GetPointer() ); + SysTryReturnResult(NID_SHELL, !IsFailed(r), E_OBJ_NOT_FOUND, "appId(%ls) is not found", appId.GetPointer() ); return pAppContext->RequestUpdate(providerName, argument); } @@ -719,24 +722,13 @@ AppWidgetManagerService::ReleaseRemoteBufferForPD(const Tizen::App::AppId& appId } result -AppWidgetManagerService::SendResult(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, bool isSucceeded) +AppWidgetManagerService::OnResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, bool isSucceeded) { _AppContext* pAppContext = null; result r = __appContexts.GetValue(appId, pAppContext); SysTryReturnResult(NID_SHELL, !IsFailed(r), E_OBJ_NOT_FOUND, "appId(%ls) is not found.", appId.GetPointer()); - if (!isSucceeded) - { - r = pAppContext->DestroyAppWidget(instanceId, false); - SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute RemoveAppWidget."); - } - else // for pending event excluding touch event. - { - SysLog(NID_SHELL, "SendResult is called[true]."); - } - - pAppContext->SendPendingEvent(); - + pAppContext->OnResponseReceived(instanceId, isSucceeded); return E_SUCCESS; } @@ -754,28 +746,17 @@ AppWidgetManagerService::OnUserEventReceivedN(RequestId reqId, IList* pArgs) { SysTryReturnVoidResult(NID_SHELL, pArgs != null, E_INVALID_STATE, "pArgs is null!."); - SysLog(NID_SHELL, "Enter."); - switch (reqId) { case LOCAL_EVENT_REQUEST_UPDATE: - { - _AppContext* pAppContext = dynamic_cast<_AppContext*>( pArgs->GetAt(0) ); - SysTryReturnVoidResult(NID_SHELL, pAppContext != null, E_OBJ_NOT_FOUND, ""); - - pAppContext->HandleUserEvent(pArgs); - - pArgs->RemoveAll(); - delete pArgs; - } + case LOCAL_EVENT_REQUEST_SEND_PENDING_REQUEST: + _AppContext::OnLocalEventReceived(reqId, pArgs); break; default: SysAssertf(false, "Never get here!"); break; } - - SysLog(NID_SHELL, "Exit."); } // _AppWidgetHelper diff --git a/src/FShell_AppWidgetManagerStub.cpp b/src/FShell_AppWidgetManagerStub.cpp index ca37641..222ee08 100644 --- a/src/FShell_AppWidgetManagerStub.cpp +++ b/src/FShell_AppWidgetManagerStub.cpp @@ -46,15 +46,7 @@ _AppWidgetManagerStub::_AppWidgetManagerStub(void) _AppWidgetManagerStub::~_AppWidgetManagerStub(void) { - SysLog(NID_SHELL, "Enter\n"); - - if ( __pIpcServer != null) - { - __pIpcServer->Stop(); - delete __pIpcServer; - } - - SysLog(NID_SHELL, "Exit\n"); + SysLog(NID_SHELL, "Destructed."); } result @@ -75,6 +67,17 @@ CATCH: return r; } +void +_AppWidgetManagerStub::StopIpcServer(void) +{ + if ( __pIpcServer != null) + { + __pIpcServer->Stop(); + delete __pIpcServer; + __pIpcServer = null; + } +} + bool _AppWidgetManagerStub::OnRequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument, result* pRes) { @@ -150,11 +153,11 @@ _AppWidgetManagerStub::OnReleaseRemoteBufferForPD(const String& instanceId, resu } bool -_AppWidgetManagerStub::OnSendResult(const String& instanceId, bool isSucceeded) +_AppWidgetManagerStub::OnSendResponse(const String& instanceId, bool isSucceeded) { SysSecureLog(NID_SHELL, "(instanceId:%ls, data:%d)", instanceId.GetPointer(), isSucceeded); - SendResult(__pIpcServer->GetClientApplicationId(), instanceId, isSucceeded); + OnResponseReceived(__pIpcServer->GetClientApplicationId(), instanceId, isSucceeded); return true; } @@ -183,7 +186,7 @@ _AppWidgetManagerStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Messa 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_SendResult, &server, OnSendResult) + IPC_MESSAGE_HANDLER_EX(AppWidgetManager_SendResponse, &server, OnSendResponse) IPC_MESSAGE_HANDLER_EX(AppWidgetManager_SendAccessStatus, &server, OnSendAccessStatus) IPC_END_MESSAGE_MAP() } diff --git a/src/FShell_AppWidgetPopupContext.cpp b/src/FShell_AppWidgetPopupContext.cpp index f9153b0..146dc8e 100644 --- a/src/FShell_AppWidgetPopupContext.cpp +++ b/src/FShell_AppWidgetPopupContext.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -49,7 +48,7 @@ const wchar_t APPWIDGET_POPUP_ON_TOUCH[] = L"http://tizen.org/appcontrol/appwidg _AppWidgetPopupContext::_AppWidgetPopupContext(const _AppWidgetContext* pParent) : __pParent(pParent) { - __pAppWidgetRemoteBuffer = new (nothrow) _AppWidgetRemoteBuffer(__pParent->GetProviderId(), __pParent->GetInstanceId(), TYPE_PD, this); + __pAppWidgetRemoteBuffer = new (nothrow) _AppWidgetRemoteBuffer(__pParent->GetProviderId(), __pParent->GetInstanceId(), TYPE_PD, this, true); SysTryReturnVoidResult(NID_SHELL, __pAppWidgetRemoteBuffer, E_OUT_OF_MEMORY, ""); SysLog(NID_SHELL, "The drop view for %ls is constructed.", (__pParent->GetInstanceId()).GetPointer()); @@ -87,7 +86,8 @@ _AppWidgetPopupContext::SendPopupCreateRequest(double x, double y, int width, in pArgs->Add(new String(ARG_KEY_POPUP_WIDTH), new String(Integer::ToString(width))); pArgs->Add(new String(ARG_KEY_POPUP_HEIGHT), new String(Integer::ToString(height))); - return __pParent->GetAppContext()->SendRequestToApp(__pParent->GetAppId(), APPWIDGET_POPUP_ON_CREATE, pArgs.release()); + _AppContext::Request* pRequest = new _AppContext::Request(APPWIDGET_POPUP_ON_CREATE, pArgs.release()); + return __pParent->GetAppContext()->SendRequestToApp(__pParent->GetAppId(), pRequest); } result @@ -95,7 +95,8 @@ _AppWidgetPopupContext::SendPopupDestroyRequest(void) { std::unique_ptr pArgs (__pParent->CreateRequestArgsN() ); - return __pParent->GetAppContext()->SendRequestToApp(__pParent->GetAppId(), APPWIDGET_POPUP_ON_DESTROY, pArgs.release()); + _AppContext::Request* pRequest = new _AppContext::Request(APPWIDGET_POPUP_ON_DESTROY, pArgs.release()); + return __pParent->GetAppContext()->SendRequestToApp(__pParent->GetAppId(), pRequest); } void @@ -108,13 +109,7 @@ _AppWidgetPopupContext::OnTouchEventReceived(buffer_event event, double timestam result _AppWidgetPopupContext::SyncRemoteBuffer(void) { - std::unique_ptr providerId(_StringConverter::CopyToCharArrayN(__pParent->GetProviderId())); - std::unique_ptr id(_StringConverter::CopyToCharArrayN(__pParent->GetInstanceId())); - - 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"); + __pAppWidgetRemoteBuffer->SyncPopup(); return E_SUCCESS; } diff --git a/src/FShell_AppWidgetRemoteBuffer.cpp b/src/FShell_AppWidgetRemoteBuffer.cpp index 40baeec..0a116d1 100644 --- a/src/FShell_AppWidgetRemoteBuffer.cpp +++ b/src/FShell_AppWidgetRemoteBuffer.cpp @@ -72,7 +72,7 @@ using namespace std; using namespace Tizen::Base; using namespace Tizen::Base::Runtime; -_AppWidgetRemoteBuffer::_AppWidgetRemoteBuffer(const String& providerId, const String& instanceId, target_type type, _IAppWidgetRemoteBufferEventListener* pListener) +_AppWidgetRemoteBuffer::_AppWidgetRemoteBuffer(const String& providerId, const String& instanceId, target_type type, _IAppWidgetRemoteBufferEventListener* pListener, bool isPopup) :__type(type) ,__providerId(providerId) ,__instanceId(instanceId) @@ -80,6 +80,7 @@ _AppWidgetRemoteBuffer::_AppWidgetRemoteBuffer(const String& providerId, const S ,__buffer_info(null) ,__pListener(pListener) ,__mutex() + ,__isPopup(isPopup) { __mutex.Create(); SysLog(NID_SHELL, "_AppWidgetRemoteBuffer is constructed."); @@ -152,6 +153,49 @@ _AppWidgetRemoteBuffer::Release(void) return E_SUCCESS; } +result +_AppWidgetRemoteBuffer::Sync(int width, int height, const String& contentInfo) const +{ + SysAssert(__isPopup == false); + const double DUMMY_PRIORITY = 1.0f;// Fixed as default + + std::unique_ptr providerId(_StringConverter::CopyToCharArrayN(__providerId)); + std::unique_ptr id(_StringConverter::CopyToCharArrayN(__instanceId)); + std::unique_ptr content_info(_StringConverter::CopyToCharArrayN(contentInfo)); + + int ret = provider_send_updated(providerId.get(), id.get(), width, height, DUMMY_PRIORITY, content_info.get(), null); + SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated"); + + SysLog(NID_SHELL, "Done"); + return E_SUCCESS; +} + +result +_AppWidgetRemoteBuffer::SyncPopup(void) const +{ + SysAssert(__isPopup == true); + std::unique_ptr providerId(_StringConverter::CopyToCharArrayN(__providerId)); + std::unique_ptr id(_StringConverter::CopyToCharArrayN(__instanceId)); + + int ret = provider_send_desc_updated(providerId.get(), id.get(), null); + SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_desc_updated"); + + SysLog(NID_SHELL, "Done"); + return E_SUCCESS; +} + +result +_AppWidgetRemoteBuffer::SendAccessStatus(int accessStatus) const +{ + std::unique_ptr providerId(_StringConverter::CopyToCharArrayN(__providerId)); + std::unique_ptr id(_StringConverter::CopyToCharArrayN(__instanceId)); + + int ret = provider_send_access_status(providerId.get(), id.get(), accessStatus); + SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_access_status"); + + return E_SUCCESS; +} + }}} // Tizen::Shell::App static int AppWidgetHandleBufferEventCallback(struct livebox_buffer *info, enum buffer_event event, double timestamp, double x, double y, void* data) diff --git a/src/OspAppWidgetService.cpp b/src/OspAppWidgetService.cpp index d14cc14..dad4705 100644 --- a/src/OspAppWidgetService.cpp +++ b/src/OspAppWidgetService.cpp @@ -70,6 +70,7 @@ OspAppWidgetService::OnAppWillTerminate(void) bool OspAppWidgetService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) { + AppWidgetManagerService::DestroySingleton(); return true; } @@ -95,7 +96,6 @@ OspAppWidgetService::OnAppControlRequestReceived(RequestId reqId, const Tizen::B return; } - AppWidgetManagerService* pSvc = null; String coreDaemonId = "osp-appwidget-service"; if (pExtraData) { @@ -109,7 +109,7 @@ OspAppWidgetService::OnAppControlRequestReceived(RequestId reqId, const Tizen::B } std::unique_ptr pIdForCoreDaemon(_StringConverter::CopyToCharArrayN(coreDaemonId)); - pSvc = AppWidgetManagerService::CreateInstance(pIdForCoreDaemon.get()); + AppWidgetManagerService* pSvc = AppWidgetManagerService::CreateInstance(pIdForCoreDaemon.get()); AppAssertf(pSvc != null, "AppWidgetManagerService::GetInstance() failed."); isServiceCreated = true; } -- 2.7.4