Tizen 2.1 base
[platform/framework/native/app-service.git] / inc / FApp_AppManagerStub.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file         FApp_AppManagerStub.h
20  * @brief       This is the header file of the _AppManagerStub class.
21  *
22  * This header file contains the declarations of the _AppManagerStub class.
23  */
24
25 #ifndef _FAPP_INTERNAL_APP_MANAGER_STUB_H_
26 #define _FAPP_INTERNAL_APP_MANAGER_STUB_H_
27
28 #include <FBaseObject.h>
29 #include <FBaseString.h>
30 #include <FBaseRtIEventListener.h>
31 #include <FSystem.h>
32 #include <FIo.h>
33 #include <FAppTypes.h>
34
35 #include <FIo_IIpcServerEventListener.h>
36 #include <FApp_IAppManager.h>
37 #include <FApp_IAppManagerServiceEventListener.h>
38
39
40 namespace Tizen { namespace App {
41
42 class _AppManagerService;
43 class _ContextManager;
44
45 /**
46  * @class               _AppManagerStub
47  * @brief               Handles IPC requests and calls real methods.
48  * @since 2.1
49  */
50 class _AppManagerStub
51         : public Tizen::Base::Object
52         , public Tizen::Io::_IIpcServerEventListener
53         , public _IAppManagerServiceEventListener
54         , virtual public Tizen::Base::Runtime::IEventListener
55 {
56 public:
57         _AppManagerStub(void);
58
59         virtual ~_AppManagerStub(void);
60
61         result Construct(_ContextManager* pContextMgr);
62
63         // handlers
64         bool OnLaunchApplication(const AppId& appID, const Tizen::Base::String& serviceId, int req);
65         bool OnTerminateApplication(const AppId& appID, const Tizen::Base::String& executableName, result *pRes);
66         bool OnIsRunning(const AppId& appID, const Tizen::Base::String& executableName, bool *pRes);
67         bool OnGetRunningAppList(Tizen::Base::Collection::ArrayList* pArray, result *pRes);
68         bool OnRegisterApplication(const AppId& appID, const Tizen::Base::String& executableName, int appType, int pid);
69         bool OnUnregisterApplication(int pid);
70         bool OnAddEventListener(int pid);
71         bool OnRemoveEventListener(int pid);
72
73         // send message to client
74
75         // _IIpcServerEventListener
76         virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server);
77         virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server);
78         virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId);
79         virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId);
80         virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message);
81
82         // to client
83         virtual result OnServiceEventReceived(int clientId, const _AppManagerEventArg& arg);
84         virtual result OnTerminateApplicationRequested(int clientId);
85
86 private:
87         result StartIpcServer(void);
88         _AppManagerStub(const _AppManagerStub& value);
89         _AppManagerStub& operator =(const _AppManagerStub& source);
90
91 private:
92         typedef Tizen::Base::Collection::HashMapT<int, Tizen::Base::String*> _AppManagerEventListeners;
93         typedef Tizen::Base::Collection::IMapEnumeratorT <int, Tizen::Base::String*> _AppManagerEventListenersEnumerator;
94
95         Tizen::Io::_IpcServer *__pIpcServer;
96         _AppManagerService* __pAppManagerService;
97 };      //_AppManagerStub
98
99 }}//Tizen::App
100
101 #endif//_FAPP_INTERNAL_APP_MANAGER_STUB_H_