Support searching place category list 83/89583/2
authorchanywa <cbible.kim@samsung.com>
Mon, 26 Sep 2016 05:46:20 +0000 (14:46 +0900)
committerchanywa <cbible.kim@samsung.com>
Wed, 12 Oct 2016 23:31:02 +0000 (08:31 +0900)
Change-Id: I23dc6288ff189efd2c6d54ec414841b58a991745

22 files changed:
inc/engine/finder/BaseFinderReply.h
inc/engine/finder/CategoriesQuery.h [new file with mode: 0644]
inc/engine/finder/CategoriesReply.h [new file with mode: 0644]
inc/engine/finder/FinderQueryListener.h
inc/engine/internal/JsonParser.h [changed mode: 0644->0755]
inc/here_api.h
inc/here_place.h
lib/aarch64/libheremaps-engine.so.1
lib/aarch64/libheremaps-engine.so.1.0.6_19 [deleted file]
lib/aarch64/libheremaps-engine.so.1.0.6_20 [new file with mode: 0755]
lib/arm/libheremaps-engine.so.1
lib/arm/libheremaps-engine.so.1.0.6_19 [deleted file]
lib/arm/libheremaps-engine.so.1.0.6_20 [new file with mode: 0755]
lib/i586/libheremaps-engine.so.1
lib/i586/libheremaps-engine.so.1.0.6_19 [deleted file]
lib/i586/libheremaps-engine.so.1.0.6_20 [new file with mode: 0755]
lib/x86_64/libheremaps-engine.so.1
lib/x86_64/libheremaps-engine.so.1.0.6_19 [deleted file]
lib/x86_64/libheremaps-engine.so.1.0.6_20 [new file with mode: 0755]
src/here_api.cpp
src/here_place.cpp
src/here_plugin.cpp

