From 34ea8805c286ff6f25679b06f33e8ceee38c2d9f Mon Sep 17 00:00:00 2001 From: "kyeongwoo.lee" Date: Thu, 13 Jun 2013 22:35:02 +0900 Subject: [PATCH] add new features Change-Id: Ib41aecee505dc654883d5deb8bb19fe15c5ea69c --- inc/FShell_AppWidgetContext.h | 14 ++++ inc/FShell_AppWidgetContextBase.h | 33 +++++----- inc/FShell_AppWidgetManagerService.h | 9 ++- inc/FShell_AppWidgetManagerStub.h | 6 ++ src/FShell_AppWidgetContext.cpp | 114 +++++++++++++++++++++++++++++---- src/FShell_AppWidgetContextBase.cpp | 50 ++++++++++----- src/FShell_AppWidgetManagerService.cpp | 90 ++++++++++++++++++++++++-- src/FShell_AppWidgetManagerStub.cpp | 15 ++++- 8 files changed, 278 insertions(+), 53 deletions(-) diff --git a/inc/FShell_AppWidgetContext.h b/inc/FShell_AppWidgetContext.h index e37b215..e20f9f1 100644 --- a/inc/FShell_AppWidgetContext.h +++ b/inc/FShell_AppWidgetContext.h @@ -63,9 +63,11 @@ public: virtual result SendTouchEvent(buffer_event event, double timestamp, double x, double y); result RequestUpdateRemote(int width, int height); + result SendPendingEvent(void); int GetPeriod(void) const; long long GetLastUpdatedTime(void) const; + virtual void SetIpcClientId(int clientId); private: result SendAddRequest(int width, int height); @@ -74,6 +76,7 @@ private: result SendRemoveRequest(void); result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); void SendPendingTouchEvent(void); + result RequestUpdate(const Tizen::Base::String& argument); virtual Tizen::Base::Collection::HashMap* CreateRequestArgsN(void); virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); @@ -89,12 +92,23 @@ private: double y; }; + struct PendingEvent + { + PendingEvent(const Tizen::Base::String& instanceId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pHashMap) + : instanceId(instanceId), operation(operation), pArg(pHashMap) { } + + Tizen::Base::String instanceId; + Tizen::Base::String operation; + Tizen::Base::Collection::HashMap* pArg; + }; + private: _AppWidgetPopupContext* __pAppWidgetPopup; Tizen::Base::Runtime::Timer __updateTimer; int __updateMillis; long long __lastUpdatedTime; Tizen::Base::Collection::ArrayListT* __pPendingTouchEventList; + Tizen::Base::Collection::ArrayListT* __pPendingEventList; Tizen::Base::String __pendingArgument; bool __hasPendingRequest; diff --git a/inc/FShell_AppWidgetContextBase.h b/inc/FShell_AppWidgetContextBase.h index 2400eb6..524fead 100644 --- a/inc/FShell_AppWidgetContextBase.h +++ b/inc/FShell_AppWidgetContextBase.h @@ -54,7 +54,8 @@ public: virtual void OnPopupCreated(double x, double y, int width, int height) = 0; virtual void OnPopupDestoyed(void) = 0; virtual result SendTouchEvent(buffer_event event, double timestamp, double x, double y) = 0; - void SetIpcClientId(int clientId); + //virtual result SendPendingEvent(void) = 0; + virtual void SetIpcClientId(int clientId); int GetClientId(void) const; bool HasValidClientId(void) const; // for buffered appWidget @@ -68,16 +69,16 @@ public: Tizen::Base::String GetAppId(void) const; int GetPriority(void) const; Tizen::Base::String GetProviderName(void) const; + bool IsRunning(void) const; protected: - bool IsRunning(void) const; bool IsSharedMemCreated(void) const; virtual Tizen::Base::Collection::HashMap* CreateRequestArgsN(void) = 0; result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); + result SendRequestToApp(const int clientId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); void SetForeground(bool forground); bool IsForeground(void) const; Tizen::Base::String GetUserInfo(void) const; - void SetWidth(int width); void SetHeight(int height); @@ -103,20 +104,22 @@ class _AppWidgetRequestHelper { public: static result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); + static result SendRequestToApp(const int clientId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); + }; // class _AppWidgetRequestHelper -extern const wchar_t ARG_KEY_INSTANCE_ID[]; -extern const wchar_t ARG_KEY_PROVIDER_NAME[]; -extern const wchar_t ARG_KEY_USER_INFO[]; -extern const wchar_t ARG_KEY_X[]; -extern const wchar_t ARG_KEY_Y[]; -extern const wchar_t ARG_KEY_WIDTH[]; -extern const wchar_t ARG_KEY_HEIGHT[]; -extern const wchar_t ARG_KEY_POPUP_WIDTH[]; -extern const wchar_t ARG_KEY_POPUP_HEIGHT[]; -extern const wchar_t ARG_KEY_ARGUMENT[]; -extern const wchar_t ARG_KEY_EVENT_TYPE[]; -extern const wchar_t ARG_KEY_TIME_STAMP[]; +extern const Tizen::Base::String ARG_KEY_INSTANCE_ID; +extern const Tizen::Base::String ARG_KEY_PROVIDER_NAME; +extern const Tizen::Base::String ARG_KEY_USER_INFO; +extern const Tizen::Base::String ARG_KEY_X; +extern const Tizen::Base::String ARG_KEY_Y; +extern const Tizen::Base::String ARG_KEY_WIDTH; +extern const Tizen::Base::String ARG_KEY_HEIGHT; +extern const Tizen::Base::String ARG_KEY_POPUP_WIDTH; +extern const Tizen::Base::String ARG_KEY_POPUP_HEIGHT; +extern const Tizen::Base::String ARG_KEY_ARGUMENT; +extern const Tizen::Base::String ARG_KEY_EVENT_TYPE; +extern const Tizen::Base::String ARG_KEY_TIME_STAMP; }}} // Tizen::Shell::App diff --git a/inc/FShell_AppWidgetManagerService.h b/inc/FShell_AppWidgetManagerService.h index 7c3f0a6..fcd3dcc 100644 --- a/inc/FShell_AppWidgetManagerService.h +++ b/inc/FShell_AppWidgetManagerService.h @@ -46,13 +46,15 @@ public: static AppWidgetManagerService* CreateInstance(const char* pServiceIdForCoreDaemon); result AddAppWidget(_AppWidgetContext* pAppWidget); result RemoveAppWidget(const char* pPackageName, const char* pId, bool free); + int Find(const Tizen::App::AppId& appId) const; + result RequestUpdate(_AppWidgetContext* pAppWidgetContext, const Tizen::Base::String& argument); private: result Construct(const char* pServiceIdForCoreDaemon); result InitializeCoreDaemonEventReceiver(const char* pServiceIdForCoreDaemon); result DeinitializeCoreDaemonEventReceiver(void); - // master daemon callbacks + // core daemon callbacks static int AppWidgetConnected(struct event_arg *arg, void* data); static int AppWidgetDisconnected(struct event_arg *arg, void* data); static int OnAppWidgetCreate(struct event_arg *arg, int *width, int *height, double *priority, void* data); @@ -84,6 +86,7 @@ private: AppWidgetManagerService(void); virtual ~AppWidgetManagerService(void); + // ipc virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId); virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId); @@ -93,8 +96,9 @@ private: void StartPingTimer(void); virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); + _AppWidgetContext* Find(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) const; - int Find(const Tizen::App::AppId& appId) const; + result RequestPendingEvent(void); class _TaskHandlerThread : public Tizen::Base::Runtime::Thread @@ -110,6 +114,7 @@ private: Tizen::Base::Collection::ArrayListT<_AppWidgetContext*> __appWidgetContextList; 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 5c81fae..fde5e57 100644 --- a/inc/FShell_AppWidgetManagerStub.h +++ b/inc/FShell_AppWidgetManagerStub.h @@ -27,6 +27,11 @@ #include #include +namespace Tizen { namespace Base { namespace Collection +{ +class HashMap; +}}} + namespace Tizen { namespace Shell { namespace App { /** @@ -41,6 +46,7 @@ class _AppWidgetManagerStub { public: + bool SendAppWidgetEvent(const int clientId, const Tizen::Base::String& instanceId, const Tizen::Base::String& operationId, Tizen::Base::Collection::HashMap* pArgs); bool SendTouchEvent(const int clientId, const Tizen::Base::String& instanceId, int eventType, double timestamp, double x, double y); bool SendTouchEventForPD(const int clientId, const Tizen::Base::String& instanceId, int eventType, double timestamp, double x, double y); diff --git a/src/FShell_AppWidgetContext.cpp b/src/FShell_AppWidgetContext.cpp index df7a73a..be1c53d 100644 --- a/src/FShell_AppWidgetContext.cpp +++ b/src/FShell_AppWidgetContext.cpp @@ -43,11 +43,11 @@ using namespace Tizen::Base; using namespace Tizen::Base::Collection; using namespace Tizen::System; -const wchar_t APPWIDGET_ON_ADD[] = L"http://tizen.org/appcontrol/appwidget/add"; -const wchar_t APPWIDGET_ON_REMOVE[] = L"http://tizen.org/appcontrol/appwidget/remove"; -const wchar_t APPWIDGET_ON_UPDATE[] = L"http://tizen.org/appcontrol/appwidget/update"; -const wchar_t APPWIDGET_ON_RESIZE[] = L"http://tizen.org/appcontrol/appwidget/resize"; -const wchar_t APPWIDGET_ON_TOUCH[] = L"http://tizen.org/appcontrol/appwidget/touch"; +const String APPWIDGET_ON_ADD = L"http://tizen.org/appcontrol/appwidget/add"; +const String APPWIDGET_ON_REMOVE = L"http://tizen.org/appcontrol/appwidget/remove"; +const String APPWIDGET_ON_UPDATE = L"http://tizen.org/appcontrol/appwidget/update"; +const String APPWIDGET_ON_RESIZE = L"http://tizen.org/appcontrol/appwidget/resize"; +const String APPWIDGET_ON_TOUCH = L"http://tizen.org/appcontrol/appwidget/touch"; const int UPDATE_PERIOD_MSEC_MIN = 1800000; // 30min @@ -57,6 +57,7 @@ _AppWidgetContext::_AppWidgetContext(const String& info, const String& providerI ,__updateMillis(period) ,__lastUpdatedTime(0) ,__pPendingTouchEventList(null) + ,__pPendingEventList(null) , __hasPendingRequest(false) { if (__updateMillis > 0) @@ -72,6 +73,11 @@ _AppWidgetContext::_AppWidgetContext(const String& info, const String& providerI __pPendingTouchEventList = new ArrayListT(); __pPendingTouchEventList->Construct(); + + __pPendingEventList = new ArrayListT(); + __pPendingEventList->Construct(); + + } _AppWidgetContext::~_AppWidgetContext(void) @@ -98,6 +104,18 @@ _AppWidgetContext::~_AppWidgetContext(void) __pPendingTouchEventList->RemoveAll(); delete __pPendingTouchEventList; } + + if (__pPendingEventList) + { + for (int i = 0; i < __pPendingEventList->GetCount(); i++) + { + PendingEvent* pEvent = null; + __pPendingEventList->GetAt(i, pEvent); + delete pEvent; + } + __pPendingEventList->RemoveAll(); + delete __pPendingEventList; + } } _AppWidgetPopupContext* @@ -140,7 +158,8 @@ _AppWidgetContext::OnUpdate(const String& argument) } else { - this->SendUpdateRequest(GetWidth(), GetHeight(), argument); + result r = this->SendUpdateRequest(GetWidth(), GetHeight(), 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); @@ -161,10 +180,22 @@ _AppWidgetContext::OnResize(int width, int height) SendResizeRequest(width, height); } +result +_AppWidgetContext::RequestUpdate(const String& argument) +{ + AppWidgetManagerService* pMgrService = AppWidgetManagerService::GetInstance(); + SysTryReturnResult(NID_SHELL, pMgrService, E_SYSTEM, "[E_SYSTEM] Failed to get an instance of AppWidgetManagerService."); + + result r = pMgrService->RequestUpdate(this, argument); + SysTryReturnResult(NID_SHELL, !IsFailed(r), r, "Failed to request update."); + + return r; +} + void _AppWidgetContext::OnForeground(void) { - SysLog(NID_SHELL, "OnForeground"); + SysLog(NID_SHELL, "I"); if (!IsPaused()) { @@ -176,7 +207,7 @@ _AppWidgetContext::OnForeground(void) if (__hasPendingRequest == true) { - OnUpdate(__pendingArgument); + RequestUpdate(__pendingArgument); } else { @@ -192,10 +223,12 @@ _AppWidgetContext::OnForeground(void) if (isPeriodExpired) { SysLog(NID_SHELL, "The period is expired."); - OnUpdate(L""); + RequestUpdate(L""); } } } + + SysLog(NID_SHELL, "O"); } void @@ -243,7 +276,7 @@ _AppWidgetContext::SendAddRequest(int width, int height) { std::unique_ptr pArgs (CreateRequestArgsN()); - return SendRequestToApp(GetAppId(), APPWIDGET_ON_ADD, pArgs.get()); + return SendRequestToApp(GetAppId(), APPWIDGET_ON_ADD, pArgs.release()); } result @@ -253,7 +286,7 @@ _AppWidgetContext::SendUpdateRequest(int width, int height, const String& argume pArgs->Add(new String(ARG_KEY_ARGUMENT), new String(argument)); - return SendRequestToApp(GetAppId(), APPWIDGET_ON_UPDATE, pArgs.get()); + return SendRequestToApp(GetAppId(), APPWIDGET_ON_UPDATE, pArgs.release()); } result @@ -261,7 +294,7 @@ _AppWidgetContext::SendResizeRequest(int width, int height) { std::unique_ptr pArgs (CreateRequestArgsN() ); - return SendRequestToApp(GetAppId(), APPWIDGET_ON_RESIZE, pArgs.get()); + return SendRequestToApp(GetAppId(), APPWIDGET_ON_RESIZE, pArgs.release()); } result @@ -269,7 +302,29 @@ _AppWidgetContext::SendRemoveRequest(void) { std::unique_ptr pArgs (CreateRequestArgsN()); - return SendRequestToApp(GetAppId(), APPWIDGET_ON_REMOVE, pArgs.get()); + return SendRequestToApp(GetAppId(), APPWIDGET_ON_REMOVE, pArgs.release()); +} + +result +_AppWidgetContext::SendPendingEvent(void) +{ + SysTryReturnResult(NID_SHELL, __pPendingEventList->GetCount() > 0 , E_SUCCESS, "There is no pending event."); + + PendingEvent* pEvent = null; + __pPendingEventList->GetAt(0, pEvent); + + if (pEvent != null) + { + SysLog(NID_SHELL, "SendPendingEvent by IPC [%d existed.]", __pPendingEventList->GetCount()); + _AppWidgetRequestHelper::SendRequestToApp(GetClientId(), pEvent->operation, pEvent->pArg); + __pPendingEventList->RemoveAt(0); + } + else + { + SysLog(NID_SHELL, "SendPendingEvent by IPC [0 existed.]"); + } + + return E_SUCCESS; } void @@ -318,7 +373,31 @@ _AppWidgetContext::SendTouchEvent(buffer_event eventType, double timeStamp, doub result _AppWidgetContext::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) { - return _AppWidgetContextBase::SendRequestToApp(appId, operation, pArgs); + result r = E_SUCCESS; + + if (AppManager::GetInstance()->IsRunning(appId) == false) + { + SysLog(NID_SHELL, "The application is not running."); + return _AppWidgetContextBase::SendRequestToApp(appId, operation, pArgs); + } + else + { + if(!HasValidClientId()) + { + SysLog(NID_SHELL, "The application is running but IPC is not connected yet."); + __pPendingEventList->Add(new PendingEvent(*new String(GetInstanceId()), *new String(operation), pArgs)); + } + else + { + SysLog(NID_SHELL, "The application is running and IPC is connected."); + r = _AppWidgetRequestHelper::SendRequestToApp(GetClientId(), operation, pArgs); + +// pArgs->RemoveAll(true); +// delete pArgs; + } + } + + return E_SUCCESS; } result @@ -341,6 +420,7 @@ _AppWidgetContext::CreateRequestArgsN(void) { HashMap* pArgs = new (std::nothrow) HashMap(SingleObjectDeleter); pArgs->Construct(); + pArgs->Add(new String(ARG_KEY_INSTANCE_ID), new String(GetInstanceId())); pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(GetProviderName())); pArgs->Add(new String(ARG_KEY_USER_INFO), new String(GetUserInfo())); @@ -364,6 +444,12 @@ _AppWidgetContext::GetLastUpdatedTime(void) const } void +_AppWidgetContext::SetIpcClientId(int clientId) +{ + _AppWidgetContextBase::SetIpcClientId(clientId); +} + +void _AppWidgetContext::OnTimerExpired(Tizen::Base::Runtime::Timer& timer) { if (&timer == &__updateTimer) diff --git a/src/FShell_AppWidgetContextBase.cpp b/src/FShell_AppWidgetContextBase.cpp index df7a9ba..3934ec5 100644 --- a/src/FShell_AppWidgetContextBase.cpp +++ b/src/FShell_AppWidgetContextBase.cpp @@ -31,6 +31,7 @@ #include #include "FShell_AppWidgetManagerImpl.h" #include "FShell_AppWidgetContextBase.h" +#include "FShell_AppWidgetManagerService.h" // provider/src/fb.c struct fb_info { @@ -78,18 +79,18 @@ using namespace Tizen::App; using namespace Tizen::Base; using namespace Tizen::Base::Collection; -const wchar_t ARG_KEY_INSTANCE_ID[] = L"_InstanceId"; -const wchar_t ARG_KEY_PROVIDER_NAME[] = L"_ProviderName"; -const wchar_t ARG_KEY_USER_INFO[] = L"_UserInfo"; -const wchar_t ARG_KEY_X[] = L"_X"; -const wchar_t ARG_KEY_Y[] = L"_Y"; -const wchar_t ARG_KEY_WIDTH[] = L"_Width"; -const wchar_t ARG_KEY_HEIGHT[] = L"_Height"; -const wchar_t ARG_KEY_POPUP_WIDTH[] = L"_PopupWidth"; -const wchar_t ARG_KEY_POPUP_HEIGHT[] = L"_PopupHeight"; -const wchar_t ARG_KEY_ARGUMENT[] = L"_Argument"; -const wchar_t ARG_KEY_EVENT_TYPE[] = L"_EventType"; -const wchar_t ARG_KEY_TIME_STAMP[] = L"_TimeStamp"; +extern const String ARG_KEY_INSTANCE_ID = L"_InstanceId"; +extern const String ARG_KEY_PROVIDER_NAME = L"_ProviderName"; +extern const String ARG_KEY_USER_INFO = L"_UserInfo"; +extern const String ARG_KEY_X = L"_X"; +extern const String ARG_KEY_Y = L"_Y"; +extern const String ARG_KEY_WIDTH = L"_Width"; +extern const String ARG_KEY_HEIGHT = L"_Height"; +extern const String ARG_KEY_POPUP_WIDTH = L"_PopupWidth"; +extern const String ARG_KEY_POPUP_HEIGHT = L"_PopupHeight"; +extern const String ARG_KEY_ARGUMENT = L"_Argument"; +extern const String ARG_KEY_EVENT_TYPE = L"_EventType"; +extern const String ARG_KEY_TIME_STAMP = L"_TimeStamp"; _AppWidgetContextBase::_AppWidgetContextBase(target_type type, const String& userInfo, const String& providerId, const String& instanceId, int width, int height, int priority) :__type(type) @@ -211,7 +212,10 @@ _AppWidgetContextBase::ReleaseSharedMem(void) result _AppWidgetContextBase::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) { - return _AppWidgetRequestHelper::SendRequestToApp(appId, operation, pArgs); + result r = _AppWidgetRequestHelper::SendRequestToApp(appId, operation, pArgs); + SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to SendRequestToApp"); + + return r; } String @@ -295,7 +299,10 @@ _AppWidgetContextBase::SetHeight(int height) result _AppWidgetRequestHelper::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) { - SysLog(NID_SHELL, "appId(%ls), operation(%ls), arg count(%d)", appId.GetPointer(), operation.GetPointer(), pArgs->GetCount() ); + const String* pInstanceId = dynamic_cast(pArgs->GetValue(ARG_KEY_INSTANCE_ID)); + SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_INSTANCE_ID.GetPointer() ); + + SysSecureLog(NID_SHELL, "[ac] pInstanceId(%ls), operation(%ls), appId(%ls), arg count(%d)", pInstanceId->GetPointer(), operation.GetPointer(), appId.GetPointer(), pArgs->GetCount()); _AppMessageImpl msg; msg.AddData(OSP_K_APPCONTROL_INTERNAL_OPERATION, L"appwidget"); @@ -304,7 +311,6 @@ _AppWidgetRequestHelper::SendRequestToApp(const AppId& appId, const String& oper std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId) ); std::unique_ptr pOperation(_StringConverter::CopyToCharArrayN(operation) ); - const int TRY_COUNT = 3; const int TRY_SLEEP_TIME = 65; @@ -332,6 +338,20 @@ _AppWidgetRequestHelper::SendRequestToApp(const AppId& appId, const String& oper return r; } +result +_AppWidgetRequestHelper::SendRequestToApp(const int clientId, const String& operation, HashMap* pArgs) +{ + const String* pInstanceId = dynamic_cast(pArgs->GetValue(ARG_KEY_INSTANCE_ID)); + SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_INSTANCE_ID.GetPointer() ); + + SysSecureLog(NID_SHELL, "[ipc] pInstanceId(%ls), operation(%ls), clientId(%d)", pInstanceId->GetPointer(), operation.GetPointer(), clientId); + + bool sendResult = AppWidgetManagerService::GetInstance()->SendAppWidgetEvent(clientId, *pInstanceId, operation, pArgs); + SysTryReturnResult(NID_SHELL, sendResult, E_FAILURE, "Propagated."); + + return E_SUCCESS; +} + }}} // Tizen::Shell::App //////////////////////////////////////////// diff --git a/src/FShell_AppWidgetManagerService.cpp b/src/FShell_AppWidgetManagerService.cpp index 3dd150d..327f2ba 100644 --- a/src/FShell_AppWidgetManagerService.cpp +++ b/src/FShell_AppWidgetManagerService.cpp @@ -48,6 +48,7 @@ static const RequestId LOCAL_EVENT_REQUEST_UPDATE = 0; } extern const int UPDATE_PERIOD_MSEC_MIN; +const wchar_t INVALID_INSTANCE[] = L"file://invalid instance id"; AppWidgetManagerService* AppWidgetManagerService::__pTheInstance = null; @@ -394,7 +395,7 @@ AppWidgetManagerService::OnAppWidgetPause(struct event_arg *arg, void* data) int AppWidgetManagerService::OnAppWidgetPauseAll(struct event_arg *arg, void* data) { - SysLog(NID_SHELL, "OnAppWidgetPauseAll"); + SysLog(NID_SHELL, "I"); AppWidgetManagerService* pAppManagerService = AppWidgetManagerService::GetInstance(); @@ -406,6 +407,7 @@ AppWidgetManagerService::OnAppWidgetPauseAll(struct event_arg *arg, void* data) pAppWidgetContext->OnBackground(); } + SysLog(NID_SHELL, "O"); return 0; } @@ -425,7 +427,7 @@ AppWidgetManagerService::OnAppWidgetResume(struct event_arg *pArg, void* pData) int AppWidgetManagerService::OnAppWidgetResumeAll(struct event_arg *pArg, void* pData) { - SysLog(NID_SHELL, "OnAppWidgetResumeAll"); + SysLog(NID_SHELL, "I"); AppWidgetManagerService* pAppManagerService = AppWidgetManagerService::GetInstance(); @@ -437,6 +439,7 @@ AppWidgetManagerService::OnAppWidgetResumeAll(struct event_arg *pArg, void* pDat pAppWidgetContext->OnForeground(); } + SysLog(NID_SHELL, "O"); return 0; } @@ -587,6 +590,31 @@ AppWidgetManagerService::RequestUpdate(const Tizen::App::AppId& appId, const Tiz return (found) ? E_SUCCESS : E_OBJ_NOT_FOUND; } +// for resuming +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 + { + SysLog(NID_SHELL, "pAppWidgetContext is null."); + } + + SysLog(NID_SHELL, "O"); + return E_SUCCESS; +} + result AppWidgetManagerService::RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument) { @@ -685,10 +713,29 @@ AppWidgetManagerService::RequestReleaseSharedMemoryForPD(const Tizen::App::AppId result AppWidgetManagerService::SendResult(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, bool isSucceeded) { + _AppWidgetContext* pAppWidgetContext = null; + if (!isSucceeded) { - _AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId); - SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext, E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer()); + SysLog(NID_SHELL, "SendResult is called[false]."); + + if (instanceId == INVALID_INSTANCE) + { + for (int i = 0; i < __appWidgetContextList.GetCount(); i++) + { + __appWidgetContextList.GetAt(i, pAppWidgetContext); + + if (!pAppWidgetContext->IsRunning()) + { + break; + } + } + } + else + { + pAppWidgetContext = this->Find(appId, 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 id(_StringConverter::CopyToCharArrayN(pAppWidgetContext->GetInstanceId())); @@ -697,15 +744,46 @@ AppWidgetManagerService::SendResult(const Tizen::App::AppId& appId, const Tizen: SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "Failed to execute provider_send_deleted."); result r = pAppWidgetContext->OnRemoved(); - SysTryReturn(NID_SHELL, !IsFailed(r), 0, E_SYSTEM, "[E_SYSTEM] Failed to execute OnRemoved."); + SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute OnRemoved."); r = RemoveAppWidget(packageName.get(), id.get(), true); - SysTryReturn(NID_SHELL, !IsFailed(r), 0, E_SYSTEM, "[E_SYSTEM] Failed to execute RemoveAppWidget."); + SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to execute RemoveAppWidget."); + + RequestPendingEvent(); + } + else // for pending event excluding touch event. + { + SysLog(NID_SHELL, "SendResult is called[true]."); + + pAppWidgetContext = this->Find(appId, instanceId); + + if (pAppWidgetContext) + { + SysLog(NID_SHELL, "AppWidgetContext for %ls exists.", instanceId.GetPointer()); + RequestPendingEvent(); + } + else + { + SysLog(NID_SHELL, "AppWidgetContext for %ls is empty.", instanceId.GetPointer()); + } } return E_SUCCESS; } +result +AppWidgetManagerService::RequestPendingEvent(void) +{ + for (int i = 0; i < __appWidgetContextList.GetCount(); i++ ) + { + _AppWidgetContext* pAppWidgetContext = null; + __appWidgetContextList.GetAt(i, pAppWidgetContext); + + pAppWidgetContext->SendPendingEvent(); + } + + return E_SUCCESS; +} AppWidgetManagerService::_TaskHandlerThread::~_TaskHandlerThread(void) { diff --git a/src/FShell_AppWidgetManagerStub.cpp b/src/FShell_AppWidgetManagerStub.cpp index 362bb7f..95e0488 100644 --- a/src/FShell_AppWidgetManagerStub.cpp +++ b/src/FShell_AppWidgetManagerStub.cpp @@ -20,6 +20,7 @@ */ #include +#include #include #include "FShell_AppWidgetManagerIpcMessage.h" #include "FShell_AppWidgetManagerStub.h" @@ -33,6 +34,7 @@ const int INVALID_CLIENT_ID = -1; }; using namespace Tizen::Base; +using namespace Tizen::Base::Collection; using namespace Tizen::Io; using namespace Tizen::Text; using namespace Tizen::Security; @@ -164,11 +166,22 @@ _AppWidgetManagerStub::OnSendResult(const String& instanceId, bool isSucceeded) } bool +_AppWidgetManagerStub::SendAppWidgetEvent(const int clientId, const String& instanceId, const String& operationId, HashMap* pArgs) +{ + SysLog(NID_SHELL, "The operation type is %ls", operationId.GetPointer()); + result r = __pIpcServer->SendResponse(clientId, new AppWidgetManager_SendAppWidgetEvent(instanceId, operationId, *pArgs)); + SysTryReturn(NID_SHELL, !IsFailed(r), false, r, "[%s] Propagated.", GetErrorMessage(r)); + + return true; +} + +bool _AppWidgetManagerStub::SendTouchEvent(const int clientId, const String& instanceId, int eventType, double timestamp, double x, double y) { SysLog(NID_SHELL,""); result r = __pIpcServer->SendResponse(clientId, new AppWidgetManager_SendTouchEvent(instanceId, eventType, timestamp, x, y)); SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r)); + return true; } @@ -177,7 +190,7 @@ _AppWidgetManagerStub::SendTouchEventForPD(const int clientId, const String& ins { SysLog(NID_SHELL,""); result r = __pIpcServer->SendResponse(clientId, new AppWidgetManager_SendTouchEventForPD(instanceId, eventType, timestamp, x, y)); - SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r)); + SysTryReturn(NID_SHELL, !IsFailed(r), false, r, "[%s] Propagated.", GetErrorMessage(r)); return true; } -- 2.7.4