Update DeviceManager [dep:osp-appfw, osp-app-service]
[platform/framework/native/common-service.git] / inc / FSys_DeviceManagerStub.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         FSys_DeviceManagerStub.h
20  * @brief       This is the header file of the _DeviceManagerStub class.
21  *
22  * This header file contains the declarations of the _DeviceManagerStub class.
23  */
24
25 #ifndef _FSYS_DEVICE_MANAGER_STUB_H_
26 #define _FSYS_DEVICE_MANAGER_STUB_H_
27
28 #include <unique_ptr.h>
29 #include <FBase.h>
30 #include <FIo_IIpcServerEventListener.h>
31 #include <FSystem.h>
32 #include "FApp_IAppEventListener.h"
33 #include "FSys_SystemServiceIpcEventForAsync.h"
34 #include "FSys_DeviceManager.h"
35
36 namespace Tizen { namespace System
37 {
38 class _OSP_EXPORT_ _DeviceManagerStub
39         : public Tizen::Base::Object
40         , public Tizen::Io::_IIpcServerEventListener
41         , public Tizen::System::IDeviceEventListener
42         , public Tizen::App::_IAppEventListener
43 {
44 public:
45         static _DeviceManagerStub* GetInstance(void);
46
47         virtual ~_DeviceManagerStub(void);
48         result SendData(const int pid, Tizen::Base::Collection::ArrayList* data);
49         virtual void OnDeviceStateChanged (DeviceType deviceType, const Tizen::Base::String &state);
50 private:
51         _DeviceManagerStub(void);
52         result Construct(void);
53
54         static void InitSingleton(void);
55         static void DestroySingleton(void);
56
57         _DeviceManagerStub(const _DeviceManagerStub& rhs);
58         _DeviceManagerStub& operator =(const _DeviceManagerStub& rhs);
59
60         void AddInterestedApp(int pid);
61         void RemoveInterestedApp(int pid);
62
63         bool OnRequestOccured(const Tizen::Base::Collection::ArrayList& request, Tizen::Base::Collection::ArrayList* response);
64         virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message);
65         virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, int pid);
66
67         virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server){};
68         virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server){};
69         virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId){};
70         virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId){};
71
72         virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, int pid){};
73
74 private:
75         std::unique_ptr<Tizen::Io::_IpcServer> __pIpcServer;
76         static _DeviceManagerStub* __pDeviceManagerStub;
77         _DeviceManager* __pDeviceManager;
78         Tizen::Base::Runtime::Mutex             __Mutex;
79         Tizen::App::AppId                       __currentPkgId;
80         int                                     __currentPid;
81         Tizen::Base::String __serviceId;
82         Tizen::Base::String __command;
83         Tizen::Base::String __deviceType;
84         Tizen::Base::String __result;
85
86         Tizen::Base::Collection::ArrayList __interestedPidList;
87         _SystemServiceIpcEventForAsync* __pDeviceManagerServiceIpcEventForAsync;
88         bool __IsInitializedDevice;
89 }; // _DeviceManagerStub
90
91 }} // Tizen::System
92
93 #endif // _FSYS_DEVICE_MANAGER_STUB_H_