Refactory SettingService.
[framework/osp/common-service.git] / src / system / FSys_SettingService.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_SettingService.h
20  * @brief       This is the header file of the _SettingService class.
21  *
22  * This header file contains the declarations of the _SettingService class.
23  */
24
25
26 #ifndef _FSYS_SETTING_SERVICE_INTERNAL_H_
27 #define _FSYS_SETTING_SERVICE_INTERNAL_H_
28
29 #include <unique_ptr.h>
30 #include <pthread.h>
31
32 #include <FBaseColArrayList.h>
33 #include <FBaseColHashMap.h>
34 #include <FBaseObject.h>
35
36 #include <FApp_IAppEventListener.h>
37 #include <FIo_IpcServer.h>
38 #include <FIo_IIpcServerEventListener.h>
39 #include <system-server/FSys_SettingInfo.h>
40
41 namespace Tizen { namespace System
42 {
43
44 class _SettingService
45         : public Tizen::Base::Object
46         , public Tizen::App::_IAppEventListener
47         , public Tizen::Io::_IIpcServerEventListener
48         , public Tizen::System::ISettingInfoSetValueAsyncResultListener
49         , public Tizen::System::ISettingEventListener
50 {
51 private:
52         static void InitSingleton(void);
53         static void DestroySingleton(void);
54
55 public:
56         _SettingService();
57         ~_SettingService();
58         result Construct(void);
59         static _SettingService* GetInstance(void);
60
61 private:
62         bool OnRequestOccured(const Tizen::Base::Collection::ArrayList& request, Tizen::Base::Collection::ArrayList* response);
63         void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message);
64         void OnIpcServerStarted(const Tizen::Io::_IpcServer& server);
65         void OnIpcServerStopped(const Tizen::Io::_IpcServer& server);
66         void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId);
67         void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId);
68
69         void OnApplicationLaunched(const Tizen::App::AppId& appId, int pid);
70         void OnApplicationTerminated(const Tizen::App::AppId& appId, int pid);
71
72         void OnResultReceivedForSetValueAsync(const Tizen::Base::String& key, result r);
73         void OnSettingChanged(Tizen::Base::String& key);
74
75 private:
76         static _SettingService*                 __pSettingService;
77         Tizen::Io::_IpcServer                   __ipcServer;
78         Tizen::Base::String                     __serviceId;
79         _SettingInfo*                           __pSettingInfo;
80         Tizen::Base::Collection::HashMap        __asyncList;
81         Tizen::Base::Collection::ArrayList      __eventList;
82         Tizen::Base::Collection::ArrayList      __eventListForInternal;
83         Tizen::Base::Collection::ArrayList      __responseMessage;
84
85         Tizen::App::AppId                       __currentPkgId;
86         int                                     __currentPid;
87 };
88
89 }}
90 #endif