summaryrefslogtreecommitdiff
path: root/include/location_preference.h
blob: db780a6688ebe27b437873295a007086bf0a1292 (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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/*
 * Copyright (c) 2011-2013 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 available country code.
 * @param[in] country_code The country code of location preference
 * @param[in] user_data The user data passed from foreach function
 * @pre location_preference_foreach_available_country_code() 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_country_code()
 */
typedef bool (*location_preference_available_country_code_cb)(const char* country_code, 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 Called repeatedly to get each supported providers.
 * @param[in] provider The supported provider name
 * @param[in] user_data The user data passed from the foreach function
 * @return @c true to continue with the next iteration of the loop, \n @c false to break outsp of the loop.
 * @pre location_preference_foreach_supported_provider() will invoke this callback.
 * @see location_preference_foreach_supported_provider()
 */
typedef bool (*location_preference_supported_provider_cb)(const char* provider, 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 Retrieves the available country code 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_country_code_cb() will be invoked.
 * @see	GET_LOCATION_SERVICE()
 * @see location_preference_available_country_code_cb()
 */
int location_preference_foreach_available_country_code(location_service_h service, location_preference_available_country_code_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);

__attribute__ ((deprecated)) int location_preference_get_provider_name(location_service_h service, char** provider);

/**
 * @brief Sets the provider 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] 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()
 * @see location_preference_get_provider()
 */
int location_preference_set_provider(location_service_h service, char* provider);

/**
 * @brief Gets the provider 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()
 * @see location_preference_set_provider()
 */
int location_preference_get_provider(location_service_h service, char** provider);

/**
 * @brief Gets the default provider 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 default 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_default_provider(location_service_h service, char** provider);

/**
 * @brief Gets the provider 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] 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
 * @post	This function invokes location_preference_supported_provider_cb() to get all supported providers.
 * @see GET_LOCATION_SERVICE()
 * @see location_preference_set_provider()
 */
int location_preference_foreach_supported_provider(location_service_h service, location_preference_supported_provider_cb callback , void *user_data);

/**
 * @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);

/**
 * @brief Sets the country code.
 * @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] country_code The country code
 * @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_country_code()
 */
int location_preference_set_country_code(location_service_h service, const char* country_code);

/**
 * @brief Gets the country code.
 * @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] country_code The country code
 * @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_country_code()
 */
int location_preference_get_country_code(location_service_h service, char** country_code);

/**
 * @brief Sets the account.
 * @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] maps_key The maps key
 * @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_maps_key()
 */
int location_preference_set_maps_key(location_service_h service, const char* maps_key);

/**
 * @brief Gets the account.
 * @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] maps_key The maps key
 * @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_maps_key()
 */
int location_preference_get_maps_key(location_service_h service, char** maps_key);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* __TIZEN_LOCATION_LOCATION_PREFERENCE_H__ */