tizen 2.4 release
[framework/location/maps-plugin-here.git] / src / here / here_place.h
1 /*
2  * Copyright (c) 2014 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 _LOCATION_HERE_PLACE_H_
18 #define _LOCATION_HERE_PLACE_H_
19
20 #include <deque>
21
22 //plug-in header
23 #include "here_manager.h"
24
25 //maps-service header
26 #include <maps_place_plugin.h>
27 #include <maps_place_rating_plugin.h>
28 #include <maps_place_contact_plugin.h>
29 #include <maps_place_image_plugin.h>
30 #include <maps_place_link_object_plugin.h>
31 #include <maps_place_editorial_plugin.h>
32 #include <maps_place_review_plugin.h>
33
34 //map engine header
35 #include <finder/DiscoveryQuery.h>
36 #include <finder/PlaceDetailsQuery.h>
37 #include <finder/FinderQueryListener.h>
38 #include <finder/DiscoveryReply.h>
39 #include <finder/PlaceDetailsReply.h>
40 #include <finder/PlaceDetails.h>
41 #include <finder/CategoryId.h>
42 #include <finder/LinkObject.h>
43 #include <finder/Ratings.h>
44 #include <finder/RelatedItem.h>
45 #include <common/GeoLocation.h>
46 #include <common/Address.h>
47
48
49 HERE_PLUGIN_BEGIN_NAMESPACE
50
51 using namespace HERE_MAPS_NAMESPACE_PREFIX;
52
53 class HerePlace
54 : public HereBase
55 , public FinderQueryListener
56 {
57 public:
58         typedef std::deque<maps_place_h> PlaceList;
59
60         /**
61          *This is the default constructor for Place.
62          */
63
64         HerePlace(void *pCbFunc, void *pUserData, int nReqId);
65
66         /**
67          *This is the default destructor for Place.
68          */
69
70         ~HerePlace();
71
72         here_error_e PrepareDiscoveryQuery();
73         here_error_e PrepareDiscoveryPreference(maps_preference_h hPref);
74         here_error_e PrepareDiscoveryFilter(maps_place_filter_h hFilter);
75
76         here_error_e StartDiscoveryPlace(maps_coordinates_h hCoord, int nDistance);
77         here_error_e StartDiscoveryPlaceByArea(maps_area_h hArea);
78         here_error_e StartDiscoveryPlaceByAddress(const char *szAddr, maps_area_h hArea);
79
80         here_error_e PreparePlaceDetailsQuery();
81         here_error_e PreparePlaceDetailsPreference(maps_preference_h hPref);
82         
83         here_error_e StartPlaceDetails(const char* szPlaceId);
84         here_error_e StartPlaceDetailsInternal(const char* szUrl);
85
86         virtual void OnDiscoverReply(const DiscoveryReply &Reply);
87         virtual void OnPlaceDetailsReply(const PlaceDetailsReply &Reply);
88
89 private:
90         void ProcessPlaceLocation(PlaceDetails herePlace, maps_place_h mapsPlace);
91         void ProcessPlaceContact(PlaceDetails herePlace, maps_place_h mapsPlace);
92         void ProcessPlaceCategory(PlaceDetails herePlace, maps_place_h mapsPlace);
93         void ProcessPlaceImage(PlaceDetails herePlace, maps_place_h mapsPlace);
94         void ProcessPlaceDetails(PlaceDetails herePlace, maps_place_h mapsPlace);
95         void ProcessPlaceReviews(PlaceDetails herePlace, maps_place_h mapsPlace);
96         void ProcessPlaceRatings(PlaceDetails herePlace, maps_place_h mapsPlace);
97         void ProcessPlaceRated(PlaceDetails herePlace, maps_place_h mapsPlace);
98
99         void __sortList(PlaceList &list);
100         static bool __compareWithTitle(const maps_place_h &item1, const maps_place_h &item2);
101         static bool __compareWithId(const maps_place_h &item1, const maps_place_h &item2);
102         static bool __compareWithType(const maps_place_h &item1, const maps_place_h &item2);
103         static bool __compareWithDistance(const maps_place_h &item1, const maps_place_h &item2);
104         static bool __compareWithRating(const maps_place_h &item1, const maps_place_h &item2);
105         static bool __compareWithCategory(const maps_place_h &item1, const maps_place_h &item2);
106         static bool __compareWithCategoryCb(int index, int total, maps_place_category_h category,
107                                          void *user_data);
108
109         DiscoveryQuery* m_pDiscoveryQuery;
110         PlaceDetailsQuery* m_pPlaceDetailsQuery;
111         int m_nReplyCnt;
112         int m_nReplyIdx;
113         char *m_szSortBy;
114
115         PlaceList m_PlaceList;;
116
117         static const bool __sending_place_details_query_automatically = TRUE;
118 };
119
120 HERE_PLUGIN_END_NAMESPACE
121
122 #endif //_LOCATION_HERE_PLACE_H_