2 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FShell_AppWidgetManagerService.h
19 * @brief This is the header file for the %AppWidgetManagerService class.
21 * This header file contains the declarations of the %AppWidgetManagerService class.
24 #ifndef _FSHELL_INTERNAL_APPWIDGET_MANAGER_SERVICE_H_
25 #define _FSHELL_INTERNAL_APPWIDGET_MANAGER_SERVICE_H_
27 #include <FBaseRtTimer.h>
28 #include <FBaseRtThread.h>
29 #include <FBaseColArrayListT.h>
30 #include "FShell_AppWidgetContext.h"
31 #include "FShell_AppWidgetManagerStub.h"
33 namespace Tizen { namespace Base { namespace Collection
38 namespace Tizen { namespace Shell { namespace App {
40 class AppWidgetManagerService
41 :public Tizen::Shell::App::_AppWidgetManagerStub
42 ,public Tizen::Base::Runtime::ITimerEventListener
45 static AppWidgetManagerService* GetInstance(void);
46 result AddAppWidget(_AppWidgetContext* pAppWidget);
47 result RemoveAppWidget(const char* pPackageName, const char* pId, bool free);
50 result Construct(void);
51 result InitializeMasterDaemonEventReceiver(const char* pServiceExecutableName);
52 result DeinitializeMasterDaemonEventReceiver(void);
54 // master daemon callbacks
55 static int AppWidgetConnected(struct event_arg *arg, void* data);
56 static int AppWidgetDisconnected(struct event_arg *arg, void* data);
57 static int OnAppWidgetCreate(struct event_arg *arg, int *width, int *height, double *priority, void* data);
58 static int OnAppWidgetDestroy(struct event_arg *arg, void* data);
59 static int OnAppWidgetUpdate(struct event_arg *arg, void* data);
60 static int OnAppWidgetPopupCreate(struct event_arg *arg, void* data);
61 static int OnAppWidgetPopupDestroy(struct event_arg *arg, void* data);
62 static int OnAppWidgetPause(struct event_arg *arg, void* data);
63 static int OnAppWidgetResume(struct event_arg *pArg, void* pData);
64 static int OnAppWidgetPauseAll(struct event_arg *arg, void* data);
65 static int OnAppWidgetResumeAll(struct event_arg *pArg, void* pData);
66 static int OnAppWidgetClick(struct event_arg *arg, void* data);
67 static int OnAppWidgetResize(struct event_arg *arg, void* data);
68 static int OnAppWidgetPeriodChaned(struct event_arg *arg, void* data);
69 static int OnAppWidgetRecreate(struct event_arg *arg, void* data);
71 // stub implementations
72 virtual result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument);
73 virtual result RequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument);
74 virtual result RequestSharedMemoryId(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int w, int h, int& shmId);
75 virtual result RequestSharedMemoryIdForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int w, int h, int& shmId);
76 virtual result RequestSyncSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height);
77 virtual result RequestSyncSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId);
78 virtual result RequestReleaseSharedMemory(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId);
79 virtual result RequestReleaseSharedMemoryForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId);
82 AppWidgetManagerService(void);
83 virtual ~AppWidgetManagerService(void);
85 virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId);
86 virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId);
89 result SetIpcClientIds(const Tizen::App::AppId& appId, int clientId);
90 int UpdateAllAppWidgetsByAppId(const Tizen::Base::String& appId);
92 void StartPingTimer(void);
93 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
94 _AppWidgetContext* Find(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId) const;
96 class _TaskHandlerThread
97 : public Tizen::Base::Runtime::Thread
100 virtual ~_TaskHandlerThread(void);
101 virtual void OnUserEventReceivedN(RequestId reqId, Tizen::Base::Collection::IList* pArgs);
106 Tizen::Base::Collection::ArrayListT<_AppWidgetContext*> __appWidgetContextList;
107 Tizen::Base::Runtime::Timer __pingTimer;
108 _TaskHandlerThread __handlerThread;
110 }; // class AppWidgetManagerService
112 }}} // Tizen::Shell::App
114 #endif // _FSHELL_INTERNAL_APPWIDGET_MANAGER_SERVICE_H_