Add Privacy-Guard
[platform/core/security/privacy-guard.git] / server / src / PrivacyGuardDaemon.cpp
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <string>
18 #include "PrivacyGuardDaemon.h"
19 #include "PrivacyInfoService.h"
20 #include "SocketService.h"
21 #if 0
22 // [CYNARA]
23 #include <CynaraService.h>
24 #endif
25
26 PrivacyGuardDaemon* PrivacyGuardDaemon::pInstance = NULL;
27
28 PrivacyGuardDaemon::PrivacyGuardDaemon(void)
29         : pSocketService(NULL)
30 {
31 }
32
33 PrivacyGuardDaemon::~PrivacyGuardDaemon(void)
34 {
35 }
36
37 PrivacyGuardDaemon*
38 PrivacyGuardDaemon::getInstance(void)
39 {
40         if (pInstance == NULL)
41                 pInstance = new PrivacyGuardDaemon();
42         return pInstance;
43 }
44
45 int
46 PrivacyGuardDaemon::initialize(void)
47 {
48         if (pSocketService == NULL)
49                 pSocketService = new SocketService();
50 #if 0
51         // [CYNARA]
52         if (pCynaraService == NULL)
53                 pCynaraService = new CynaraService();
54 #endif
55         pSocketService->initialize();
56 #if 0
57         // [CYNARA]
58         pCynaraService->initialize();
59 #endif
60
61         PrivacyInfoService::registerCallbacks(pSocketService);
62
63         return 0;
64 }
65
66 int
67 PrivacyGuardDaemon::start(void)
68 {
69         int res = 0;
70         
71         if (pSocketService == NULL)
72                 return PRIV_FLTR_ERROR_NOT_INITIALIZED;
73         res = pSocketService->start();
74         if(res != PRIV_FLTR_ERROR_SUCCESS){
75                 PF_LOGE("FAIL");
76         }
77 #if 0
78         // [CYNARA]
79         if (pCynaraService == NULL)
80                 return PRIV_FLTR_ERROR_NOT_INITIALIZED;
81         res = pCynaraService->start();
82         if(res != PRIV_FLTR_ERROR_SUCCESS){
83                 PF_LOGE("FAIL");
84         }       
85 #endif
86         return res;
87 }
88
89 int
90 PrivacyGuardDaemon::stop(void)
91 {
92         pSocketService->stop();
93 #if 0
94         // [CYNARA]     
95         pCynaraService->stop();
96 #endif
97         
98         return 0;
99 }
100
101 int
102 PrivacyGuardDaemon::shutdown(void)
103 {
104         pSocketService->shutdown();
105         return 0;
106 }