Migrate from 2.4 code repo
[platform/core/context/place-context-provider.git] / src / place_geofence / myplace_handle.h
1 /*
2  * Copyright (c) 2014 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 #ifndef __CONTEXT_PLACE_MYPLACE_HANDLE_H__
18 #define __CONTEXT_PLACE_MYPLACE_HANDLE_H__
19
20 #include <set>
21 #include <string>
22 #include <map>
23 #include <geofence_manager.h>
24
25 namespace ctx {
26
27         class myplace_handle {
28
29                 typedef std::map<int, geofence_state_e> geo_state_map_t;
30                 typedef std::set<std::string> string_set_t;
31
32                 public:
33                         myplace_handle();
34                         ~myplace_handle();
35
36                         bool start_monitor(int place_id);
37                         void add_zone(const char* zone);
38                         void remove_zone(const char* zone);
39                         bool zone_empty();
40                         int get_place_id();
41
42                 private:
43                         int _place_id;
44                         string_set_t _zone;
45                         geofence_state_e prev_state;
46                         geofence_manager_h geo_handle;
47                         geo_state_map_t geo_state_map;
48
49                         void emit_state_change();
50                         void stop_monitor();
51                         bool start_fence(int fence_id);
52                         void remove_fence(int fence_id);
53                         void update_fence(int fence_id, geofence_manage_e manage);
54                         void update_state(int fence_id, geofence_state_e state);
55
56                         static bool fence_list_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void* user_data);
57                         static void fence_event_cb(int place_id, int geofence_id, geofence_manager_error_e error, geofence_manage_e manage, void* user_data);
58                         static void fence_state_cb(int geofence_id, geofence_state_e state, void* user_data);
59         };
60
61 }       /* namespace ctx */
62
63 #endif /* __CONTEXT_PLACE_MYPLACE_HANDLE_H__ */