Tizen 2.1 base
[platform/core/location/lbs-location.git] / location / manager / location-ielement.c
1 /*
2  * libslp-location
3  *
4  * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
7  *          Genie Kim <daejins.kim@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include "location-log.h"
27 #include "location-ielement.h"
28
29 static void
30 location_ielement_base_init (gpointer g_class)
31 {
32         static gboolean is_initialized = FALSE;
33
34         if (is_initialized){
35                 /* add properties and signals to the interface here */
36
37                 is_initialized = TRUE;
38         }
39 }
40
41 GType
42 location_ielement_get_type (void)
43 {
44         static GType iface_type = 0;
45
46         if (iface_type == 0) {
47                 static const GTypeInfo info = {
48                         sizeof (LocationIElementInterface),
49                         location_ielement_base_init, /* base_init */
50                         NULL /* base_finalize */
51                 };
52
53                 iface_type = g_type_register_static (G_TYPE_INTERFACE, "LocationIElement",
54                                              &info, 0);
55         }
56
57         return iface_type;
58 }
59
60 int
61 location_ielement_start (LocationIElement *self)
62 {
63         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
64         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->start, LOCATION_ERROR_NOT_AVAILABLE);
65         return LOCATION_IELEMENT_GET_INTERFACE (self)->start (self);
66 }
67
68 int
69 location_ielement_stop (LocationIElement *self)
70 {
71         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
72         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->stop, LOCATION_ERROR_NOT_AVAILABLE);
73         return LOCATION_IELEMENT_GET_INTERFACE (self)->stop (self);
74 }
75
76 int
77 location_ielement_get_position (LocationIElement *self,
78         LocationPosition **position,
79         LocationAccuracy **accuracy)
80 {
81         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
82         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
83         g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
84         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_position, LOCATION_ERROR_NOT_AVAILABLE);
85
86         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_position (self, position, accuracy);
87 }
88
89 int
90 location_ielement_get_position_ext (LocationIElement *self,
91         LocationPosition **position,
92         LocationVelocity **velocity,
93         LocationAccuracy **accuracy)
94 {
95         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
96         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
97         g_return_val_if_fail (velocity, LOCATION_ERROR_PARAMETER);
98         g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
99         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_position_ext, LOCATION_ERROR_NOT_AVAILABLE);
100
101         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_position_ext (self, position, velocity, accuracy);
102 }
103
104
105 int
106 location_ielement_get_last_position (LocationIElement *self,
107         LocationPosition **position,
108         LocationAccuracy **accuracy)
109 {
110         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
111         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
112         g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
113         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
114
115         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_position (self, position, accuracy);
116 }
117
118 int
119 location_ielement_get_last_position_ext (LocationIElement *self,
120         LocationPosition **position,
121         LocationVelocity **velocity,
122         LocationAccuracy **accuracy)
123 {
124         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
125         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
126         g_return_val_if_fail (velocity, LOCATION_ERROR_PARAMETER);
127         g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
128         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_position_ext, LOCATION_ERROR_NOT_AVAILABLE);
129
130         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_position_ext (self, position, velocity, accuracy);
131 }
132
133
134 int
135 location_ielement_get_satellite (LocationIElement *self,
136         LocationSatellite **satellite)
137 {
138         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
139         g_return_val_if_fail (satellite, LOCATION_ERROR_PARAMETER);
140         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_satellite, LOCATION_ERROR_NOT_AVAILABLE);
141
142         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_satellite (self, satellite);
143 }
144
145 int
146 location_ielement_get_last_satellite (LocationIElement *self,
147         LocationSatellite **satellite)
148 {
149         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
150         g_return_val_if_fail (satellite, LOCATION_ERROR_PARAMETER);
151         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_satellite, LOCATION_ERROR_NOT_AVAILABLE);
152
153         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_satellite (self, satellite);
154 }
155
156
157 int
158 location_ielement_get_velocity (LocationIElement *self,
159         LocationVelocity **velocity,
160         LocationAccuracy **accuracy)
161 {
162         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
163         g_return_val_if_fail (velocity, LOCATION_ERROR_PARAMETER);
164         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_velocity, LOCATION_ERROR_NOT_AVAILABLE);
165         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_velocity (self, velocity, accuracy);
166 }
167
168 int
169 location_ielement_get_last_velocity (LocationIElement *self,
170         LocationVelocity **velocity,
171         LocationAccuracy **accuracy)
172 {
173         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
174         g_return_val_if_fail (velocity, LOCATION_ERROR_PARAMETER);
175         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_velocity, LOCATION_ERROR_NOT_AVAILABLE);
176         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_velocity (self, velocity, accuracy);
177 }