index c9f7568640697f96b2701fc70ad65d4b95e6b7d7..a483cc4a2a7b199b08ca2d2772ff566cc01bc57b 100644 (file)
@@ -34,7 +34,10 @@ public:
     enum ReplyType
     {
         RT_Discovery = 0, // Indicates a reply to a discovery query.
-        RT_PlaceDetails   // Indicates a reply to a request for place details.
+        RT_PlaceDetails,  // Indicates a reply to a request for place details.
+#ifdef TIZEN_CUSTOMIZATION
+        RT_Categories     // Indicates a reply to a request for categories.
+#endif
     };
     /**
      * This method is the constructor.
diff --git a/inc/engine/finder/CategoriesQuery.h b/inc/engine/finder/CategoriesQuery.h
new file mode 100644 (file)
index 0000000..bcd2351
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2013 HERE Global B.V. All rights reserved.
+ * This software, including documentation, is protected by copyright controlled by
+ * HERE Global B.V. (“Software”). All rights are reserved. Copying, including reproducing,
+ * storing, adapting or translating, any or all of this material requires the prior
+ * written consent of HERE Global B.V. You may use this
+ * Software in accordance with the terms and conditions defined in the
+ * HERE Location Platform Services Terms and Conditions, available at
+ * http://developer.here.com/terms-conditions-base
+ *
+ * As an additional permission to the above, you may distribute Software,
+ * in object code format as part of an Application, according to, and subject to, terms and
+ * conditions defined in the Tizen Software Development kit (“SDK”) License Agreement.
+ * You may distribute such object code format Application under terms of your choice,
+ * provided that the header and source files of the Software have not been modified.
+ */
+
+#ifndef CATEGORIES_QUERY_H_
+#define CATEGORIES_QUERY_H_
+
+#include "common/HereMaps_global.h"
+#include "common/BaseQuery.h"
+#include "finder/Category.h"
+#include "common/GeoBoundingArea.h"
+
+#ifdef TIZEN_CUSTOMIZATION
+HERE_MAPS_BEGIN_NAMESPACE
+
+class QueryListener;
+class GeoCoordinates;
+class FinderQueryListener;
+class FinderError;
+
+/**
+ * This class encapsulates a places discovery query.
+ *
+ * \ingroup finder
+ */
+class EXPORT_API CategoriesQuery : public BaseQuery
+{
+public:
+   /**
+    * This enumeration defines identifiers for the supported discovery query
+    * types.
+    */
+    enum QueryType
+    {
+        QT_PLACES = 0, ///< Indicates a query that searches for places.
+        QT_CUISINES,   ///< Indicates a query that searches for cuisines.
+    };
+
+    /**
+     * This enumeration defines identifiers for the supported discovery query
+     * result types.
+     */
+    /*
+     * The identifiers are not valid for search QueryTypes.
+     */
+    enum ResultTypes
+    {
+        SIT_CATEGORY = 0,   ///< Indicates that the result contains only category items
+    };
+
+public:
+
+    /**
+     * This method is the default constructor.
+     */
+    CategoriesQuery();
+
+    /**
+     * This method is a constructor. It constructs a valid <code>CategoriesQuery</code> from
+     * a URL provided by the caller.
+     *
+     * @param sUrl A constant reference to the URL of the location whose details
+     *        are to be retrieved from the server
+     */
+    CategoriesQuery(const  String& sUrl);
+
+    /**
+     * This method is the (virtual) destructor.
+     */
+    virtual ~CategoriesQuery();
+
+    /**
+     * This method retrieves a value indicating the query type.
+     *
+     * @return A value indicating the query type.
+     */
+    QueryType GetType() const;
+
+    /**
+     * This method sets the query type.
+     *
+     * @param eType A value indicating the query type.
+     */
+    void SetType(QueryType eType);
+
+    /**
+     * This method retrieves the search proximity.
+     *
+     * @return An object containing the geographic coordinates of the location
+     *        around which the search is/was to be conducted and within whose
+     *        proximity the results must lie.
+     */
+    GeoCoordinates GetProximity() const;
+
+    /**
+     * This method sets search proximity.
+     *
+     * @param rCoord An object containing the geographic coordinates of the
+     *        location around which the search is/was to be conducted and within
+     *        whose proximity the results must lie.
+     */
+    void SetProximity(const GeoCoordinates& rCoord);
+
+    /**
+     * This method retrieves a BCP 47 identifier of the search language.
+     *
+     * @return A string containing a BCP 47 identifier of the language.
+     */
+    String GetLanguage() const;
+
+    /**
+     * This method sets the langauge, using a BCP 47 langauge code.
+     *
+     * @param sSearch A constant reference to a string containing a BCP 47
+     *        identifier of the language.
+     */
+    void SetLanguage(const String& sLang);
+
+
+    /**
+     * This method attempts to establish a connection
+     * with the server and then, if the connection has been established, it
+     * builds and submits a query.
+     *
+     * @param rDst A reference to an object that is to be notified when the
+     *        reply to the query has arrived from the server.
+     *
+     * @param pUserData A pointer to user data to be passed back within the
+     *        corresponding reply object.
+     *
+     * @return Identifier of issued request.
+     */
+    RestItemHandle::RequestId Execute(FinderQueryListener& rListener, Tizen::Maps::HereObject* pUserData = NULL) const;
+
+    /**
+     * This method retrieves error information associated with the query.
+     *
+     * @return A constant pointer to an object containing the error details.
+     */
+    const FinderError* GetError() const;
+
+    /**
+     * This static method returns the base URI to be used for all subsequent
+     * discovery queries.
+     *
+     * @return A string containing the base URI.
+     */
+    static String GetBaseUri();
+
+    /**
+     * This static method returns the base URI to be used for all subsequent
+     * discovery queries.
+     *
+     * @param sUri A constant reference to a string containing the base URI.
+     */
+    static void SetBaseUri(const String& sUri);
+
+private:
+
+    /**
+     * This method creates the URI for the request.
+     *
+     * @return URI request string.
+     */
+    String CreateUri() const;
+
+    bool AppendService(CategoriesQuery::QueryType eType, String& sDst) const;
+
+private:
+    HERE_MAPS_NO_COPY_NO_ASSIGN(CategoriesQuery);
+
+    class CategoriesQueryImpl;
+    CategoriesQueryImpl* m_pImpl;
+
+    friend class CategoriesReply;
+
+    static String s_sBaseUri;
+
+};
+
+HERE_MAPS_END_NAMESPACE
+#endif
+
+#endif // CATEGORIES_QUERY_H_
diff --git a/inc/engine/finder/CategoriesReply.h b/inc/engine/finder/CategoriesReply.h
new file mode 100644 (file)
index 0000000..0a9dd16
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 HERE Global B.V. All rights reserved.
+ * This software, including documentation, is protected by copyright controlled by
+ * HERE Global B.V. (“Software”). All rights are reserved. Copying, including reproducing,
+ * storing, adapting or translating, any or all of this material requires the prior
+ * written consent of HERE Global B.V. You may use this
+ * Software in accordance with the terms and conditions defined in the
+ * HERE Location Platform Services Terms and Conditions, available at
+ * http://developer.here.com/terms-conditions-base
+ *
+ * As an additional permission to the above, you may distribute Software,
+ * in object code format as part of an Application, according to, and subject to, terms and
+ * conditions defined in the Tizen Software Development kit (“SDK”) License Agreement.
+ * You may distribute such object code format Application under terms of your choice,
+ * provided that the header and source files of the Software have not been modified.
+ */
+
+#ifndef CATEGORIES_REPLY_H_
+#define CATEGORIES_REPLY_H_
+
+#include "finder/BaseFinderReply.h"
+#include "finder/CategoriesQuery.h"
+
+HERE_MAPS_BEGIN_NAMESPACE
+
+/**
+ * This class encapsulates a response to a discovery query. The response is a
+ * page of link objects, each containing information about one place. It also
+ * includes a link to the next page of results, if available.
+ *
+ * \ingroup finder
+ */
+class EXPORT_API CategoriesReply : public BaseFinderReply
+{
+public:
+
+    /**
+     * This is the default constructor.
+     */
+    CategoriesReply();
+
+    /**
+     * This is the (virtual) destructor.
+     */
+    virtual ~CategoriesReply();
+
+    /**
+     * This method retrieves a list of search result items that can lead an
+     * application user to detailed information about specific places.
+     *
+     * @return A vector of instances of <code>SearchItem</code> which represent
+     *       individual search results.
+     */
+    CategoryList GetCategoryList() const;
+
+private:
+    void SetCategoryList(const CategoryList&);
+
+private:
+    HERE_MAPS_NO_COPY_NO_ASSIGN(CategoriesReply);
+
+    virtual bool OnDataReceived(const unsigned char* pBuffer, size_t uSize);
+
+    class CategoriesReplyImpl;
+    CategoriesReplyImpl* m_pImpl;
+
+    friend class JsonParser;
+};
+
+HERE_MAPS_END_NAMESPACE
+
+#endif // CATEGORIES_REPLY_H_
index 9a84d48ac9b9addb637729e222638b06ea378bd4..e9fde4936d15c54cfa14f5697ec80819e56b5e9b 100644 (file)
@@ -26,6 +26,9 @@ HERE_MAPS_BEGIN_NAMESPACE
 
 class DiscoveryReply;
 class PlaceDetailsReply;
