{
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);
};
private:
+ static AppWidgetManagerService* __pTheInstance;
Tizen::Base::Collection::ArrayListT<_AppWidgetContext*> __appWidgetContextList;
Tizen::Base::Runtime::Timer __pingTimer;
_TaskHandlerThread __handlerThread;
-
}; // class AppWidgetManagerService
}}} // Tizen::Shell::App
*/
class OspAppWidgetService
: public Tizen::App::ServiceApp
+ ,public Tizen::App::IAppControlProviderEventListener
{
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_
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<HashMap, AllElementsDeleter> 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)));
extern const int UPDATE_PERIOD_MSEC_MIN;
+AppWidgetManagerService* AppWidgetManagerService::__pTheInstance = null;
+
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();
r = __handlerThread.Start();
SysTryReturnResult(NID_SHELL, IsFailed(r) == false, r, "Event thread Start failure.");
- return InitializeMasterDaemonEventReceiver("osp-appwidget-service");
+ return InitializeCoreDaemonEventReceiver(pIdForCoreDaemon);
}
int
}
///////////////////////////////////////////////////////
-// MasterDaemonEventReceiver implementation
+// CoreDaemonEventReceiver implementation
///////////////////////////////////////////////////////
int
AppWidgetManagerService::OnAppWidgetCreate(struct event_arg *arg, int *width, int *height, double *priority, 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();
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();
return E_SUCCESS;
}
+
AppWidgetManagerService::_TaskHandlerThread::~_TaskHandlerThread(void)
{
* @brief This is the implementation for the OspAppWidgetService class.
*/
+#include <FAppAppControlProviderManager.h>
+#include <FBase_StringConverter.h>
#include "FShell_AppWidgetManagerService.h"
#include "OspAppWidgetService.h"
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)
{
}
bool
OspAppWidgetService::OnAppInitializing(AppRegistry& appRegistry)
{
- AppLog("Enter.");
-
- AppWidgetManagerService* pSvc = AppWidgetManagerService::GetInstance();
- AppAssertf( pSvc != null, "AppWidgetManagerService::GetInstance() failed.");
+ AppControlProviderManager::GetInstance()->SetAppControlProviderEventListener(this);
return true;
}
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<const String*>(pExtraData->GetValue(key));
+
+ std::unique_ptr<char[]> pIdForCoreDaemon(_StringConverter::CopyToCharArrayN(*pValue));
+ AppWidgetManagerService* pSvc = AppWidgetManagerService::CreateInstance(pIdForCoreDaemon.get());
+ AppAssertf( pSvc != null, "AppWidgetManagerService::GetInstance() failed.");
+
+ isServiceCreated = true;
+ }
+ }
+}