From: jungmin76.park Date: Mon, 10 Jun 2013 12:40:37 +0000 (+0900) Subject: fix to send id for core daemon as param of provider_init() X-Git-Tag: submit/tizen/20130912.075546~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b36242f98ff0297acf105b49e77d5918888654d7;p=platform%2Fframework%2Fnative%2Fappwidget-service.git fix to send id for core daemon as param of provider_init() Change-Id: I1bb8d2711994ee0fab17f35dcc9f9b1a72117bbb Signed-off-by: jungmin76.park --- diff --git a/inc/FShell_AppWidgetManagerService.h b/inc/FShell_AppWidgetManagerService.h index 26ee083..7c3f0a6 100644 --- a/inc/FShell_AppWidgetManagerService.h +++ b/inc/FShell_AppWidgetManagerService.h @@ -43,13 +43,14 @@ class AppWidgetManagerService { public: static AppWidgetManagerService* GetInstance(void); + static AppWidgetManagerService* CreateInstance(const char* pServiceIdForCoreDaemon); result AddAppWidget(_AppWidgetContext* pAppWidget); result RemoveAppWidget(const char* pPackageName, const char* pId, bool free); private: - result Construct(void); - result InitializeMasterDaemonEventReceiver(const char* pServiceExecutableName); - result DeinitializeMasterDaemonEventReceiver(void); + result Construct(const char* pServiceIdForCoreDaemon); + result InitializeCoreDaemonEventReceiver(const char* pServiceIdForCoreDaemon); + result DeinitializeCoreDaemonEventReceiver(void); // master daemon callbacks static int AppWidgetConnected(struct event_arg *arg, void* data); @@ -105,10 +106,10 @@ private: }; private: + static AppWidgetManagerService* __pTheInstance; Tizen::Base::Collection::ArrayListT<_AppWidgetContext*> __appWidgetContextList; Tizen::Base::Runtime::Timer __pingTimer; _TaskHandlerThread __handlerThread; - }; // class AppWidgetManagerService }}} // Tizen::Shell::App diff --git a/inc/OspAppWidgetService.h b/inc/OspAppWidgetService.h index 58e4a3d..9a666e2 100644 --- a/inc/OspAppWidgetService.h +++ b/inc/OspAppWidgetService.h @@ -34,6 +34,7 @@ */ class OspAppWidgetService : public Tizen::App::ServiceApp + ,public Tizen::App::IAppControlProviderEventListener { public: @@ -67,6 +68,8 @@ public: // Called when the battery level changes. void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel); +private: + virtual void OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData); }; // class OspAppWidgetService #endif // _OSP_APPWIDGET_SERVICE_H_ diff --git a/src/FShell_AppWidgetContext.cpp b/src/FShell_AppWidgetContext.cpp index 70749df..df7a73a 100644 --- a/src/FShell_AppWidgetContext.cpp +++ b/src/FShell_AppWidgetContext.cpp @@ -291,18 +291,19 @@ _AppWidgetContext::SendTouchEvent(buffer_event eventType, double timeStamp, doub if (HasValidClientId() && IsRunning()) { SysAssert(IsSharedMemCreated() == true); - SysLog(NID_SHELL, "send IPC message"); + SysLog(NID_SHELL, "%d, %f, %f", eventType, x, y); AppWidgetManagerService::GetInstance()->SendTouchEvent(GetClientId(), GetInstanceId(), eventType, timeStamp, x, y); } else { - SysLog(NID_SHELL, "request to start AppControl"); __pPendingTouchEventList->Add(new PendingTouchEvent(eventType, timeStamp, x, y)); if( AppManager::GetInstance()->IsRunning(this->GetAppId() ) == false) { + SysLog(NID_SHELL, "request to start AppControl"); std::unique_ptr pArgs (CreateRequestArgsN() ); + // TODO: consider to remove these unused args. pArgs->Add(new String(ARG_KEY_EVENT_TYPE), new String(Integer::ToString(eventType))); pArgs->Add(new String(ARG_KEY_TIME_STAMP), new String(Double::ToString(timeStamp))); pArgs->Add(new String(ARG_KEY_X), new String(Double::ToString(x))); diff --git a/src/FShell_AppWidgetManagerService.cpp b/src/FShell_AppWidgetManagerService.cpp index b1d54c5..3dd150d 100644 --- a/src/FShell_AppWidgetManagerService.cpp +++ b/src/FShell_AppWidgetManagerService.cpp @@ -49,6 +49,8 @@ static const RequestId LOCAL_EVENT_REQUEST_UPDATE = 0; extern const int UPDATE_PERIOD_MSEC_MIN; +AppWidgetManagerService* AppWidgetManagerService::__pTheInstance = null; + AppWidgetManagerService::AppWidgetManagerService(void) { @@ -57,27 +59,36 @@ AppWidgetManagerService::AppWidgetManagerService(void) AppWidgetManagerService::~AppWidgetManagerService(void) { __pingTimer.Cancel(); - DeinitializeMasterDaemonEventReceiver(); + DeinitializeCoreDaemonEventReceiver(); } AppWidgetManagerService* AppWidgetManagerService::GetInstance(void) { - static AppWidgetManagerService* pSelf = null; - if( pSelf == null) + if( __pTheInstance == null) + { + __pTheInstance = CreateInstance("osp-appwidget-service"); + } + return __pTheInstance; +} + +AppWidgetManagerService* +AppWidgetManagerService::CreateInstance(const char* pIdForCoreDaemon) +{ + if( __pTheInstance == null) { - pSelf = new AppWidgetManagerService(); - SysTryReturn(NID_SHELL, pSelf != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); + __pTheInstance = new AppWidgetManagerService(); + SysTryReturn(NID_SHELL, __pTheInstance != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); - result r = pSelf->Construct(); + result r = __pTheInstance->Construct(pIdForCoreDaemon); SysAssertf(!IsFailed(r), "Failed to construct AppWidgetManagerService"); SysLog(NID_SHELL, "AppWidgetManagerService is created."); } - return pSelf; + return __pTheInstance; } result -AppWidgetManagerService::Construct(void) +AppWidgetManagerService::Construct(const char* pIdForCoreDaemon) { _AppWidgetManagerStub::StartIpcServer(); @@ -87,7 +98,7 @@ AppWidgetManagerService::Construct(void) r = __handlerThread.Start(); SysTryReturnResult(NID_SHELL, IsFailed(r) == false, r, "Event thread Start failure."); - return InitializeMasterDaemonEventReceiver("osp-appwidget-service"); + return InitializeCoreDaemonEventReceiver(pIdForCoreDaemon); } int @@ -242,7 +253,7 @@ AppWidgetManagerService::RemoveAppWidget(const char* pPackageName, const char* p } /////////////////////////////////////////////////////// -// MasterDaemonEventReceiver implementation +// CoreDaemonEventReceiver implementation /////////////////////////////////////////////////////// int AppWidgetManagerService::OnAppWidgetCreate(struct event_arg *arg, int *width, int *height, double *priority, void* data) @@ -497,10 +508,9 @@ AppWidgetManagerService::OnAppWidgetRecreate(struct event_arg *arg, void* data) } result -AppWidgetManagerService::InitializeMasterDaemonEventReceiver(const char *pServiceExecutableName) +AppWidgetManagerService::InitializeCoreDaemonEventReceiver(const char *pIdForCoreDaemon) { - SysTryReturnResult(NID_SHELL, pServiceExecutableName != null, E_INVALID_ARG, ""); - SysLog(NID_SHELL, "Enter."); + SysTryReturnResult(NID_SHELL, pIdForCoreDaemon != null, E_INVALID_ARG, "pIdForCoreDaemon should not be null!"); __appWidgetContextList.Construct(); @@ -528,15 +538,15 @@ AppWidgetManagerService::InitializeMasterDaemonEventReceiver(const char *pServic cbs.lb_recreate = OnAppWidgetRecreate;/* Recover from the fault of slave */ //cbs.content_event = OnAppWidgetContentEvent, - int ret = provider_init(null, pServiceExecutableName, &cbs, this); + int ret = provider_init(null, pIdForCoreDaemon, &cbs, this); SysTryReturnResult(NID_SHELL, ret == 0, E_SYSTEM, "provider_init failed."); - SysLog(NID_SHELL, "Exit."); + SysLog(NID_SHELL, "provider_init is invoked with (%s)", pIdForCoreDaemon); return E_SUCCESS; } result -AppWidgetManagerService::DeinitializeMasterDaemonEventReceiver(void) +AppWidgetManagerService::DeinitializeCoreDaemonEventReceiver(void) { SysLog(NID_SHELL, "Enter."); provider_fini(); @@ -696,6 +706,7 @@ AppWidgetManagerService::SendResult(const Tizen::App::AppId& appId, const Tizen: return E_SUCCESS; } + AppWidgetManagerService::_TaskHandlerThread::~_TaskHandlerThread(void) { diff --git a/src/OspAppWidgetService.cpp b/src/OspAppWidgetService.cpp index 1cdc1f6..0820901 100644 --- a/src/OspAppWidgetService.cpp +++ b/src/OspAppWidgetService.cpp @@ -19,6 +19,8 @@ * @brief This is the implementation for the OspAppWidgetService class. */ +#include +#include #include "FShell_AppWidgetManagerService.h" #include "OspAppWidgetService.h" @@ -27,6 +29,9 @@ using namespace Tizen::Base; using namespace Tizen::System; using namespace Tizen::Shell::App; +const wchar_t OPERATION_MAIN[] = L"http://tizen.org/appcontrol/operation/main"; +const wchar_t KEY_NAME[] = L"name"; + OspAppWidgetService::OspAppWidgetService(void) { } @@ -45,10 +50,7 @@ OspAppWidgetService::CreateInstance(void) bool OspAppWidgetService::OnAppInitializing(AppRegistry& appRegistry) { - AppLog("Enter."); - - AppWidgetManagerService* pSvc = AppWidgetManagerService::GetInstance(); - AppAssertf( pSvc != null, "AppWidgetManagerService::GetInstance() failed."); + AppControlProviderManager::GetInstance()->SetAppControlProviderEventListener(this); return true; } @@ -80,3 +82,24 @@ void OspAppWidgetService::OnBatteryLevelChanged(BatteryLevel batteryLevel) { } + +void +OspAppWidgetService::OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData) +{ + if( operationId == OPERATION_MAIN) + { + static bool isServiceCreated = false; + + if( isServiceCreated == false) + { + String key(KEY_NAME); + const String* pValue = dynamic_cast(pExtraData->GetValue(key)); + + std::unique_ptr pIdForCoreDaemon(_StringConverter::CopyToCharArrayN(*pValue)); + AppWidgetManagerService* pSvc = AppWidgetManagerService::CreateInstance(pIdForCoreDaemon.get()); + AppAssertf( pSvc != null, "AppWidgetManagerService::GetInstance() failed."); + + isServiceCreated = true; + } + } +}