+#ifdef TIZEN_CUSTOMIZATION
+class CategoriesReply;
+#endif
 
 /**
  * This class encapsulates an object that is notified when a response to a query
@@ -71,6 +74,16 @@ public:
      */
     virtual void OnPlaceDetailsReply(const PlaceDetailsReply& rReply) = 0;
 
+       #ifdef TIZEN_CUSTOMIZATION
+    /**
+     * This method is a callback invoked when data have arrived in response to a
+     * categories request.
+     *
+     * @param rReply A constant reference to an object containing the response data.
+     */
+    virtual void OnCategoriesReply(const CategoriesReply& rReply) = 0;
+       #endif
+
     #ifdef TIZEN_MIGRATION
     /**
      * This method is a callback invoked when geocoding request is failed.
@@ -80,6 +93,15 @@ public:
     virtual void OnPlaceDetailsFailure(const PlaceDetailsReply& rReply) = 0;
     #endif
 
+       #ifdef TIZEN_CUSTOMIZATION
+    /**
+     * This method is a callback invoked when categories request is failed.
+     *
+     * @param rReply A Constant reference to an object containing the response data.
+     */
+    virtual void OnCategoriesFailure(const CategoriesReply& rReply) = 0;
+    #endif
+
 private:
     HERE_MAPS_NO_COPY_NO_ASSIGN(FinderQueryListener);
 
old mode 100644 (file)
new mode 100755 (executable)
index 0ca02e2..1b6bcc9
@@ -66,6 +66,9 @@ class Ratings;
 class GeoBoundingBox;
 class SearchContext;
 class FinderError;
+#ifdef TIZEN_CUSTOMIZATION
+class CategoriesReply;
+#endif
 
 /**
  * Parses Places API Json data.
@@ -94,6 +97,17 @@ public:
      */
     static bool ParsePlaceResult( ByteBuffer& buf, PlaceDetails& place_data, FinderError*& error);
 
