[ACR-476] Added mock location APIs
[platform/core/api/location-manager.git] / include / location_internal.h
1 /*
2  * Copyright (c) 2011-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 #ifndef __TIZEN_LOCATION_INTERNAL_H__
18 #define __TIZEN_LOCATION_INTERNAL_H__
19
20 #include <location.h>
21 #include <locations.h>
22 #include <dlog.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 #ifdef LOG_TAG
29 #undef LOG_TAG
30 #endif
31 #define LOG_TAG "CAPI_LOCATION_MANAGER"
32
33
34 /*
35 * Internal Macros
36 */
37 #define LOCATIONS_LOGD(fmt,args...) LOGD(fmt, ##args)
38 #define LOCATIONS_LOGW(fmt,args...) LOGW(fmt, ##args)
39 #define LOCATIONS_LOGI(fmt,args...) LOGI(fmt, ##args)
40 #define LOCATIONS_LOGE(fmt,args...) LOGE(fmt, ##args)
41
42 #define LOCATIONS_CHECK_CONDITION(condition, error, msg)        \
43         do { \
44                 if (condition) { \
45                 } else { \
46                         LOCATIONS_LOGE("%s(0x%08x)", msg, error); \
47                         return error; \
48                 } \
49         } while (0)
50
51
52 #define LOCATIONS_PRINT_ERROR_CODE(error, msg)  \
53         do { \
54                 LOCATIONS_LOGE("%s(0x%08x)", msg, error); \
55                 return error; \
56         } while (0)
57
58 #define LOCATIONS_NULL_ARG_CHECK(arg)   \
59         LOCATIONS_CHECK_CONDITION((arg != NULL),LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER") \
60
61 #define LOCATIONS_NOT_SUPPORTED_CHECK(arg)      \
62         LOCATIONS_CHECK_CONDITION((arg == LOCATIONS_ERROR_NONE),LOCATIONS_ERROR_NOT_SUPPORTED,"LOCATIONS_ERROR_NOT_SUPPORTED") \
63
64 typedef enum {
65         _LOCATIONS_EVENT_TYPE_SERVICE_STATE,
66         _LOCATIONS_EVENT_TYPE_POSITION,
67         _LOCATIONS_EVENT_TYPE_VELOCITY,
68         _LOCATIONS_EVENT_TYPE_BOUNDARY,
69         _LOCATIONS_EVENT_TYPE_SATELLITE,
70         _LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS,
71         _LOCATIONS_EVENT_TYPE_COLLECTION_STATE,
72         _LOCATIONS_EVENT_TYPE_LOCATION,
73         _LOCATIONS_EVENT_TYPE_BATCH,
74         _LOCATIONS_EVENT_TYPE_DISTANCE,
75         _LOCATIONS_EVENT_TYPE_POS_VEL,
76         _LOCATIONS_EVENT_TYPE_NUM
77 } _location_event_e;
78
79 typedef enum {
80         _LOCATION_SIGNAL_SERVICE_ENABLED,
81         _LOCATION_SIGNAL_SERVICE_DISABLED,
82         _LOCATION_SIGNAL_SERVICE_UPDATED,
83         _LOCATION_SIGNAL_ZONE_IN,
84         _LOCATION_SIGNAL_ZONE_OUT,
85         _LOCATION_SIGNAL_LOCATION_UPDATED,
86         _LOCATION_SIGNAL_BATCH_UPDATED,
87         _LOCATION_SIGNAL_ERROR_EMITTED,
88         _LOCATION_SIGNAL_STATUS_CHANGED,
89         _LOCATION_SIGNAL_NUM
90 } _location_signal_e;
91
92 typedef struct _location_manager_s {
93         LocationObject *object;
94         const void *user_cb[_LOCATIONS_EVENT_TYPE_NUM];
95         void *user_data[_LOCATIONS_EVENT_TYPE_NUM];
96         location_method_e method;
97         bool is_continue_foreach_bounds;
98         int collection_state;
99         GList *bounds_list;
100         guint timeout;
101         gulong sig_id[_LOCATION_SIGNAL_NUM];
102 } location_manager_s;
103
104 typedef struct _location_bounds_s {
105         LocationBoundary *boundary;
106         const void *user_cb;
107         void *user_data;
108         bool is_added;
109 } location_bounds_s;
110
111 typedef struct _location_setting_changed_s {
112         location_setting_changed_cb callback;
113         void *user_data;
114 } location_setting_changed_s;
115
116 /*
117 * Internal Functions
118 */
119 int __convert_error_code(int code);
120 int __is_gps_supported(void);
121 int __is_gps_satellite_supported(void);
122 int __is_wps_supported(void);
123 int __is_location_supported(void);
124 int __set_callback(_location_event_e type, location_manager_h manager, void *callback, void *user_data);
125 int __unset_callback(_location_event_e type, location_manager_h manager);
126
127 #ifdef __cplusplus
128 }
129 #endif
130
131 #endif /* __TIZEN_LOCATION_INTERNAL_H__ */