2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <location/location.h>
20 #include <poi_private.h>
30 #define LOG_TAG "TIZEN_N_POI"
32 #define POI_CHECK_CONDITION(condition,error,msg) \
35 LOGE("[%s] %s(0x%08x)",__FUNCTION__, msg,error); return error; \
39 #define POI_PRINT_ERROR_CODE_RETURN(code) \
41 LOGE("[%s] %s(0x%08x)",__FUNCTION__, #code,code); return code; \
45 #define POI_NULL_ARG_CHECK(arg) \
46 POI_CHECK_CONDITION( (arg !=NULL),POI_ERROR_INVALID_PARAMETER,"POI_ERROR_INVALID_PARAMETER")
51 poi_service_search_cb callback;
55 * Internal Implementation
57 static int _convert_error_code(int code, const char* func_name)
60 char* msg = "POI_ERROR_NONE";
63 case LOCATION_ERROR_NONE:
65 msg = "POI_ERROR_NONE";
67 case LOCATION_ERROR_NETWORK_FAILED:
68 case LOCATION_ERROR_NETWORK_NOT_CONNECTED:
69 ret = POI_ERROR_NETWORK_FAILED;
70 msg = "POI_ERROR_NETWORK_FAILED";
72 case LOCATION_ERROR_PARAMETER:
73 ret = POI_ERROR_INVALID_PARAMETER;
74 msg = "POI_ERROR_INVALID_PARAMETER";
76 case LOCATION_ERROR_NOT_FOUND:
77 ret = POI_ERROR_RESULT_NOT_FOUND;
78 msg = "POI_ERROR_RESULT_NOT_FOUND";
80 case LOCATION_ERROR_NOT_ALLOWED:
81 case LOCATION_ERROR_NOT_AVAILABLE:
82 case LOCATION_ERROR_CONFIGURATION:
83 case LOCATION_ERROR_UNKNOWN:
85 msg = "POI_ERROR_SERVICE_NOT_AVAILABLE";
86 ret = POI_ERROR_SERVICE_NOT_AVAILABLE;
88 LOGE("[%s] %s(0x%08x) : core fw error(0x%x)",func_name,msg, ret, code);
92 static void __LocationPOICB(LocationError error, guint req_id, GList * landmark_list, gchar * error_code, gchar * error_msg, gpointer userdata)
94 __callback_data * callback = (__callback_data*)userdata;
95 if( callback == NULL || callback->callback == NULL)
98 int ret = _convert_error_code(error,"search_callback");
99 GList *mark_list = landmark_list;
103 if( mark_list == NULL || ret != 0){
104 callback->callback(ret , req_id, index, length, NULL, callback->data);
109 length = g_list_length(mark_list);
111 LocationLandmark *mark = mark_list->data;
112 if( callback->callback(ret, req_id, index++, length, mark, callback->data) == false )
114 mark_list = mark_list->next;
123 int poi_service_create( poi_service_h *poi)
126 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_INVALID_PARAMETER);
128 if( location_init() != LOCATION_ERROR_NONE )
130 LOGE("[%s] POI_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : fail to location_init", __FUNCTION__, POI_ERROR_SERVICE_NOT_AVAILABLE);
131 return POI_ERROR_SERVICE_NOT_AVAILABLE;
134 poi_service_s *handle = (poi_service_s*)malloc(sizeof(poi_service_s));
136 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_OUT_OF_MEMORY);
138 memset(handle, 0 , sizeof(poi_service_s));
140 if( POI_ERROR_NONE != poi_preference_create(&handle->preference ) ){
142 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_OUT_OF_MEMORY);
145 handle->object = location_new(LOCATION_METHOD_HYBRID);
146 if(handle->object == NULL)
149 LOGE("[%s] POI_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : fail to location_new", __FUNCTION__, POI_ERROR_SERVICE_NOT_AVAILABLE);
150 return POI_ERROR_SERVICE_NOT_AVAILABLE;
153 *poi = (poi_service_h)handle;
154 return POI_ERROR_NONE;
158 int poi_service_destroy(poi_service_h poi)
161 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_INVALID_PARAMETER);
163 poi_service_s *handle = (poi_service_s*)poi;
165 if( handle->preference ){
166 poi_preference_destroy(handle->preference);
167 handle->preference = NULL;
170 int ret = location_free(handle->object);
171 if(ret!= POI_ERROR_NONE)
173 return _convert_error_code(ret,__FUNCTION__);
176 return POI_ERROR_NONE;
180 int poi_service_set_preference(poi_service_h poi , poi_preference_h preference)
182 POI_NULL_ARG_CHECK(poi);
183 POI_NULL_ARG_CHECK(preference);
185 poi_service_s *handle = (poi_service_s*)poi;
187 if( handle->preference ){
188 poi_preference_destroy(handle->preference);
189 handle->preference = (poi_preference_h)location_poi_pref_copy((LocationPOIPreference*)preference);
191 return POI_ERROR_NONE;
194 int poi_service_get_preference(poi_service_h poi , poi_preference_h *preference)
196 POI_NULL_ARG_CHECK(poi);
197 POI_NULL_ARG_CHECK(preference);
198 poi_service_s *handle = (poi_service_s*)poi;
200 if( handle->preference == NULL ){
201 poi_preference_create(&handle->preference );
203 *preference = (poi_preference_h)location_poi_pref_copy((LocationPOIPreference*)handle->preference);
204 return POI_ERROR_NONE;
207 int poi_service_search(poi_service_h poi, location_coords_s position, int distance , poi_filter_h filter, poi_service_search_cb callback, void * user_data, int * request_id)
209 POI_NULL_ARG_CHECK(poi);
210 POI_NULL_ARG_CHECK(callback);
211 POI_CHECK_CONDITION(distance >= 0 , POI_ERROR_INVALID_PARAMETER, "distance value is negative");
212 POI_CHECK_CONDITION(position.latitude>=-90 && position.latitude<=90 ,POI_ERROR_INVALID_PARAMETER,"latitude should be -90 <= latitude <= 90");
213 POI_CHECK_CONDITION(position.longitude>=-180 && position.longitude<=180,POI_ERROR_INVALID_PARAMETER,"longitude should be -180 <= latitude <= 180");
216 LocationPosition pos;
220 poi_service_s *handle = (poi_service_s*)poi;
221 pos.latitude = position.latitude;
222 pos.longitude = position.longitude;
224 pos.status = LOCATION_STATUS_2D_FIX;
227 __callback_data * calldata = (__callback_data *)malloc(sizeof(__callback_data));
228 if( calldata == NULL)
229 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_OUT_OF_MEMORY);
231 calldata->callback = callback;
232 calldata->data = user_data;
235 char distance_str[255];
236 snprintf(distance_str, 255, "%d", distance);
237 poi_preference_set(handle->preference, "Distance", distance_str);
239 poi_preference_set(handle->preference, "Distance", NULL);
243 ret = location_search_poi (handle->object , (LocationPOIFilter*)filter , &pos, (LocationPOIPreference *)handle->preference, __LocationPOICB, calldata, &reqid);
246 return _convert_error_code(ret, __func__);
251 return POI_ERROR_NONE;
256 int poi_service_search_by_area (poi_service_h poi, location_bounds_h boundary , poi_filter_h filter, poi_service_search_cb callback, void * user_data, int * request_id)
258 POI_NULL_ARG_CHECK(poi);
259 POI_NULL_ARG_CHECK(callback);
260 POI_NULL_ARG_CHECK(boundary);
264 poi_service_s *handle = (poi_service_s*)poi;
265 location_bounds_type_e bound_type;
266 location_bounds_get_type(boundary, &bound_type);
268 if( bound_type == LOCATION_BOUNDS_RECT ){
269 if( !location_is_supported_map_provider_capability(handle->object , MAP_SERVICE_POI_SEARCH_BY_RECT_BOUNDARY) )
270 return POI_ERROR_SERVICE_NOT_AVAILABLE;
271 }else if(bound_type == LOCATION_BOUNDS_CIRCLE){
272 if( !location_is_supported_map_provider_capability(handle->object , MAP_SERVICE_POI_SEARCH_BY_CIRCLE_BOUNDARY) )
273 return POI_ERROR_SERVICE_NOT_AVAILABLE;
274 }else if(bound_type == LOCATION_BOUNDS_CIRCLE){
275 if( !location_is_supported_map_provider_capability(handle->object , MAP_SERVICE_POI_SEARCH_BY_POLYGON_BOUNDARY) )
276 return POI_ERROR_SERVICE_NOT_AVAILABLE;
279 __callback_data * calldata = (__callback_data *)malloc(sizeof(__callback_data));
280 if( calldata == NULL)
281 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_OUT_OF_MEMORY);
283 calldata->callback = callback;
284 calldata->data = user_data;
286 poi_preference_set(handle->preference, "Distance", NULL);
288 ret = location_search_poi_by_area (handle->object , (LocationPOIFilter*)filter , (LocationBoundary *)boundary, (LocationPOIPreference *)handle->preference, __LocationPOICB, calldata, &reqid);
291 return _convert_error_code(ret, __func__);
296 return POI_ERROR_NONE;
300 int poi_service_search_by_address(poi_service_h poi, const char* address, int distance, poi_filter_h filter, poi_service_search_cb callback, void * user_data, int * request_id)
302 POI_NULL_ARG_CHECK(poi);
303 POI_NULL_ARG_CHECK(callback);
304 POI_CHECK_CONDITION(distance >= 0 , POI_ERROR_INVALID_PARAMETER, "distance value is negative");
309 poi_service_s *handle = (poi_service_s*)poi;
311 __callback_data * calldata = (__callback_data *)malloc(sizeof(__callback_data));
312 if( calldata == NULL)
313 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_OUT_OF_MEMORY);
315 calldata->callback = callback;
316 calldata->data = user_data;
319 char distance_str[255];
320 snprintf(distance_str, 255, "%d", distance);
321 poi_preference_set(handle->preference, "Distance", distance_str);
323 poi_preference_set(handle->preference, "Distance", NULL);
326 ret = location_search_poi_by_freeformed_address (handle->object , (LocationPOIFilter*)filter , address, (LocationPOIPreference *)handle->preference, __LocationPOICB, calldata, &reqid);
330 return _convert_error_code(ret, __func__);
335 return POI_ERROR_NONE;
339 int poi_service_cancel(poi_service_h service, int request_id)
341 POI_NULL_ARG_CHECK(service);
343 poi_service_s *handle = (poi_service_s*)service;
344 return _convert_error_code(location_cancel_poi_request(handle->object, request_id), __func__);
347 int poi_filter_create(poi_filter_h *filter)
349 POI_NULL_ARG_CHECK(filter);
351 LocationPOIFilter *native_filter = location_poi_filter_new();
352 POI_CHECK_CONDITION( (native_filter != NULL) , POI_ERROR_OUT_OF_MEMORY, "POI_ERROR_OUT_OF_MEMORY");
353 *filter = (void*)native_filter;
354 return POI_ERROR_NONE;
356 int poi_filter_destroy(poi_filter_h filter)
358 POI_NULL_ARG_CHECK(filter);
359 location_poi_filter_free((LocationPOIFilter*)filter);
360 return POI_ERROR_NONE;
362 int poi_filter_set(poi_filter_h filter, const char* key, const char* value)
364 POI_NULL_ARG_CHECK(filter);
365 POI_NULL_ARG_CHECK(key);
366 int ret = location_poi_filter_set((LocationPOIFilter*)filter , key, value);
368 return POI_ERROR_INVALID_KEY;
369 return POI_ERROR_NONE;
371 int poi_filter_get(poi_filter_h filter, const char* key, char** value)
373 POI_NULL_ARG_CHECK(filter);
374 POI_NULL_ARG_CHECK(key);
375 POI_NULL_ARG_CHECK(value);
376 char *v = (char*)location_poi_filter_get((LocationPOIFilter*)filter, key);
378 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_INVALID_KEY);
381 return POI_ERROR_NONE;
384 int poi_filter_foreach_properties(poi_filter_h filter, poi_filter_properties_cb callback , void * user_data)
386 POI_NULL_ARG_CHECK(filter);
387 POI_NULL_ARG_CHECK(callback);
389 GList *keys = location_poi_filter_get_key((LocationPOIFilter*)filter);
391 char *key = keys->data;
392 char *value = location_poi_filter_get((LocationPOIFilter*)filter, key);
393 if(!callback(key,value, user_data))
398 return POI_ERROR_NONE;
401 int poi_filter_foreach_available_keys( poi_service_h poi, poi_filter_available_key_cb callback , void * user_data)
403 POI_NULL_ARG_CHECK(poi);
404 POI_NULL_ARG_CHECK(callback);
407 location_get_map_provider_capability_key((LocationObject*)poi, MAP_SERVICE_POI_FILTER, &keys);
409 return POI_ERROR_RESULT_NOT_FOUND;
412 char *key = keys->data;
413 if( !callback(key,user_data) )
417 g_list_free_full (keys, g_free);
418 return POI_ERROR_NONE;
421 int poi_filter_foreach_available_values( poi_service_h poi, const char *key, poi_filter_available_value_cb callback , void * user_data)
424 // Available category
425 return POI_ERROR_RESULT_NOT_FOUND;
428 int poi_preference_create(poi_preference_h *preference )
430 POI_NULL_ARG_CHECK(preference);
431 LocationPOIPreference *pref;
432 pref = location_poi_pref_new();
434 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_OUT_OF_MEMORY);
437 return POI_ERROR_NONE;
440 int poi_preference_destroy(poi_preference_h preference )
442 POI_NULL_ARG_CHECK(preference);
443 location_poi_pref_free((LocationPOIPreference*)preference);
444 return POI_ERROR_NONE;
447 int poi_preference_foreach_properties( poi_preference_h preference, poi_preference_properties_cb callback , void * user_data)
449 POI_NULL_ARG_CHECK(preference);
450 POI_NULL_ARG_CHECK(callback);
452 GList *keys = location_poi_pref_get_property_key((LocationPOIPreference*)preference);
454 char *key = keys->data;
455 char *value = location_poi_pref_get_property((LocationPOIPreference*)preference, key);
456 if(!callback(key,value, user_data))
461 return POI_ERROR_NONE;
464 int poi_preference_foreach_available_keys( poi_service_h poi, poi_preference_available_key_cb callback , void * user_data)
466 POI_NULL_ARG_CHECK(poi);
467 POI_NULL_ARG_CHECK(callback);
470 location_get_map_provider_capability_key((LocationObject*)poi, MAP_SERVICE_POI_PREF_PROPERTY, &keys);
472 return POI_ERROR_RESULT_NOT_FOUND;
475 char *key = keys->data;
476 if( !callback(key,user_data) )
480 g_list_free_full (keys, g_free);
481 return POI_ERROR_NONE;
484 int poi_preference_foreach_available_values( poi_service_h poi, const char *key, poi_preference_available_value_cb callback , void * user_data)
487 // Availiable LandmarkType
488 // Availiable LandmarkName
489 return POI_ERROR_RESULT_NOT_FOUND;
492 int poi_preference_get(poi_preference_h preference, const char *key, char **value)
494 POI_NULL_ARG_CHECK(preference);
495 POI_NULL_ARG_CHECK(key);
496 POI_NULL_ARG_CHECK(value);
497 char *v = (char*)location_poi_pref_get_property((LocationPOIPreference*)preference, key);
499 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_INVALID_KEY);
501 return POI_ERROR_NONE;
504 int poi_preference_set(poi_preference_h preference, const char *key, const char *value)
506 POI_NULL_ARG_CHECK(preference);
507 POI_NULL_ARG_CHECK(key);
509 int ret = location_poi_pref_set_property((LocationPOIPreference*)preference,key, value);
511 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_INVALID_KEY);
512 return POI_ERROR_NONE;
515 int poi_preference_set_max_result(poi_preference_h preference, int max_result)
517 POI_NULL_ARG_CHECK(preference);
518 int ret = location_poi_pref_set_max_result((LocationPOIPreference*)preference, max_result);
520 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_INVALID_PARAMETER);
521 return POI_ERROR_NONE;
524 int poi_preference_get_max_result(poi_preference_h preference, int* max_result)
526 POI_NULL_ARG_CHECK(preference);
527 POI_NULL_ARG_CHECK(max_result);
528 int ret = location_poi_pref_get_max_result((LocationPOIPreference*)preference );
530 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_INVALID_PARAMETER);
532 return POI_ERROR_NONE;
536 int poi_preference_foreach_sortable_field( poi_service_h poi, poi_preference_sortable_field_cb callback , void * user_data)
538 POI_NULL_ARG_CHECK(poi);
539 POI_NULL_ARG_CHECK(callback);
542 location_get_map_provider_capability_key((LocationObject*)poi, MAP_SERVICE_POI_PREF_SORT_BY, &keys);
544 return POI_ERROR_RESULT_NOT_FOUND;
547 char *key = keys->data;
548 if( !callback(key,user_data) )
552 g_list_free_full (keys, g_free);
553 return POI_ERROR_NONE;
556 int poi_preference_set_sort(poi_preference_h preference , const char* field , poi_sort_order_e order)
558 POI_NULL_ARG_CHECK(preference);
559 POI_NULL_ARG_CHECK(field);
560 int ret = location_poi_pref_set_sort_by((LocationPOIPreference*)preference, field);
562 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_INVALID_PARAMETER);
563 ret = location_poi_pref_set_sort_order ((LocationPOIPreference*)preference , order);
565 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_INVALID_PARAMETER);
567 return POI_ERROR_NONE;
570 int poi_preference_get_sort(poi_preference_h preference , char** field, poi_sort_order_e *order)
572 POI_NULL_ARG_CHECK(preference);
573 POI_NULL_ARG_CHECK(field);
574 POI_NULL_ARG_CHECK(order);
575 char *sort_by = (char*)location_poi_pref_get_sort_by((LocationPOIPreference*)preference);
577 *field = strdup(sort_by);
581 *order = location_poi_pref_get_sort_order((LocationPOIPreference*)preference);
582 return POI_ERROR_NONE;
585 int poi_create(poi_h *poi)
587 POI_NULL_ARG_CHECK(poi);
588 LocationLandmark* landmark = location_landmark_new();
589 if( landmark == NULL)
590 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_OUT_OF_MEMORY);
593 return POI_ERROR_NONE;
596 int poi_destroy(poi_h poi)
598 POI_NULL_ARG_CHECK(poi);
599 location_landmark_free((LocationLandmark*)poi);
600 return POI_ERROR_NONE;
603 int poi_clone(poi_h* cloned, poi_h origin)
605 POI_NULL_ARG_CHECK(cloned);
606 POI_NULL_ARG_CHECK(origin);
608 LocationLandmark * landmark = location_landmark_copy ((LocationLandmark*)origin);
609 if( landmark == NULL)
610 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_OUT_OF_MEMORY);
612 return POI_ERROR_NONE;
615 int poi_get_id(poi_h poi, int *id)
617 POI_NULL_ARG_CHECK(poi);
618 POI_NULL_ARG_CHECK(id);
619 *id = location_landmark_get_id((LocationLandmark*)poi);
620 return POI_ERROR_NONE;
623 int poi_get_name(poi_h poi, char **name)
625 POI_NULL_ARG_CHECK(poi);
626 POI_NULL_ARG_CHECK(name);
627 char *poi_name = (char*)location_landmark_get_name((LocationLandmark*)poi);
628 if( poi_name == NULL)
631 *name = strdup(poi_name);
632 return POI_ERROR_NONE;
635 int poi_get_position(poi_h poi, location_coords_s *position)
637 POI_NULL_ARG_CHECK(poi);
638 POI_NULL_ARG_CHECK(position);
639 const LocationPosition *pos = location_landmark_get_position((LocationLandmark*)poi);
641 POI_PRINT_ERROR_CODE_RETURN(POI_ERROR_INVALID_PARAMETER);
643 position->latitude = pos->latitude;
644 position->longitude = pos->longitude;
645 return POI_ERROR_NONE;
648 int poi_get_address(poi_h poi, char **building_number, char **postal_code, char **street, char **city, char **district, char **state, char **country_code)
650 POI_NULL_ARG_CHECK(poi);
651 const LocationAddress * addr = location_landmark_get_address((LocationLandmark*)poi);
653 return POI_ERROR_RESULT_NOT_FOUND;
654 if( building_number && addr->building_number)
655 *building_number = strdup(addr->building_number);
657 if( postal_code && addr->postal_code)
658 *postal_code = strdup(addr->postal_code);
660 if( street && addr->street)
661 *street = strdup(addr->street);
663 if( city && addr->city)
664 *city = strdup(addr->city);
666 if( district && addr->district)
667 *district = strdup(addr->district);
669 if( state && addr->state)
670 *state = strdup(addr->state);
672 if( country_code && addr->country_code)
673 *country_code = strdup(addr->country_code);
675 return POI_ERROR_NONE;
679 int poi_get_description(poi_h poi, char** description)
681 POI_NULL_ARG_CHECK(poi);
682 POI_NULL_ARG_CHECK(description);
684 char * desc = (char*)location_landmark_get_description((LocationLandmark*)poi);
688 *description = strdup(desc);
689 return POI_ERROR_NONE;
692 int poi_get_timestamp(poi_h poi , time_t *timestamp)
694 POI_NULL_ARG_CHECK(poi);
695 POI_NULL_ARG_CHECK(timestamp);
696 *timestamp = location_landmark_get_timestamp((LocationLandmark*)poi);
697 return POI_ERROR_NONE;
700 int poi_get_bounding_rect(poi_h poi , location_coords_s *top_left, location_coords_s *bottom_right)
702 POI_NULL_ARG_CHECK(poi);
703 POI_NULL_ARG_CHECK(top_left);
704 POI_NULL_ARG_CHECK(bottom_right);
706 const LocationBoundary *bound = location_landmark_get_bounding_box((LocationLandmark*)poi);
708 return POI_ERROR_RESULT_NOT_FOUND;
709 top_left->latitude = bound->rect.left_top->latitude;
710 top_left->longitude = bound->rect.left_top->longitude;
711 bottom_right->latitude = bound->rect.right_bottom->latitude;
712 bottom_right->longitude = bound->rect.right_bottom->longitude;
714 return POI_ERROR_NONE;
717 int poi_get_author(poi_h poi , char** author)
719 POI_NULL_ARG_CHECK(poi);
720 POI_NULL_ARG_CHECK(author);
721 char *auth = (char*)location_landmark_get_author((LocationLandmark*)poi);
725 *author = strdup(auth);
726 return POI_ERROR_NONE;
729 int poi_get_phone_number(poi_h poi , char** phone_number)
731 POI_NULL_ARG_CHECK(poi);
732 POI_NULL_ARG_CHECK(phone_number);
733 char *number = (char*)location_landmark_get_phone_number((LocationLandmark*)poi);
735 *phone_number = NULL;
737 *phone_number = strdup(number);
738 return POI_ERROR_NONE;
741 int poi_foreach_urls(poi_h poi, poi_urls_cb callback , void * user_data)
743 POI_NULL_ARG_CHECK(poi);
744 POI_NULL_ARG_CHECK(callback);
746 GList *url_list = (GList*)location_landmark_get_url((LocationLandmark*)poi);
749 LocationLandmarkUrl *url = url_list->data;
750 if(url != NULL && !callback(location_landmark_url_get_url_path(url), location_landmark_url_get_description(url), user_data) )
752 url_list = url_list->next;
754 return POI_ERROR_NONE;
757 int poi_foreach_properties(poi_h poi, poi_properties_cb callback, void * user_data)
759 POI_NULL_ARG_CHECK(poi);
760 POI_NULL_ARG_CHECK(callback);
761 GList *key_list = (GList*)location_landmark_get_property_key((LocationLandmark*)poi);
764 char *key = key_list->data;
766 if( key != NULL && (value = (char*)location_landmark_get_property((LocationLandmark*)poi, key)) != NULL){
767 if( callback(key, value, user_data) == false)
770 key_list = key_list->next;
772 return POI_ERROR_NONE;
775 int poi_foreach_categories(poi_h poi , poi_categories_cb callback , void * user_data)
777 POI_NULL_ARG_CHECK(poi);
778 POI_NULL_ARG_CHECK(callback);
779 GList *category_list = (GList*)location_landmark_get_category((LocationLandmark*)poi);
781 while( category_list ){
782 char *category = category_list->data;
783 if( false == callback(category, user_data) )
785 category_list = category_list->next;
787 return POI_ERROR_NONE;