summaryrefslogtreecommitdiff
path: root/include/location_preference.h
blob: 29d44e4407cdcc6a7ea3af82f7814fcadcac667c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*
* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef __TIZEN_LOCATION_LOCATION_PREFERENCE_H__
#define __TIZEN_LOCATION_LOCATION_PREFERENCE_H__

#include <tizen_type.h>
#include <tizen_error.h>

#ifdef __cplusplus
extern "C" {
#endif


/**
 * @addtogroup CAPI_LOCATION_PREF_MODULE
 * @{
 */

/**
 * @brief The handle of location service
 */
typedef void* location_service_h;


/**
 * @brief Gets a handle of location service from x
 */
#define GET_LOCATION_SERVICE(x) (location_service_h)(x)


/**
 * @brief Enumerations of error code for Location Preference
 */
typedef enum
{
    LOCATION_PREFERENCE_ERROR_NONE = TIZEN_ERROR_NONE,    /**< Successful */
    LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,    /**< Invalid parameter */
    LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND = TIZEN_ERROR_LOCATION_CLASS|0x0101,    /**<  Result not found */
    LOCATION_PREFERENCE_ERROR_NETWORK_FAILED = TIZEN_ERROR_LOCATION_CLASS|0x0102,    /**< Network unavailable */
    LOCATION_PREFERENCE_ERROR_INVALID_KEY = TIZEN_ERROR_LOCATION_CLASS | 0x0103,   /**< Invalid key */
} location_preference_error_e;

/**
 * @brief Enumerations of distance unit
 */
typedef enum
{
    LOCATION_PREFERENCE_DISTANCE_UNIT_M = 0,  /**< Meter */
    LOCATION_PREFERENCE_DISTANCE_UNIT_KM = 1,  /**< Kilometer */
    LOCATION_PREFERENCE_DISTANCE_UNIT_FT = 2,  /**< Feet */
    LOCATION_PREFERENCE_DISTANCE_UNIT_YD = 3,  /**< Mile */
    LOCATION_PREFERENCE_DISTANCE_UNIT_MI = 4,  /**< Mile */
} location_preference_distance_unit_e;

/**
 * @brief Called repeatedly when you get the available property keys.
 * @param[in] key The property key of location preference
 * @param[in] user_data The user data passed from foreach function
 * @pre location_preference_foreach_available_property_keys() will invoke this callback.
 * @return  @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
 * @see	location_preference_foreach_available_property_keys()
 */
typedef bool (*location_preference_available_property_key_cb)(const char* key, void* user_data);

/**
 * @brief Called repeatedly when you get the available property values.
 * @param[in] value The property value of location preference
 * @param[in] user_data The user data passed from foreach function
 * @pre location_preference_foreach_available_property_values() will invoke this callback.
 * @return  @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
 * @see	location_preference_foreach_available_property_values()
 */
typedef bool (*location_preference_available_property_value_cb)(const char* value, void* user_data);

/**
 * @brief Called repeatedly when you get the available languages.
 * @param[in] language The language of location preference
 * @param[in] user_data The user data passed from foreach function
 * @pre location_preference_foreach_available_languages() will invoke this callback.
 * @return  @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
 * @see	location_preference_foreach_available_languages()
 */
typedef bool (*location_preference_available_language_cb)(const char* language, void* user_data);

/**
 * @brief Called repeatedly when you get the properties that was set in location preference.
 * @param[in] key The property key of location preference
 * @param[in] value The property value of location preference
 * @param[in] user_data The user data passed from foreach function
 * @pre location_preference_foreach_properties() will invoke this callback.
 * @return  @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
 * @see	location_preference_foreach_properties()
 */
typedef bool (*location_preference_property_cb)(const char* key, const char* value, void* user_data);

/**
 * @brief Retrieves the available property keys of location preference.
 * @param[in] location_service The memory pointer of location service handle.
 *                 It must be converted into location_service_h by GET_LOCATION_SERVICE().
 * @param[in] callback The callback function to be invoked
 * @param[in] user_data The user data passed to the callback function
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER	Invalid parameter
 * @retval #LOCATION_PREFERENCE_ERROR_NETWORK_FAILED Network unavailable
 * @retval #LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND Result not found
 * @post location_preference_available_property_key_cb() will be invoked.
 * @see	GET_LOCATION_SERVICE()
 * @see location_preference_available_property_key_cb()
 * @see location_preference_foreach_available_property_values()
 */
int location_preference_foreach_available_property_keys(location_service_h service, location_preference_available_property_key_cb callback, void* user_data);

/**
 * @brief Retrieves the available property values of location preference.
 * @param[in] location_service The memory pointer of location service handle.
 *                 It must be converted into location_service_h by GET_LOCATION_SERVICE().
 * @param[in] key The property of location preference
 * @param[in] callback The callback function to be invoked
 * @param[in] user_data The user data passed to the callback function
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER	Invalid parameter
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_KEY Invalid key
 * @retval #LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND Result not found
 * @post location_preference_available_property_value_cb() will be invoked.
 * @see	GET_LOCATION_SERVICE()
 * @see location_preference_available_property_value_cb()
 * @see location_preference_foreach_available_property_keys()
 */
int location_preference_foreach_available_property_values(location_service_h service, const char* key, location_preference_available_property_value_cb callback, void* user_data);

/**
 * @brief Retrieves the available languages of location preference.
 * @param[in] location_service The memory pointer of location service handle.
 *                 It must be converted into location_service_h by GET_LOCATION_SERVICE().
 * @param[in] callback The callback function to be invoked
 * @param[in] user_data The user data passed to the callback function
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER	Invalid parameter
 * @retval #LOCATION_PREFERENCE_ERROR_NETWORK_FAILED Network unavailable
 * @retval #LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND Result not found
 * @post location_preference_available_language_cb() will be invoked.
 * @see	GET_LOCATION_SERVICE()
 * @see location_preference_available_language_cb()
 */
int location_preference_foreach_available_languages(location_service_h service, location_preference_available_language_cb callback, void* user_data);

/**
 * @brief Gets the location preference that was set in location preference.
 * @param[in] location_service The memory pointer of location service handle.
 *                 It must be converted into location_service_h by GET_LOCATION_SERVICE().
 * @param[in] key The property of location preference
 * @param[in] callback The callback function to be invoked
 * @param[in] user_data The user data passed to the callback function
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER	Invalid parameter
 * @see	GET_LOCATION_SERVICE()
 */
int location_preference_foreach_properties(location_service_h service, location_preference_property_cb callback, void* user_data);

/**
 * @brief Sets the location preference value.
 * @param[in] location_service The memory pointer of location service handle.
 *                 It must be converted into location_service_h by GET_LOCATION_SERVICE().
 * @param[in] property The property of location preference
 * @param[in] value The value of  location preference
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER	Invalid parameter
 * @see	GET_LOCATION_SERVICE()
 * @see location_preference_foreach_available_property_keys()
 * @see location_preference_foreach_available_property_values()
 * @see location_preference_get()
 */
int location_preference_set(location_service_h service, const char* key, const char* value);

/**
 * @brief Gets the location preference value.
 * @param[in] location_service The memory pointer of location service handle.
 *                 It must be converted into location_service_h by GET_LOCATION_SERVICE().
 * @param[in] property The property of location preference
 * @param[out] value The value of  location preference
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER	Invalid parameter
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_KEY Invalid key
 * @see	GET_LOCATION_SERVICE()
 * @see location_preference_foreach_available_property_keys()
 * @see location_preference_set()
 */
int location_preference_get(location_service_h service, const char* key, char** value);

/**
 * @brief Gets the provider name of location service.
 * @remarks The @a provider must be released with free() by you.
 * @param[in] location_service The memory pointer of location service handle.
 *                 It must be converted into location_service_h by GET_LOCATION_SERVICE().
 * @param[out] provider The provider name of location service
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER	Invalid parameter
 * @see	GET_LOCATION_SERVICE()
 */
int location_preference_get_provider_name(location_service_h service, char** provider);

/**
 * @brief Gets the distance unit of location service.
 * @param[in] location_service The memory pointer of location service handle.
 *                 It must be converted into location_service_h by GET_LOCATION_SERVICE().
 * @param[out] unit The distance unit
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER	Invalid parameter
 * @retval #LOCATION_PREFERENCE_ERROR_RESULT_NOT_FOUND Result not found
 * @see	GET_LOCATION_SERVICE()
 * @see	location_preference_set_distance_unit()
 */
int location_preference_get_distance_unit(location_service_h service, location_preference_distance_unit_e* unit);

/**
 * @brief Sets the distance unit of location service.
 * @param[in] location_service The memory pointer of location service handle.
 *                 It must be converted into location_service_h by GET_LOCATION_SERVICE().
 * @param[in] unit The distance unit
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER	Invalid parameter
 * @see	GET_LOCATION_SERVICE()
 * @see	location_preference_get_distance_unit()
 */
int location_preference_set_distance_unit(location_service_h service, location_preference_distance_unit_e unit);

/**
 * @brief Gets the language of location service.
 * @param[in] location_service The memory pointer of location service handle.
 *                 It must be converted into location_service_h by GET_LOCATION_SERVICE().
 * @param[out] language The language
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER	Invalid parameter
 * @see	GET_LOCATION_SERVICE()
 * @see	location_preference_set_language()
 */
int location_preference_get_language(location_service_h service, char** language);

/**
 * @brief Sets the language of location service.
 * @param[in] location_service The memory pointer of location service handle.
 *                 It must be converted into location_service_h by GET_LOCATION_SERVICE().
 * @param[in] language The language
 * @return 0 on success, otherwise a negative error value.
 * @retval #LOCATION_PREFERENCE_ERROR_NONE Successful
 * @retval #LOCATION_PREFERENCE_ERROR_INVALID_PARAMETER	Invalid parameter
 * @see	GET_LOCATION_SERVICE()
 * @see	location_preference_get_language()
 */
int location_preference_set_language(location_service_h service, const char* language);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* __TIZEN_LOCATION_LOCATION_PREFERENCE_H__ */