+#ifdef TIZEN_CUSTOMIZATION
+    /**
+     * Parse categories result.
+     * @param json_stream ByteBuffer.
+     * @param place_data Parsed categories data.
+     * @param error A pointer to an object that is populated
+     *        with error information should parsing fail.
+     */
+       static bool ParseCategoriesSearch( ByteBuffer& buf, CategoriesReply& results_page, FinderError*& pError );
+#endif
+
 private:
 
     static void ParseGeocodeSearch( ByteBuffer& json_stream,
@@ -179,6 +193,9 @@ private:
     static void ParseAddress( IJsonValue* json_location, GeoLocation& loc );
 
     static void ParsePlaceResults(JsonArray* pObject, PlaceItemList&, SearchItemList& );
+#ifdef TIZEN_CUSTOMIZATION
+       static void ParseCategoriesSearch( IJsonValue* pJsonValue, CategoriesReply& result );
+#endif
 
 private:
     static void GetStringValue(JsonObject* pObject, const String& sKey, String& value );
index 458ffee9c388012195ee130c965d215ba0461560..c2d402baee2d864043767179a2d40b1facbe5b20 100644 (file)
@@ -67,9 +67,11 @@ int HerePluginSearchPlaceList(maps_area_h hArea, maps_item_hashtable_h hPref,
        maps_place_filter_h hFilter, maps_service_search_place_list_cb pCbFunc,
        void * pUserData, int *nReqId);
 
-int HerePluginSearchPlaceDetails(const char* szUrl,
-       maps_service_get_place_details_cb pCbFunc,
-       void * pUserData, int *nReqId);
+int HerePluginGetPlaceDetails(const char* szUrl,
+       maps_service_get_place_details_cb pCbFunc, void * pUserData, int *nReqId);
+
+int HerePluginGetPlaceCategories(maps_item_hashtable_h hPref,
+       maps_service_get_place_categories_cb pCbFunc, void *pUserData, int *nReqId);
 
 int HerePluginSearchRoute(maps_coordinates_h hOrigin, maps_coordinates_h hDestination,
        maps_item_hashtable_h hPref, maps_service_search_route_cb pCbFunc,
index 419e5a7e7aafd4681e086404a34693aa30081521..83017b8fe3ea885fa78bd261eb883bd903b7b658 100644 (file)
@@ -46,6 +46,8 @@
 #include <finder/Ratings.h>
 #include <finder/RelatedItem.h>
 #include <finder/ExtendedAttribute.h>
+#include <finder/CategoriesQuery.h>
+#include <finder/CategoriesReply.h>
 #include <common/GeoLocation.h>
 #include <common/Address.h>
 
@@ -60,6 +62,7 @@ class HerePlace
 {
 public:
        typedef std::deque<maps_place_h> PlaceList;
+       typedef std::deque<maps_place_category_h> PlaceCategoryList;
 
        /**
         *This is the default constructor for Place.
@@ -83,16 +86,27 @@ public:
 
        here_error_e PreparePlaceDetailsQuery();
        here_error_e PreparePlaceDetailsPreference(maps_preference_h hPref);
+       here_error_e PreparePlaceDetailsPreference(PlaceDetailsQuery* pPlaceDetailsQuery, maps_preference_h hPref);
 
        here_error_e StartPlaceDetails(const char* szUrl);
        here_error_e StartPlaceDetailsInternal(const char* szUrl);
 
+       here_error_e PrepareCategoriesQuery();
+       here_error_e PrepareCategoriesPreference(maps_preference_h hPref);
+       here_error_e PrepareCategoriesPreference(PlaceDetailsQuery* pPlaceDetailsQuery, maps_preference_h hPref);
+       here_error_e PrepareCategoriesFilter(maps_place_filter_h hFilter);
+
+       here_error_e StartCategories();
+
        virtual void OnDiscoverReply(const DiscoveryReply &Reply);
        virtual void OnDiscoverFailure(const DiscoveryReply& Reply);
 
        virtual void OnPlaceDetailsReply(const PlaceDetailsReply &Reply);
        virtual void OnPlaceDetailsFailure(const PlaceDetailsReply& Reply);
 
+       virtual void OnCategoriesReply(const CategoriesReply &Reply);
+       virtual void OnCategoriesFailure(const CategoriesReply& Reply);
+
 private:
        void ProcessPlaceLocation(PlaceDetails herePlace, maps_place_h mapsPlace);
        void ProcessPlaceContacts(PlaceDetails herePlace, maps_place_h mapsPlace);
@@ -108,7 +122,8 @@ private:
        bool ProcessPlaceLinkObject(LinkObject hereLinkObject, maps_place_link_object_h mapsLinkObject);
 
        void __sortList(PlaceList &list);
-       void __flushReplies(int error);
+       void __flushPlaceReplies(int error);
+       void __flushCategoriesReplies(int error);
        static bool __compareWithTitle(const maps_place_h &item1, const maps_place_h &item2);
        static bool __compareWithId(const maps_place_h &item1, const maps_place_h &item2);
        static bool __compareWithType(const maps_place_h &item1, const maps_place_h &item2);
@@ -120,6 +135,7 @@ private:
 
        DiscoveryQuery* m_pDiscoveryQuery;
        PlaceDetailsQuery* m_pPlaceDetailsQuery;
+       CategoriesQuery* m_pCategoriesQuery;
        int m_nReplyCnt;
        int m_nReplyIdx;
        bool m_bReplyFlushed;
@@ -130,6 +146,7 @@ private:
        maps_distance_unit_e m_eDistanceUnit;
 
        PlaceList m_PlaceList;
+       PlaceCategoryList m_CategoryList;
 
        static const bool __sending_place_details_query_automatically = TRUE;
 };
index 7b330ec1acf01fa4878bed149c9a41bdd2a2f28b..3585e21658538e30d2fcf48765953e44353acadd 120000 (symlink)
@@ -1 +1 @@
-libheremaps-engine.so.1.0.6_19
\ No newline at end of file
+libheremaps-engine.so.1.0.6_20
\ No newline at end of file
diff --git a/lib/aarch64/libheremaps-engine.so.1.0.6_19 b/lib/aarch64/libheremaps-engine.so.1.0.6_19
deleted file mode 100755 (executable)
index 6b027ae..0000000
Binary files a/lib/aarch64/libheremaps-engine.so.1.0.6_19 and /dev/null differ
diff --git a/lib/aarch64/libheremaps-engine.so.1.0.6_20 b/lib/aarch64/libheremaps-engine.so.1.0.6_20
new file mode 100755 (executable)
index 0000000..61a8325
Binary files /dev/null and b/lib/aarch64/libheremaps-engine.so.1.0.6_20 differ
index 7b330ec1acf01fa4878bed149c9a41bdd2a2f28b..3585e21658538e30d2fcf48765953e44353acadd 120000 (symlink)
@@ -1 +1 @@
-libheremaps-engine.so.1.0.6_19
\ No newline at end of file
+libheremaps-engine.so.1.0.6_20
\ No newline at end of file
diff --git a/lib/arm/libheremaps-engine.so.1.0.6_19 b/lib/arm/libheremaps-engine.so.1.0.6_19
deleted file mode 100755 (executable)
index 6abf00d..0000000
Binary files a/lib/arm/libheremaps-engine.so.1.0.6_19 and /dev/null differ
diff --git a/lib/arm/libheremaps-engine.so.1.0.6_20 b/lib/arm/libheremaps-engine.so.1.0.6_20
new file mode 100755 (executable)
index 0000000..de9303b
Binary files /dev/null and b/lib/arm/libheremaps-engine.so.1.0.6_20 differ
index 7b330ec1acf01fa4878bed149c9a41bdd2a2f28b..3585e21658538e30d2fcf48765953e44353acadd 120000 (symlink)
@@ -1 +1 @@
-libheremaps-engine.so.1.0.6_19
\ No newline at end of file
+libheremaps-engine.so.1.0.6_20
\ No newline at end of file
diff --git a/lib/i586/libheremaps-engine.so.1.0.6_19 b/lib/i586/libheremaps-engine.so.1.0.6_19
deleted file mode 100755 (executable)
index 444a9c3..0000000
Binary files a/lib/i586/libheremaps-engine.so.1.0.6_19 and /dev/null differ
diff --git a/lib/i586/libheremaps-engine.so.1.0.6_20 b/lib/i586/libheremaps-engine.so.1.0.6_20
new file mode 100755 (executable)
index 0000000..daf60cd
Binary files /dev/null and b/lib/i586/libheremaps-engine.so.1.0.6_20 differ
index 7b330ec1acf01fa4878bed149c9a41bdd2a2f28b..3585e21658538e30d2fcf48765953e44353acadd 120000 (symlink)
@@ -1 +1 @@
-libheremaps-engine.so.1.0.6_19
\ No newline at end of file
+libheremaps-engine.so.1.0.6_20
\ No newline at end of file
diff --git a/lib/x86_64/libheremaps-engine.so.1.0.6_19 b/lib/x86_64/libheremaps-engine.so.1.0.6_19
deleted file mode 100755 (executable)
index f490b6b..0000000
Binary files a/lib/x86_64/libheremaps-engine.so.1.0.6_19 and /dev/null differ
diff --git a/lib/x86_64/libheremaps-engine.so.1.0.6_20 b/lib/x86_64/libheremaps-engine.so.1.0.6_20
new file mode 100755 (executable)
index 0000000..f191594
Binary files /dev/null and b/lib/x86_64/libheremaps-engine.so.1.0.6_20 differ
index 70875926780a94c121b3db891319b89cb74507d1..249c22b7aadb60781cb3ce03ce7a1edcf9ddc936 100644 (file)
@@ -517,9 +517,8 @@ int HerePluginSearchPlaceList(maps_area_h hArea, maps_item_hashtable_h hPref,
        return error;
 }
 
-int HerePluginSearchPlaceDetails(const char* szUrl,
-       maps_service_get_place_details_cb pCbFunc,
-       void *pUserData, int *nReqId)
+int HerePluginGetPlaceDetails(const char* szUrl,
+       maps_service_get_place_details_cb pCbFunc, void *pUserData, int *nReqId)
 {
        /* checking parmaters */
        if (!szUrl || (szUrl && *szUrl == '\0') || !pCbFunc || !nReqId)
@@ -556,6 +555,47 @@ int HerePluginSearchPlaceDetails(const char* szUrl,
        return error;
 }
 
+int HerePluginGetPlaceCategories(maps_item_hashtable_h hPref,
+       maps_service_get_place_categories_cb pCbFunc, void *pUserData, int *nReqId)
+{
+       /* checking parmaters */
+       if (!pCbFunc || !nReqId)
+               return HERE_ERROR_INVALID_PARAMETER;
+
+       if (HereManager::CheckAgreement() != HERE_ERROR_NONE)
+               return HERE_ERROR_PERMISSION_DENIED;
+
+       if (!HereManager::GetHandler())
+               return HERE_ERROR_INVALID_OPERATION;
+
+       /* creating instance */
+       HerePlace *pPlace =
+               (HerePlace*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_PLACE,
+               (void*)pCbFunc, pUserData, nReqId));
+
+       if(!pPlace)
+               return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+       /* sending request */
+       here_error_e error = HERE_ERROR_NONE;
+
+       do {
+               error = pPlace->PrepareCategoriesQuery();
+               if (error != HERE_ERROR_NONE) break;
+
+               error = pPlace->PrepareCategoriesPreference(hPref);
+               if (error != HERE_ERROR_NONE) break;
+
+               error = pPlace->StartCategories();
+       } while (0);
+
+       /* finishing task */
+       if(error != HERE_ERROR_NONE)
+               pPlace->TerminateService();
+
+       return error;
+}
+
 int HerePluginSearchRoute(maps_coordinates_h hOrigin, maps_coordinates_h hDestination,
        maps_item_hashtable_h hPref, maps_service_search_route_cb pCbFunc,
        void *pUserData, int *nReqId)
index 2bca429ad8e15976049f4988010436cc50aa9414..8aab3ca965432e1c423acc66fc82a42bdbecc829 100644 (file)
@@ -22,6 +22,8 @@ HerePlace::HerePlace(void *pCbFunc, void *pUserData, int nReqId)
 {
        m_pDiscoveryQuery = NULL;
        m_pPlaceDetailsQuery = NULL;
+       m_pCategoriesQuery = NULL;
+       
 
        m_pCbFunc = pCbFunc;
        m_pUserData = pUserData;
@@ -49,6 +51,11 @@ HerePlace::~HerePlace()
                m_pPlaceDetailsQuery = NULL;
        }
 
+       if (m_pCategoriesQuery) {
+               delete m_pCategoriesQuery;
+               m_pCategoriesQuery = NULL;
+       }
+
        while (!m_PlaceList.empty()) {
                maps_place_destroy(m_PlaceList.front());
                m_PlaceList.pop_front();
@@ -295,7 +302,12 @@ here_error_e HerePlace::PreparePlaceDetailsQuery()
 
 here_error_e HerePlace::PreparePlaceDetailsPreference(maps_preference_h hPref)
 {
-       if (!m_pPlaceDetailsQuery)
+       return PreparePlaceDetailsPreference(m_pPlaceDetailsQuery, hPref);
+}
+
+here_error_e HerePlace::PreparePlaceDetailsPreference(PlaceDetailsQuery* pPlaceDetailsQuery, maps_preference_h hPref)
+{
+       if (!pPlaceDetailsQuery)
                return HERE_ERROR_OUT_OF_MEMORY;
 
        if (!hPref)
@@ -305,7 +317,7 @@ here_error_e HerePlace::PreparePlaceDetailsPreference(maps_preference_h hPref)
        char *szLanguage = NULL;
        ret = maps_preference_get_language(hPref, &szLanguage);
        if (ret == MAPS_ERROR_NONE && szLanguage && *szLanguage)
-               m_pPlaceDetailsQuery->SetLanguage(szLanguage);
+               pPlaceDetailsQuery->SetLanguage(szLanguage);
        g_free(szLanguage);
 
        maps_distance_unit_e eUnit;
@@ -344,6 +356,66 @@ here_error_e HerePlace::StartPlaceDetailsInternal(const char *szUrl)
        return (bExcuted ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
 }
 
+here_error_e HerePlace::PrepareCategoriesQuery()
+{
+       if (m_pCategoriesQuery)
+               return HERE_ERROR_PERMISSION_DENIED;
+
+        m_pCategoriesQuery = new (std::nothrow) CategoriesQuery();
+
+       if (!m_pCategoriesQuery)
+               return HERE_ERROR_OUT_OF_MEMORY;
+       else
+               return HERE_ERROR_NONE;
+}
+
+here_error_e HerePlace::PrepareCategoriesPreference(maps_preference_h hPref)
+{
+       if (!m_pCategoriesQuery)
+               return HERE_ERROR_OUT_OF_MEMORY;
+
+       if (!hPref)
+               return HERE_ERROR_NONE;
+
+       int ret;
+       char *szLanguage = NULL;
+       ret = maps_preference_get_language(hPref, &szLanguage);
+       if (ret == MAPS_ERROR_NONE && szLanguage && *szLanguage)
+               m_pCategoriesQuery->SetLanguage(szLanguage);
+       g_free(szLanguage);
+
+       maps_distance_unit_e eUnit;
+       ret = maps_preference_get_distance_unit(hPref, &eUnit);
+       if (ret == MAPS_ERROR_NONE)
+               m_eDistanceUnit = eUnit;
+
+       return HERE_ERROR_NONE;
+}
+
+here_error_e HerePlace::PrepareCategoriesFilter(maps_place_filter_h hFilter)
+{
+       if (!m_pCategoriesQuery)
+               return HERE_ERROR_OUT_OF_MEMORY;
+
+       if (!hFilter)
+               return HERE_ERROR_INVALID_PARAMETER;
+
+       return HERE_ERROR_NONE;
+}
+
+here_error_e HerePlace::StartCategories()
+{
+       GeoCoordinates geoCoord;
+       geoCoord.SetLatitude(0.);
+       geoCoord.SetLongitude(0.);
+       m_pCategoriesQuery->SetProximity(geoCoord);
+
+       /* Execute query */
+       m_nRestReqId = m_pCategoriesQuery->Execute(*this, NULL);
+
+       return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
+}
+
 void HerePlace::OnDiscoverReply(const DiscoveryReply &Reply)
 {
        maps_place_h mapsPlace;
@@ -520,7 +592,7 @@ void HerePlace::OnDiscoverReply(const DiscoveryReply &Reply)
                if (m_nReplyCnt == 0)
                        error = MAPS_ERROR_NOT_FOUND;
 
-               __flushReplies(error);
+               __flushPlaceReplies(error);
                delete this;
        }
 }
@@ -530,7 +602,7 @@ void HerePlace::OnDiscoverFailure(const DiscoveryReply& Reply)
        if (!m_bReplyFlushed) {
                m_nReplyIdx = 0;
                m_nReplyCnt = 0;
-               __flushReplies((maps_error_e)GetErrorCode(Reply));
+               __flushPlaceReplies((maps_error_e)GetErrorCode(Reply));
                delete this;
        }
 }
@@ -639,7 +711,7 @@ void HerePlace::OnPlaceDetailsReply(const PlaceDetailsReply &Reply)
                if (m_nReplyCnt == 0)
                        error = MAPS_ERROR_NOT_FOUND;
 
-               __flushReplies(error);
+               __flushPlaceReplies(error);
                delete this;
        }
 }
