* @since_tizen 3.0
*
* @param[in] address_list The address list handle
- * @param[in] maps_address_h The address handle
* @return 0 on success, otherwise a negative error value
* @retval #MAPS_ERROR_NONE Successful
* @retval #MAPS_ERROR_INVALID_PARAMETER Invalid parameter
* @details This function delivers items of a specified list via
* maps_item_list_foreach_cb() callback.
* @since_tizen 2.4
+ * @remarks This function clones the list values during maps_item_list_foreach() procedure.
+ * \n maps_item_list_foreach_noclone() is useful to reduce the memory consumption.
*
* @param[in] list The handle of list
* @param[in] clone_func The function for cloning the list values
*
* @see maps_item_list_foreach_cb()
* @see maps_item_list_append()
+ * @see maps_item_list_foreach_noclone()
* @see maps_service_create()
*/
int maps_item_list_foreach(maps_item_list_h list,
int maps_item_list_remove_all(maps_item_list_h list,
maps_item_list_free_cb free_func);
+/**
+ * @brief Called once for each item while iterating through the given list.
+ * @details This function is called once for each item of the given list while
+ * the list is being iterated during the maps_item_list_foreach_noclone() procedure.
+ * @since_tizen 3.0
+ *
+ * @param[in] index The current index of item
+ * @param[in] data The pointer to the list item
+ * @param[in] user_data The user data passed from maps_item_list_foreach_noclone()
+ * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
+ *
+ * @pre maps_item_list_foreach_noclone() will invoke this callback.
+ *
+ * @see maps_item_list_foreach_noclone()
+ */
+typedef bool(*maps_item_list_foreach_noclone_cb) (int index, void *data, void *user_data);
+
+/**
+ * @brief Gets the items of the specified list.
+ * @details This function delivers items of a specified list via maps_item_list_foreach_noclone_cb() callback.
+ * @since_tizen 3.0
+ * @remarks This function is useful while adding to the list an item of arbitrary type without cloning it.
+ * \n maps_item_list_foreach() is useful when cloning the value is required while adding to the list.
+ *
+ * @param[in] list The handle of list
+ * @param[in] callback The callback to be invoked for delivering each list item
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #MAPS_ERROR_NONE Successful
+ * @retval #MAPS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MAPS_ERROR_NOT_FOUND Result not found
+ *
+ * @pre @a list is created using maps_item_list_create().
+ * @post This function invokes maps_item_list_foreach_noclone_cb() to deliver list items.
+ *
+ * @see maps_item_list_foreach_noclone_cb()
+ * @see maps_item_list_append()
+ * @see maps_item_list_foreach()
+ * @see maps_service_create()
+ */
+int maps_item_list_foreach_noclone(maps_item_list_h list, maps_item_list_foreach_noclone_cb callback, void *user_data);
+
/**
* @}
*/
* @since_tizen 3.0
*
* @see maps_place_list_foreach()
+ * @see maps_place_list_destroy()
*/
typedef void *maps_place_list_h;
* @brief Called when requesting the list of Place.
* @details This callback is invoked while iterating through the list of Place.
* @since_tizen 3.0
- * @remarks @a place is valid only in this function and must be released using
- * maps_place_destroy().
*
* @param[in] index The current index of review
- * @param[in] total The total amount of reviews
* @param[in] place The place handle
* @param[in] uesr_data The user data passed from the maps_place_list_foreach()
* @return @c true to continue with the next iteration of the loop,
* @see maps_place_get_rating()
* @see maps_place_foreach_category()
*/
-typedef bool(*maps_place_cb) (int index, int total, maps_place_h place, void *user_data);
+typedef bool(*maps_place_cb) (int index, maps_place_h place, void *user_data);
/*----------------------------------------------------------------------------*/
* @details This function retrieves all places.
* @since_tizen 3.0
* @remarks The places will be delivered via maps_place_cb().
+ * \n @a place_list must be released using maps_place_list_destroy().
*
* @param[in] place_list The place list handle
* @param[in] callback The callback function to invoke
* @post This function invokes maps_place_cb() repeatedly to retrieve each place.
*
* @see maps_place_cb()
+ * @see maps_place_list_destroy()
+ */
+int maps_place_list_foreach(const maps_place_list_h place_list, maps_place_cb callback, void *user_data);
+
+/**
+ * @brief Frees all of the memory used by a place list.
+ * @since_tizen 3.0
+ *
+ * @param[in] place_list The place list handle
+ * @return 0 on success, otherwise a negative error value
+ * @retval #MAPS_ERROR_NONE Successful
+ * @retval #MAPS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see maps_place_list_foreach()
*/
-int maps_place_list_foreach(const maps_place_list_h place_list,
- maps_place_cb callback, void *user_data);
+int maps_place_list_destroy(maps_place_list_h place_list);
#ifdef __cplusplus
}
int maps_place_set_related_link(maps_place_h place,
const maps_place_link_object_h related);
+/**
+ * @brief Creates a place list having a set of places.
+ * @since_tizen 3.0
+ *
+ * @param[out] place_list The place list handle
+ * @return 0 on success, otherwise a negative error value
+ * @retval #MAPS_ERROR_NONE Successful
+ * @retval #MAPS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MAPS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see maps_place_list_destroy()
+ */
+int maps_place_list_create(maps_place_list_h *place_list);
+
#ifdef __cplusplus
}
#endif
int maps_preference_get_route_feature(const maps_preference_h preference,
maps_route_feature_e *feature);
+/**
+ * @brief Gets the enable status of alternative routes.
+ * @details This function retrieves the enable status of alternative route.
+ * @since_tizen 3.0
+ *
+ * @param[in] preference The preference handle
+ * @param[out] enable The enable status
+ * @return 0 on success, otherwise a negative error value
+ * @retval #MAPS_ERROR_NONE Successful
+ * @retval #MAPS_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int maps_preference_get_route_alternatives_enabled(const maps_preference_h preference, bool *enable);
+
/**
* @brief Gets the maps preference value by key.
* @details This function gets the maps preference value by key.
int maps_preference_set_route_feature(maps_preference_h preference,
const maps_route_feature_e feature);
+/**
+ * @brief Sets the enable status of alternative routes.
+ * @details This function sets the alternative routes status.
+ * @since_tizen 3.0
+ *
+ * @param[in] preference The preference handle
+ * @param[in] enable The value to set
+ * @return 0 on success, otherwise a negative error value
+ * @retval #MAPS_ERROR_NONE Successful
+ * @retval #MAPS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @pre @a preference is created using maps_preference_create().
+ *
+ * @see maps_preference_create()
+ * @see maps_preference_get_route_alternatives_enabled()
+ */
+int maps_preference_set_route_alternatives_enabled(maps_preference_h preference, bool enable);
+
/**
* @brief Sets the preference value by key.
* @details This function sets the preference value assigned with a specified
* from the specified coordinates.
* \n If search is failed, the value of @a total is 0 and @a place_list is NULL
* @since_tizen 3.0
- * @remarks This error code will be reported. \n
+ * @remarks The parameter @a place_list must be released using maps_place_list_destroy().
+ * \n This error code will be reported. \n
* #MAPS_ERROR_NONE \n
* #MAPS_ERROR_OUT_OF_MEMORY \n
* #MAPS_ERROR_INVALID_PARAMETER \n
*
* @param[in] error The result of request
* @param[in] request_id The request id
+ * @param[in] total The total number of results
* @param[in] place_list The resulting Place list data
* @param[in] uesr_data The user data passed from maps_service_search_place_list()
*
* @see maps_place_list_foreach()
*/
typedef void(*maps_service_search_place_list_cb) (maps_error_e error,
- int request_id, maps_place_list_h place_list, void *user_data);
+ int request_id, int total, maps_place_list_h place_list, void *user_data);
/**
* @brief Called for Place datail information of Place Search request
* obtained from the specified uri.
* \n If search is failed, @a place is NULL
* @since_tizen 3.0
- * @remarks This error code will be reported. \n
+ * @remarks The parameter @a place must be released using maps_place_destroy().
+ * \n This error code will be reported. \n
* #MAPS_ERROR_NONE \n
* #MAPS_ERROR_OUT_OF_MEMORY \n
* #MAPS_ERROR_INVALID_PARAMETER \n
return MAPS_ERROR_NONE;
}
+EXPORT_API int maps_item_list_foreach_noclone(maps_item_list_h list, maps_item_list_foreach_noclone_cb callback, void *user_data)
+{
+ if (!list || !callback)
+ return MAPS_ERROR_INVALID_PARAMETER;
+ maps_item_list_s *l = (maps_item_list_s *) list;
+
+ if (!l->l)
+ return MAPS_ERROR_NOT_FOUND;
+
+ GList *head = g_list_first(l->l);
+ int index = 0;
+ while (head) {
+ void *data = head->data;
+ head = head->next;
+ if (!callback(index++, data, user_data))
+ break;
+ }
+
+ return MAPS_ERROR_NONE;
+}
+
EXPORT_API int maps_item_list_remove_all(maps_item_list_h list,
maps_item_list_free_cb free_func)
{
if (!place_list || !callback)
return MAPS_ERROR_INVALID_PARAMETER;
- return maps_item_list_foreach((maps_item_list_h) place_list, maps_place_clone, callback, user_data);
+ return maps_item_list_foreach_noclone((maps_item_list_h) place_list, callback, user_data);
}
+
+EXPORT_API int maps_place_list_create(maps_place_list_h *place_list)
+{
+ if (!place_list)
+ return MAPS_ERROR_INVALID_PARAMETER;
+
+ return maps_item_list_create(place_list);
+}
+
+EXPORT_API int maps_place_list_destroy(maps_place_list_h place_list)
+{
+ if (!place_list)
+ return MAPS_ERROR_INVALID_PARAMETER;
+
+ int error = MAPS_ERROR_NONE;
+
+ error = maps_item_list_remove_all(place_list, maps_place_destroy);
+ if (error != MAPS_ERROR_NONE)
+ return error;
+
+ return maps_item_list_destroy(place_list);
+}
+
#include "maps_preference.h"
#include <glib.h>
+const int _DEFAULT_ALTERNATIVES_SIZE = 2;
+
typedef struct _callback_data
{
maps_preference_properties_cb callback;
g_str_hash("MAPS_PREFERENCE_ROUTE_OPTIMIZATION"),
g_str_hash("MAPS_PREFERENCE_ROUTE_TRANSPORT_MODE"),
g_str_hash("MAPS_PREFERENCE_ROUTE_FEATURE_WEIGHT"),
- g_str_hash("MAPS_PREFERENCE_ROUTE_FEATURE")
+ g_str_hash("MAPS_PREFERENCE_ROUTE_FEATURE"),
+ g_str_hash("MAPS_PREFERENCE_ROUTE_ALTERNATIVES")
};
const int size = sizeof(names) / sizeof(names[0]);
return error;
do {
- error = maps_item_hashtable_set_int(*preference,
- "MAPS_PREFERENCE_DISTANCE_UNIT", MAPS_DISTANCE_UNIT_M);
+ error = maps_item_hashtable_set_int(*preference, "MAPS_PREFERENCE_DISTANCE_UNIT", MAPS_DISTANCE_UNIT_M);
+ if (error != MAPS_ERROR_NONE)
+ break;
+
+ error = maps_item_hashtable_set_string(*preference, "MAPS_PREFERENCE_LANGUAGE", "en-US");
if (error != MAPS_ERROR_NONE)
break;
- error = maps_item_hashtable_set_string(*preference,
- "MAPS_PREFERENCE_LANGUAGE", "en-US");
+ error = maps_item_hashtable_set_int(*preference, "MAPS_PREFERENCE_MAX_RESULTS", 25);
if (error != MAPS_ERROR_NONE)
break;
- error = maps_item_hashtable_set_int(*preference,
- "MAPS_PREFERENCE_MAX_RESULTS", 25);
+ error = maps_item_hashtable_set_int(*preference, "MAPS_PREFERENCE_ROUTE_ALTERNATIVES", 0);
if (error != MAPS_ERROR_NONE)
break;
"MAPS_PREFERENCE_ROUTE_FEATURE", (int *) feature);
}
+EXPORT_API int maps_preference_get_route_alternatives_enabled(const maps_preference_h preference, bool *enable)
+{
+ if (!preference)
+ return MAPS_ERROR_INVALID_PARAMETER;
+
+ int alternatives;
+ int error = maps_item_hashtable_get_int(preference, "MAPS_PREFERENCE_ROUTE_ALTERNATIVES", &alternatives);
+ if (error != MAPS_ERROR_NONE)
+ return error;
+
+ *enable = (alternatives == _DEFAULT_ALTERNATIVES_SIZE) ? true :false;
+
+ return MAPS_ERROR_NONE;
+}
+
EXPORT_API int maps_preference_get(const maps_preference_h preference,
const char *key, char **value)
{
"MAPS_PREFERENCE_ROUTE_FEATURE", feature);
}
+EXPORT_API int maps_preference_set_route_alternatives_enabled(maps_preference_h preference, bool enable)
+{
+ if (!preference)
+ return MAPS_ERROR_INVALID_PARAMETER;
+
+ int alternatives = 0;
+ if (enable)
+ alternatives = _DEFAULT_ALTERNATIVES_SIZE;
+
+ return maps_item_hashtable_set_int(preference, "MAPS_PREFERENCE_ROUTE_ALTERNATIVES", alternatives);
+}
+
EXPORT_API int maps_preference_set_property(maps_preference_h preference,
const char *key, const char *value)
{
if (handler) {
/* Run the plugin interface function */
error = func(boundary, filter, preference,
- command_search_place_list_handler::foreach_place_around_cb, handler,
+ command_search_place_list_handler::foreach_place_list_cb, handler,
&handler->plg_req_id);
pr.update(my_req_id, handler);
{
}
-void session::command_search_place_list_handler::foreach_place_around_cb(maps_error_e error,
+void session::command_search_place_list_handler::foreach_place_list_cb(maps_error_e error,
int request_id,
+ int total,
maps_place_list_h place_list,
void *user_data)
{
}
/* Send data to user */
- handler->callback(error, handler->user_req_id, place_list, handler->user_data);
+ handler->callback(error, handler->user_req_id, total, place_list, handler->user_data);
pending_request pr(handler->plugin());
pr.remove(handler->user_req_id);
{ return *this;
}
private:
- static void foreach_place_around_cb(maps_error_e error, int request_id,
- maps_place_list_h place, void *user_data);
+ static void foreach_place_list_cb(maps_error_e error, int request_id,
+ int total, maps_place_list_h place, void *user_data);
friend class command_search_place_list;
};