Replace MethodCallHandler::setCaller() with a parameterized constructor
[platform/core/context/sensor-recorder.git] / src / server / SensorRecorderService.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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 <ServerUtil.h>
18 #include <SensorRecorderTypesPrivate.h>
19 #include <SensorRecorderService.h>
20 #include "MethodCallHandler.h"
21 #include "SensorDatabase.h"
22 #include "SensorTimer.h"
23 #include "legacy/SensorProvider.h"
24 #include "legacy/RecorderClientInfo.h"
25
26 using namespace ctx;
27
28 SensorRecorderService::SensorRecorderService() :
29         __serviceRunner(NULL)
30 {
31 }
32
33 SensorRecorderService::~SensorRecorderService()
34 {
35 }
36
37 void SensorRecorderService::setServiceRunner(IServiceRunner* runner)
38 {
39         __serviceRunner = runner;
40 }
41
42 bool SensorRecorderService::isUserService()
43 {
44         return true;
45 }
46
47 const char* SensorRecorderService::getServiceName()
48 {
49         return CTX_SENSOR_RECORDER;
50 }
51
52 const char* SensorRecorderService::getMethodSpecs()
53 {
54         return CTX_SENSOR_RECORDER_SPEC;
55 }
56
57 bool SensorRecorderService::prepare()
58 {
59         RecorderClientInfo::setHostService(this);
60
61         if (!SensorDatabase::open(util::getActiveUid()))
62                 return false;
63
64         SensorTimer::init();
65         SensorProvider::init();
66
67         return true;
68 }
69
70 void SensorRecorderService::cleanup()
71 {
72         SensorProvider::release();
73         SensorTimer::release();
74         SensorDatabase::close();
75 }
76
77 void SensorRecorderService::onUserActivated()
78 {
79 }
80
81 void SensorRecorderService::onUserDeactivated()
82 {
83 }
84
85 IMethodCallHandler* SensorRecorderService::createMethodCallHandler(IClient* client)
86 {
87         return new MethodCallHandler(client);
88 }
89
90 GDBusConnection* SensorRecorderService::getConnection()
91 {
92         return __serviceRunner->getConnection();
93 }