Tizen 2.1 base
[platform/framework/native/app-service.git] / inc / FApp_AppManagerService.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_AppManagerService.h
20  * @brief       This is the header file of the _AppManagerService class.
21  *
22  * This header file contains the declarations of the _AppManagerService class.
23  */
24
25 #ifndef _FAPP_INTERNAL_APP_MANAGER_SERVICE_H_
26 #define _FAPP_INTERNAL_APP_MANAGER_SERVICE_H_
27
28 #include <FBase.h>
29 #include <FSystem.h>
30 #include <FIo.h>
31 #include <FAppTypes.h>
32
33 #include <FApp_IAppManager.h>
34
35 #include "FApp_ContextManager.h"
36
37
38 namespace Tizen { namespace App {
39
40 class _IAppManagerServiceEventListener;
41
42 /**
43  * @class               _AppManagerService
44  * @brief               Manages and control applications.
45  * @since 2.1
46  */
47 class _AppManagerService
48         : public Tizen::Base::Object
49         , public _IAppManager
50         , public _IContextManagerEventListener
51         , virtual public Tizen::Base::Runtime::IEventListener
52 {
53 public:
54         _AppManagerService(void);
55
56         virtual ~_AppManagerService(void);
57
58         result Construct(_ContextManager* pContextMgr, _IAppManagerServiceEventListener* pStub);
59
60         virtual result LaunchApplication(const AppId& appId, const Tizen::Base::String& executableName, int req);
61         virtual result TerminateApplication(const AppId& appId, const Tizen::Base::String& executableName);
62         virtual bool IsRunning(const AppId& appId, const Tizen::Base::String& executableName);
63         virtual result GetRunningAppList(Tizen::Base::Collection::ArrayList* pArray);
64         virtual result RegisterApplication(const AppId& appId, const Tizen::Base::String& executableName, _AppType appType, int pid);
65         virtual result RegisterApplication(const AppId& appId, const Tizen::Base::String& executableName, _AppType appType, int pid, int clientId);
66         virtual result UnregisterApplication(int pid);
67
68         virtual result InitEventListener( _IAppManagerServiceEventListener* pListener);
69         virtual result AddEventListener(int clientId);//, _IAppManagerServiceEventListener* pListener);
70         virtual result RemoveEventListener(int clientId);//, _IAppManagerServiceEventListener* pListener);
71         virtual void OnApplicationTerminated(const _AppContext& appInfo);
72
73         // helper
74 //      const _AppContext* GetAppInfoSimple(const AppId& appId) const;
75
76 private:
77         result SendEventToAllListeners(const _AppManagerEventArg& arg);
78
79 private:
80         typedef Tizen::Base::Collection::HashMapT<int, _IAppManagerServiceEventListener*> _AppManagerServiceEventListeners;
81         typedef Tizen::Base::Collection::IMapEnumeratorT <int, _IAppManagerServiceEventListener*> _AppManagerServiceEventListenerEnum;
82
83         _ContextManager*        __pContextMgr;
84         _AppManagerServiceEventListeners        __eventListeners;
85         _IAppManagerServiceEventListener*       __pStub;
86         _IAppManagerServiceEventListener*       __pProxy;
87
88         void Dump(void);
89
90 friend class UTs_AppManagerServiceP;
91 };      //_AppManagerService
92
93 }}//Tizen::App
94
95 #endif//_APP_MANAGER_SERVICE_H_