From 3200f322542690be2dd6fdfdcbe52ba835ef33c9 Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Mon, 22 Apr 2013 17:52:32 +0900 Subject: [PATCH] initialize appwidget when appwidget popup is created Change-Id: I7a83a70a4dbf832f7abf876bebc6d97eaede260a Signed-off-by: jungmin76.park --- inc/FShell_AppWidgetContext.h | 2 ++ inc/FShell_AppWidgetContextBase.h | 15 +++++++++++++- inc/FShell_AppWidgetManagerService.h | 3 +++ inc/FShell_AppWidgetPopupContext.h | 10 +++++++++- src/FShell_AppWidgetContext.cpp | 23 +++++++++++++++------- src/FShell_AppWidgetContextBase.cpp | 31 ++++++++++++----------------- src/FShell_AppWidgetManagerService.cpp | 36 ++++++++++++++++++++++++++-------- src/FShell_AppWidgetPopupContext.cpp | 27 +++++++++++++++++-------- 8 files changed, 103 insertions(+), 44 deletions(-) diff --git a/inc/FShell_AppWidgetContext.h b/inc/FShell_AppWidgetContext.h index 558f42d..c661e17 100644 --- a/inc/FShell_AppWidgetContext.h +++ b/inc/FShell_AppWidgetContext.h @@ -77,6 +77,8 @@ private: result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); void SendPendingTouchEvent(void); + virtual Tizen::Base::Collection::HashMap* CreateRequestArgs(void); + virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer); struct PendingTouchEvent diff --git a/inc/FShell_AppWidgetContextBase.h b/inc/FShell_AppWidgetContextBase.h index 3c62686..949dc6a 100644 --- a/inc/FShell_AppWidgetContextBase.h +++ b/inc/FShell_AppWidgetContextBase.h @@ -70,7 +70,7 @@ protected: bool IsRunning(void) const; bool IsSharedMemCreated(void) const; - Tizen::Base::Collection::HashMap* CreateRequestArgs(void); + virtual Tizen::Base::Collection::HashMap* CreateRequestArgs(void) = 0; result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs); public: @@ -102,6 +102,19 @@ public: // static result ExtractPackageIdAndExecutableName(Tizen::App::AppId inAppId, Tizen::Base::String& outPackageId, Tizen::Base::String& outExecutableName); }; +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[]; + } /* namespace App */ } /* namespace AppWidget */ } /* namespace Samsung */ diff --git a/inc/FShell_AppWidgetManagerService.h b/inc/FShell_AppWidgetManagerService.h index 0da6a1c..64979c5 100644 --- a/inc/FShell_AppWidgetManagerService.h +++ b/inc/FShell_AppWidgetManagerService.h @@ -60,9 +60,12 @@ private: static int OnAppWidgetPopupDestroy(struct event_arg *arg, void* data); static int OnAppWidgetPause(struct event_arg *arg, void* data); static int OnAppWidgetResume(struct event_arg *arg, void* data); + static int OnAppWidgetPauseAll(struct event_arg *arg, void* data); + static int OnAppWidgetResumeAll(struct event_arg *arg, void* data); static int OnAppWidgetClick(struct event_arg *arg, void* data); static int OnAppWidgetResize(struct event_arg *arg, void* data); static int OnAppWidgetPeriodChaned(struct event_arg *arg, void* data); + static int OnAppWidgetRecreate(struct event_arg *arg, void* data); // stub implementations virtual result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument); diff --git a/inc/FShell_AppWidgetPopupContext.h b/inc/FShell_AppWidgetPopupContext.h index e58390d..ab64a2c 100644 --- a/inc/FShell_AppWidgetPopupContext.h +++ b/inc/FShell_AppWidgetPopupContext.h @@ -30,11 +30,13 @@ namespace Tizen { namespace Shell { namespace App { +class _AppWidgetContext; + class _AppWidgetPopupContext :public Tizen::Shell::App::_AppWidgetContextBase { public: - _AppWidgetPopupContext(const Tizen::Base::String& userInfo, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int priority); + _AppWidgetPopupContext(const Tizen::Base::String& userInfo, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int priority, _AppWidgetContext* pParent); virtual ~_AppWidgetPopupContext(); // event handler @@ -47,6 +49,12 @@ public: virtual result SendTouchEvent(buffer_event event, double timestamp, double x, double y); result RequestUpdateRemote(void); + +private: + virtual Tizen::Base::Collection::HashMap* CreateRequestArgs(void); + +private: + _AppWidgetContext* __pParent; }; diff --git a/src/FShell_AppWidgetContext.cpp b/src/FShell_AppWidgetContext.cpp index 5185b63..ba5b132 100644 --- a/src/FShell_AppWidgetContext.cpp +++ b/src/FShell_AppWidgetContext.cpp @@ -51,12 +51,6 @@ const char APPWIDGET_ON_UPDATE[] = "http://tizen.org/appcontrol/appwidget/update const char APPWIDGET_ON_RESIZE[] = "http://tizen.org/appcontrol/appwidget/resize"; const char APPWIDGET_ON_TOUCH[] = "http://tizen.org/appcontrol/appwidget/touch"; -const String ARG_KEY_ARGUMENT = L"_Argument"; -const String ARG_KEY_EVENT_TYPE = L"_EventType"; -const String ARG_KEY_TIME_STAMP = L"_TimeStamp"; -const String ARG_KEY_X = L"_X"; -const String ARG_KEY_Y = L"_Y"; - const int DEFAULT_LIFE_DURATION_MSEC = 30000;//30sec const int UPDATE_PERIOD_MSEC_MIN = 1800000;//30min @@ -165,7 +159,7 @@ _AppWidgetContext::OnBackground() void _AppWidgetContext::OnPopupCreated(double x, double y, int width, int height) { - __pAppWidgetPopup = new (std::nothrow) _AppWidgetPopupContext(__userInfo, __providerId, __instanceId, width, height, __priority); + __pAppWidgetPopup = new (std::nothrow) _AppWidgetPopupContext(__userInfo, __providerId, __instanceId, width, height, __priority, this); __pAppWidgetPopup->SetIpcClientId(__ipcClientId); __pAppWidgetPopup->OnPopupCreated(x, y, width, height); @@ -288,6 +282,21 @@ _AppWidgetContext::RequestUpdateRemote(int width, int height) return E_SUCCESS; } +Tizen::Base::Collection::HashMap* +_AppWidgetContext::CreateRequestArgs(void) +{ + HashMap* pArgs = new (std::nothrow) HashMap(SingleObjectDeleter); + pArgs->Construct(); + pArgs->Add(new String(ARG_KEY_INSTANCE_ID), new String(__instanceId)); + pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(__providerName)); + pArgs->Add(new String(ARG_KEY_USER_INFO), new String(__userInfo)); + pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(__width))); + pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(__height))); + + return pArgs; +} + + //void //_AppWidgetContext::RestartLifeDurationTimer() //{ diff --git a/src/FShell_AppWidgetContextBase.cpp b/src/FShell_AppWidgetContextBase.cpp index 2641c80..91b41f0 100644 --- a/src/FShell_AppWidgetContextBase.cpp +++ b/src/FShell_AppWidgetContextBase.cpp @@ -85,11 +85,18 @@ using namespace Tizen::Base; using namespace Tizen::Base::Collection; -const String ARG_KEY_INSTANCE_ID = L"_InstanceId"; -const String ARG_KEY_PROVIDER_NAME = L"_ProviderName"; -const String ARG_KEY_USER_INFO = L"_UserInfo"; -const String ARG_KEY_WIDTH = L"_Width"; -const String ARG_KEY_HEIGHT = L"_Height"; +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"; _AppWidgetContextBase::_AppWidgetContextBase(target_type type, const String& userInfo, const String& providerId, const String& instanceId, int width, int height, int priority) @@ -210,20 +217,6 @@ _AppWidgetContextBase::ReleaseSharedMem() return E_SUCCESS; } -Tizen::Base::Collection::HashMap* -_AppWidgetContextBase::CreateRequestArgs(void) -{ - HashMap* pArgs = new (std::nothrow) HashMap(SingleObjectDeleter); - pArgs->Construct(); - pArgs->Add(new String(ARG_KEY_INSTANCE_ID), new String(__instanceId)); - pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(__providerName)); - pArgs->Add(new String(ARG_KEY_USER_INFO), new String(__userInfo)); - pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(__width))); - pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(__height))); - - return pArgs; -} - result _AppWidgetContextBase::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs) { diff --git a/src/FShell_AppWidgetManagerService.cpp b/src/FShell_AppWidgetManagerService.cpp index 80c62b7..400536c 100644 --- a/src/FShell_AppWidgetManagerService.cpp +++ b/src/FShell_AppWidgetManagerService.cpp @@ -350,8 +350,8 @@ AppWidgetManagerService::OnAppWidgetPopupCreate(struct event_arg *arg, void* dat return 0; } - int - AppWidgetManagerService::OnAppWidgetPause(struct event_arg *arg, void* data) +int +AppWidgetManagerService::OnAppWidgetPause(struct event_arg *arg, void* data) { SysTryReturn(NID_SHELL, arg, 0, E_SUCCESS, "arg is null!"); @@ -377,6 +377,20 @@ AppWidgetManagerService::OnAppWidgetResume(struct event_arg *arg, void* data) } int +AppWidgetManagerService::OnAppWidgetPauseAll(struct event_arg *arg, void* data) +{ + SysLog(NID_SHELL,""); + return 0; +} + +int +AppWidgetManagerService::OnAppWidgetResumeAll(struct event_arg *arg, void* data) +{ + SysLog(NID_SHELL,""); + return 0; +} + +int AppWidgetManagerService::OnAppWidgetClick(struct event_arg *arg, void* data) { SysTryReturn (NID_SHELL, arg->type == event_arg::EVENT_CLICKED, -EPERM, E_SUCCESS, "invalid argument from master"); @@ -410,6 +424,13 @@ AppWidgetManagerService::OnAppWidgetPeriodChaned(struct event_arg *arg, void* da return 0; } +int +AppWidgetManagerService::OnAppWidgetRecreate(struct event_arg *arg, void* data) +{ + SysLog(NID_SHELL, ""); + return 0; +} + result AppWidgetManagerService::InitializeMasterDaemonEventReceiver(const char *pServiceExecutableName) { @@ -427,10 +448,10 @@ AppWidgetManagerService::InitializeMasterDaemonEventReceiver(const char *pServic cbs.connected = AppWidgetConnected, cbs.disconnected = AppWidgetDisconnected, - cbs.pause = OnAppWidgetPause, - cbs.resume = OnAppWidgetResume, -// cbs.lb_pause = OnAppWidgetPause, -// cbs.lb_resume = OnAppWidgetResume, + cbs.pause = OnAppWidgetPauseAll, + cbs.resume = OnAppWidgetResumeAll, + cbs.lb_pause = OnAppWidgetPause, + cbs.lb_resume = OnAppWidgetResume, cbs.lb_create = OnAppWidgetCreate, cbs.lb_destroy = OnAppWidgetDestroy, cbs.update_content = OnAppWidgetUpdate, @@ -439,9 +460,8 @@ AppWidgetManagerService::InitializeMasterDaemonEventReceiver(const char *pServic cbs.clicked = OnAppWidgetClick, cbs.resize = OnAppWidgetResize, cbs.set_period = OnAppWidgetPeriodChaned; - //cbs.lb_recreate = OnAppWidgetRecreate,/* Recover from the fault of slave */ + cbs.lb_recreate = OnAppWidgetRecreate;/* Recover from the fault of slave */ //cbs.content_event = OnAppWidgetContentEvent, - //cbs.change_group = OnAppWidgetGroupChanged; int ret = provider_init(null, pServiceExecutableName, &cbs, this); SysTryReturnResult(NID_SHELL, ret == 0, E_SYSTEM, "provider_init failed."); diff --git a/src/FShell_AppWidgetPopupContext.cpp b/src/FShell_AppWidgetPopupContext.cpp index 1b0bfd0..3c47849 100644 --- a/src/FShell_AppWidgetPopupContext.cpp +++ b/src/FShell_AppWidgetPopupContext.cpp @@ -32,6 +32,7 @@ #include #include "FShell_AppWidgetManagerService.h" +#include "FShell_AppWidgetContext.h" #include "FShell_AppWidgetPopupContext.h" namespace Tizen { namespace Shell { namespace App @@ -45,15 +46,11 @@ const char APPWIDGET_POPUP_ON_CREATE[] = "http://tizen.org/appcontrol/appwidgetp const char APPWIDGET_POPUP_ON_DESTROY[] = "http://tizen.org/appcontrol/appwidgetpopup/destroy"; const char APPWIDGET_POPUP_ON_TOUCH[] = "http://tizen.org/appcontrol/appwidgetpopup/touch"; -const String ARG_KEY_X = L"_X"; -const String ARG_KEY_Y = L"_Y"; -const String ARG_KEY_WIDTH = L"_Width"; -const String ARG_KEY_HEIGHT = L"_Height"; - -_AppWidgetPopupContext::_AppWidgetPopupContext(const String& info, const String& appId, const String& instanceId, int width, int height, int priority) +_AppWidgetPopupContext::_AppWidgetPopupContext(const String& info, const String& appId, const String& instanceId, int width, int height, int priority, _AppWidgetContext* pParent) :_AppWidgetContextBase(TYPE_PD, info, appId, instanceId, width, height, priority) { + __pParent = pParent; SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height); } @@ -84,8 +81,8 @@ _AppWidgetPopupContext::SendPopupCreateRequest(double x, double y, int width, in pArgs->Add(new String(ARG_KEY_X), new String(Double::ToString(x))); pArgs->Add(new String(ARG_KEY_Y), new String(Double::ToString(y))); - pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(width))); - pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(height))); + 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 SendRequestToApp( __appId, APPWIDGET_POPUP_ON_CREATE, pArgs.get()); } @@ -136,5 +133,19 @@ _AppWidgetPopupContext::RequestUpdateRemote() return E_SUCCESS; } +Tizen::Base::Collection::HashMap* +_AppWidgetPopupContext::CreateRequestArgs(void) +{ + HashMap* pArgs = new (std::nothrow) HashMap(SingleObjectDeleter); + pArgs->Construct(); + pArgs->Add(new String(ARG_KEY_INSTANCE_ID), new String(__instanceId)); + pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(__providerName)); + pArgs->Add(new String(ARG_KEY_USER_INFO), new String(__userInfo)); + pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(__pParent->__width))); + pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(__pParent->__height))); + + return pArgs; +} + } } } // Tizen::Shell::App { -- 2.7.4