@@ -650,7 +722,7 @@ void HerePlace::OnPlaceDetailsFailure(const PlaceDetailsReply& Reply)
                if (!m_bReplyFlushed) {
                        m_nReplyIdx = 0;
                        m_nReplyCnt = 0;
-                       __flushReplies(GetErrorCode(Reply));
+                       __flushPlaceReplies(GetErrorCode(Reply));
                        delete this;
                }
        } else {
@@ -658,12 +730,63 @@ void HerePlace::OnPlaceDetailsFailure(const PlaceDetailsReply& Reply)
                MAPS_LOGD("Internal error during updating detailed information for the place. (%d/%d)", m_nReplyIdx, m_nReplyCnt);
                if (!m_bReplyFlushed && (m_nReplyIdx == m_nReplyCnt))
                {
-                       __flushReplies(MAPS_ERROR_NONE);
+                       __flushPlaceReplies(MAPS_ERROR_NONE);
                        delete this;
                }
        }
 }
 
+void HerePlace::OnCategoriesReply(const CategoriesReply &Reply)
+{
+       CategoryList hereCategoryList = Reply.GetCategoryList();
+       CategoryList::iterator hereCategoryIt;
+
+       int error = MAPS_ERROR_NONE, sub_error;
+       bool is_valid;
+       maps_place_category_h mapsCategory;
+       m_nReplyIdx = 0;
+       m_nReplyCnt = 0;
+
+       for (hereCategoryIt = hereCategoryList.begin();
+               hereCategoryIt != hereCategoryList.end();
+               hereCategoryIt++) {
+               is_valid = false;
+
+               if (maps_place_category_create(&mapsCategory) == MAPS_ERROR_NONE) {
+                       if (!hereCategoryIt->GetCategoryId().ToString().empty()) {
+                               sub_error = maps_place_category_set_id(mapsCategory, (char*)hereCategoryIt->GetCategoryId().ToString().data());
+                               is_valid |= (sub_error == MAPS_ERROR_NONE);
+                       }
+
+                       if (!hereCategoryIt->GetTitle().empty()) {
+                               sub_error = maps_place_category_set_name(mapsCategory, (char*)hereCategoryIt->GetTitle().data());
+                               is_valid |= (sub_error == MAPS_ERROR_NONE);
+                       }
+
+                       if (!hereCategoryIt->GetHref().empty()) {
+                               sub_error = maps_place_category_set_url(mapsCategory, (char*)hereCategoryIt->GetHref().data());
+                               is_valid |= (sub_error == MAPS_ERROR_NONE);
+                       }
+
+                       if (is_valid && !m_bCanceled) {
+                               m_CategoryList.push_back(mapsCategory);
+                               m_nReplyCnt++;
+                       }
+                       else
+                               maps_place_category_destroy(mapsCategory);
+               }
+       }
+
+       __flushCategoriesReplies(error);
+       delete this;
+}
+
+void HerePlace::OnCategoriesFailure(const CategoriesReply& Reply)
+{
+       MAPS_LOGD("Internal error during updating detailed information for the place.");
+       delete this;
+}
+
 void HerePlace::ProcessPlaceLocation(PlaceDetails herePlace, maps_place_h mapsPlace)
 {
        GeoLocation hereLocation = herePlace.GetLocation();
@@ -1200,7 +1323,7 @@ bool HerePlace::ProcessPlaceLinkObject(LinkObject hereLinkObject, maps_place_lin
        return is_valid;
 }
 
-void HerePlace::__flushReplies(int error)
+void HerePlace::__flushPlaceReplies(int error)
 {
        maps_place_h mapsPlace;
        maps_item_list_h placeList = NULL;
@@ -1259,6 +1382,32 @@ void HerePlace::__flushReplies(int error)
        m_bReplyFlushed = true;
 }
 
+void HerePlace::__flushCategoriesReplies(int error)
+{
+       maps_place_category_h category;
+       m_nReplyIdx = 0;
+       m_nReplyCnt = m_CategoryList.size();
+
+       if (error == MAPS_ERROR_NONE && m_nReplyCnt == 0)
+               error = MAPS_ERROR_NOT_FOUND;
+
+       if (error != MAPS_ERROR_NONE) {
+               ((maps_service_get_place_categories_cb)m_pCbFunc)((maps_error_e)error, m_nReqId, 0, 0, NULL, m_pUserData);
+               return;
+       }
+
+       while (m_nReplyIdx < m_nReplyCnt && !m_bCanceled && !m_CategoryList.empty()) {
+               category = m_CategoryList.front();
+               m_CategoryList.pop_front();
+
+               /* callback function */
+               if (((maps_service_get_place_categories_cb)m_pCbFunc)((maps_error_e)error, m_nReqId,
+                       m_nReplyIdx++, m_nReplyCnt, category, m_pUserData) == FALSE)
+                       break;
+       }
+       m_bReplyFlushed = true;
+}
+
 bool HerePlace::__compareWithTitle(const maps_place_h &item1, const maps_place_h &item2)
 {
        bool result = false;
index 33a5ac074921758071eb2dee81fd8c494041832b..f67b71885c353c97f2e5b35f4eccb6e7da21a6f6 100644 (file)
@@ -126,7 +126,8 @@ EXPORT_API int maps_plugin_is_service_supported(maps_service_e service, bool *su
                case MAPS_SERVICE_CANCEL_REQUEST:
                case MAPS_SERVICE_MULTI_REVERSE_GEOCODE:
                case MAPS_SERVICE_SEARCH_PLACE_LIST:
-               case MAPS_SERVICE_SEARCH_GET_PLACE_DETAILS:
+               case MAPS_SERVICE_GET_PLACE_DETAILS:
+               case MAPS_SERVICE_GET_PLACE_CATEGORIES:
                case MAPS_SERVICE_VIEW:
                case MAPS_SERVICE_VIEW_SNAPSHOT:
                        *supported = TRUE;
@@ -271,7 +272,17 @@ EXPORT_API int maps_plugin_search_place_list(const maps_area_h boundary, const m
 EXPORT_API int maps_plugin_get_place_details(const char* url,
        maps_service_get_place_details_cb callback, void* user_data, int* request_id)
 {
-       int ret = HerePluginSearchPlaceDetails(url, callback, user_data, request_id);
+       int ret = HerePluginGetPlaceDetails(url, callback, user_data, request_id);
+
+       MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));
+
+       return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_get_place_categories(maps_preference_h preference,
+       maps_service_get_place_categories_cb callback, void* user_data, int* request_id)
+{
+       int ret = HerePluginGetPlaceCategories(preference, callback, user_data, request_id);
 
        MAPS_LOGD("here_error_e = %d, %s", ret, ConverHereErrorToString(ret));