1 /* Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #include "maps_error.h"
18 #include "maps_place_plugin.h"
19 #include "maps_extra_types.h"
20 #include "maps_util.h"
21 #include "maps_address.h"
22 #include "maps_place_private.h"
23 #include "maps_condition.h"
25 static bool __is_supported(const maps_place_h place, maps_service_data_e data)
27 bool supported = false;
28 _maps_place_is_data_supported(place, data, &supported);
32 /*----------------------------------------------------------------------------*/
34 typedef struct _maps_place_s
40 maps_coordinates_h location;
44 maps_address_h address;
46 maps_place_rating_h rating;
48 /* List of properties:
49 * Obtained with: maps_place_properties_cb callback
50 * Items are pairs: const char* key, const char* value */
51 maps_item_hashtable_h properties;
54 * Obtained with: maps_place_categories_cb
55 * Each of type: maps_place_category_h */
56 maps_item_list_h categories;
59 * Obtained with maps_place_attributes_cb
60 * Each of type: maps_place_attribute_h */
61 maps_item_list_h attribute;
64 * Obtained with: maps_place_contacts_cb
65 * Each of type: maps_place_contact_h */
66 maps_item_list_h contacts;
69 * Obtained with: maps_place_editorials_cb
70 * Each of type: maps_place_editorial_h */
71 maps_item_list_h editorials;
74 * Obtained with: maps_place_images_cb callback
75 * Each of type: maps_place_image_h */
76 maps_item_list_h images;
79 * Obtained with: maps_place_reviews_cb callback
80 * Each of type: maps_place_review_h */
81 maps_item_list_h reviews;
83 maps_place_link_object_h supplier;
84 maps_place_link_object_h related;
86 /* The table of available data features */
87 maps_int_hashtable_h supported_data;
90 /* TODO: extract all such constants to the dedcated header file */
91 const gsize _MAPS_PLACE_ID_MAX_LENGTH = MAPS_BASE_ID_MAX_LEN;
92 const gsize _MAPS_PLACE_NAME_MAX_LENGTH = MAPS_BASE_NAME_MAX_LEN;
93 const gsize _MAPS_PLACE_URI_MAX_LENGTH = MAPS_BASE_URL_MAX_LEN;
95 /*----------------------------------------------------------------------------*/
97 EXPORT_API int maps_place_create(maps_place_h *place)
99 if (!maps_condition_check_maps_feature())
100 return MAPS_ERROR_NOT_SUPPORTED;
102 return MAPS_ERROR_INVALID_PARAMETER;
103 *place = (maps_place_h) g_slice_new0(maps_place_s);
105 if (*place == NULL) {
107 MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
108 return MAPS_ERROR_OUT_OF_MEMORY;
112 return MAPS_ERROR_NONE;
115 EXPORT_API int maps_place_destroy(maps_place_h place)
117 if (!maps_condition_check_maps_feature())
118 return MAPS_ERROR_NOT_SUPPORTED;
120 return MAPS_ERROR_INVALID_PARAMETER;
122 maps_place_s *p = (maps_place_s *) place;
132 maps_coordinates_destroy(p->location);
135 maps_address_destroy(p->address);
138 maps_place_rating_destroy(p->rating);
141 maps_item_hashtable_destroy(p->properties);
144 maps_item_list_remove_all(p->categories,
145 maps_place_category_destroy);
146 maps_item_list_destroy(p->categories);
150 maps_item_list_remove_all(p->attribute,
151 maps_place_attribute_destroy);
152 maps_item_list_destroy(p->attribute);
156 maps_item_list_remove_all(p->contacts,
157 maps_place_contact_destroy);
158 maps_item_list_destroy(p->contacts);
162 maps_item_list_remove_all(p->editorials,
163 maps_place_editorial_destroy);
164 maps_item_list_destroy(p->editorials);
168 maps_item_list_remove_all(p->images, maps_place_image_destroy);
169 maps_item_list_destroy(p->images);
173 maps_item_list_remove_all(p->reviews,
174 maps_place_review_destroy);
175 maps_item_list_destroy(p->reviews);
179 maps_place_link_object_destroy(p->supplier);
181 maps_place_link_object_destroy(p->related);
183 if (p->supported_data)
184 maps_int_hashtable_destroy(p->supported_data);
186 g_slice_free(maps_place_s, place);
187 return MAPS_ERROR_NONE;
190 EXPORT_API int maps_place_clone(const maps_place_h origin,
191 maps_place_h *cloned)
193 if (!maps_condition_check_maps_feature())
194 return MAPS_ERROR_NOT_SUPPORTED;
195 if (!cloned || !origin)
196 return MAPS_ERROR_INVALID_PARAMETER;
198 int error = MAPS_ERROR_NONE;
200 error = maps_place_create(cloned);
201 if (!(*cloned) || (error != MAPS_ERROR_NONE))
204 maps_place_s *p = (maps_place_s *) origin;
207 error = maps_place_set_id(*cloned, p->id);
208 if (error != MAPS_ERROR_NONE)
213 error = maps_place_set_name(*cloned, p->name);
214 if (error != MAPS_ERROR_NONE)
219 error = maps_place_set_uri(*cloned, p->uri);
220 if (error != MAPS_ERROR_NONE)
225 error = maps_place_set_location(*cloned, p->location);
226 if (error != MAPS_ERROR_NONE)
230 error = maps_place_set_distance(*cloned, p->distance);
231 if (error != MAPS_ERROR_NONE)
235 error = maps_place_set_address(*cloned, p->address);
236 if (error != MAPS_ERROR_NONE)
241 error = maps_place_set_rating(*cloned, p->rating);
242 if (error != MAPS_ERROR_NONE)
247 error = maps_place_set_properties(*cloned, p->properties);
248 if (error != MAPS_ERROR_NONE)
253 error = maps_place_set_categories(*cloned, p->categories);
254 if (error != MAPS_ERROR_NONE)
259 error = maps_place_set_attributes(*cloned, p->attribute);
260 if (error != MAPS_ERROR_NONE)
265 error = maps_place_set_contacts(*cloned, p->contacts);
266 if (error != MAPS_ERROR_NONE)
271 error = maps_place_set_editorials(*cloned, p->editorials);
272 if (error != MAPS_ERROR_NONE)
277 error = maps_place_set_images(*cloned, p->images);
278 if (error != MAPS_ERROR_NONE)
283 error = maps_place_set_reviews(*cloned, p->reviews);
284 if (error != MAPS_ERROR_NONE)
289 error = maps_place_set_supplier_link(*cloned, p->supplier);
290 if (error != MAPS_ERROR_NONE)
295 error = maps_place_set_related_link(*cloned, p->related);
296 if (error != MAPS_ERROR_NONE)
300 if (p->supported_data) {
301 error = _maps_place_set_supported_data(*cloned, p->supported_data);
302 if (error != MAPS_ERROR_NONE)
306 return MAPS_ERROR_NONE;
310 maps_place_destroy(*cloned);
316 /*----------------------------------------------------------------------------*/
318 EXPORT_API int maps_place_get_id(const maps_place_h place, char **id)
320 if (!maps_condition_check_maps_feature())
321 return MAPS_ERROR_NOT_SUPPORTED;
323 return MAPS_ERROR_INVALID_PARAMETER;
324 if (!((maps_place_s *) place)->id)
325 return MAPS_ERROR_NOT_FOUND;
326 return maps_get_string(((maps_place_s *) place)->id,
327 _MAPS_PLACE_ID_MAX_LENGTH, id);
330 EXPORT_API int maps_place_get_name(const maps_place_h place, char **name)
332 if (!maps_condition_check_maps_feature())
333 return MAPS_ERROR_NOT_SUPPORTED;
335 return MAPS_ERROR_INVALID_PARAMETER;
336 if (!((maps_place_s *) place)->name)
337 return MAPS_ERROR_NOT_FOUND;
338 return maps_get_string(((maps_place_s *) place)->name,
339 _MAPS_PLACE_NAME_MAX_LENGTH, name);
342 EXPORT_API int maps_place_get_uri(const maps_place_h place, char **uri)
344 if (!maps_condition_check_maps_feature())
345 return MAPS_ERROR_NOT_SUPPORTED;
347 return MAPS_ERROR_INVALID_PARAMETER;
348 if (!((maps_place_s *) place)->uri)
349 return MAPS_ERROR_NOT_FOUND;
350 return maps_get_string(((maps_place_s *) place)->uri,
351 _MAPS_PLACE_URI_MAX_LENGTH, uri);
354 EXPORT_API int maps_place_get_location(const maps_place_h place,
355 maps_coordinates_h *location)
357 if (!maps_condition_check_maps_feature())
358 return MAPS_ERROR_NOT_SUPPORTED;
359 if (!place || !location)
360 return MAPS_ERROR_INVALID_PARAMETER;
361 if (!((maps_place_s *) place)->location)
362 return MAPS_ERROR_NOT_FOUND;
363 return maps_coordinates_clone(((maps_place_s *) place)->location,
367 EXPORT_API int maps_place_get_distance(const maps_place_h place, int *distance)
369 if (!maps_condition_check_maps_feature())
370 return MAPS_ERROR_NOT_SUPPORTED;
371 if (!place || !distance)
372 return MAPS_ERROR_INVALID_PARAMETER;
373 *distance = ((maps_place_s *) place)->distance;
374 return MAPS_ERROR_NONE;
377 EXPORT_API int maps_place_get_address(const maps_place_h place,
378 maps_address_h *address)
380 if (!maps_condition_check_maps_feature())
381 return MAPS_ERROR_NOT_SUPPORTED;
383 return MAPS_ERROR_INVALID_PARAMETER;
384 if (!__is_supported(place, MAPS_PLACE_ADDRESS))
385 return MAPS_ERROR_NOT_SUPPORTED;
387 return MAPS_ERROR_INVALID_PARAMETER;
388 if (!((maps_place_s *) place)->address)
389 return MAPS_ERROR_NOT_FOUND;
390 return maps_address_clone(((maps_place_s *) place)->address, address);
393 EXPORT_API int maps_place_get_rating(const maps_place_h place,
394 maps_place_rating_h *rating)
396 if (!maps_condition_check_maps_feature())
397 return MAPS_ERROR_NOT_SUPPORTED;
399 return MAPS_ERROR_INVALID_PARAMETER;
400 if (!__is_supported(place, MAPS_PLACE_RATING))
401 return MAPS_ERROR_NOT_SUPPORTED;
403 return MAPS_ERROR_INVALID_PARAMETER;
404 if (!((maps_place_s *) place)->rating)
405 return MAPS_ERROR_NOT_FOUND;
406 return maps_place_rating_clone(((maps_place_s *) place)->rating, rating);
409 EXPORT_API int maps_place_foreach_property(const maps_place_h place,
410 maps_place_properties_cb callback,
413 if (!maps_condition_check_maps_feature())
414 return MAPS_ERROR_NOT_SUPPORTED;
415 if (!place || !callback)
416 return MAPS_ERROR_INVALID_PARAMETER;
417 if (!((maps_place_s *) place)->properties)
418 return MAPS_ERROR_NOT_FOUND;
419 return maps_item_hashtable_foreach(((maps_place_s *) place)->properties,
420 callback, user_data);
423 EXPORT_API int maps_place_foreach_category(const maps_place_h place,
424 maps_place_categories_cb callback,
427 if (!maps_condition_check_maps_feature())
428 return MAPS_ERROR_NOT_SUPPORTED;
430 return MAPS_ERROR_INVALID_PARAMETER;
431 if (!__is_supported(place, MAPS_PLACE_CATEGORIES))
432 return MAPS_ERROR_NOT_SUPPORTED;
434 return MAPS_ERROR_INVALID_PARAMETER;
435 if (!((maps_place_s *) place)->categories)
436 return MAPS_ERROR_NOT_FOUND;
437 return maps_item_list_foreach(((maps_place_s *) place)->categories,
438 maps_place_category_clone, callback, user_data);
441 EXPORT_API int maps_place_foreach_attribute(const maps_place_h place,
442 maps_place_attributes_cb callback,
445 if (!maps_condition_check_maps_feature())
446 return MAPS_ERROR_NOT_SUPPORTED;
448 return MAPS_ERROR_INVALID_PARAMETER;
449 if (!__is_supported(place, MAPS_PLACE_ATTRIBUTES))
450 return MAPS_ERROR_NOT_SUPPORTED;
452 return MAPS_ERROR_INVALID_PARAMETER;
453 if (!((maps_place_s *) place)->attribute)
454 return MAPS_ERROR_NOT_FOUND;
455 return maps_item_list_foreach(((maps_place_s *) place)->attribute,
456 maps_place_attribute_clone, callback, user_data);
459 EXPORT_API int maps_place_foreach_contact(const maps_place_h place,
460 maps_place_contacts_cb callback,
463 if (!maps_condition_check_maps_feature())
464 return MAPS_ERROR_NOT_SUPPORTED;
466 return MAPS_ERROR_INVALID_PARAMETER;
467 if (!__is_supported(place, MAPS_PLACE_CONTACTS))
468 return MAPS_ERROR_NOT_SUPPORTED;
470 return MAPS_ERROR_INVALID_PARAMETER;
471 if (!((maps_place_s *) place)->contacts)
472 return MAPS_ERROR_NOT_FOUND;
473 return maps_item_list_foreach(((maps_place_s *) place)->contacts,
474 maps_place_contact_clone, callback, user_data);
477 EXPORT_API int maps_place_foreach_editorial(const maps_place_h place,
478 maps_place_editorials_cb callback,
481 if (!maps_condition_check_maps_feature())
482 return MAPS_ERROR_NOT_SUPPORTED;
484 return MAPS_ERROR_INVALID_PARAMETER;
485 if (!__is_supported(place, MAPS_PLACE_EDITORIALS))
486 return MAPS_ERROR_NOT_SUPPORTED;
488 return MAPS_ERROR_INVALID_PARAMETER;
489 if (!((maps_place_s *) place)->editorials)
490 return MAPS_ERROR_NOT_FOUND;
491 return maps_item_list_foreach(((maps_place_s *) place)->editorials,
492 maps_place_editorial_clone, callback, user_data);
495 EXPORT_API int maps_place_foreach_image(const maps_place_h place,
496 maps_place_images_cb callback,
499 if (!maps_condition_check_maps_feature())
500 return MAPS_ERROR_NOT_SUPPORTED;
502 return MAPS_ERROR_INVALID_PARAMETER;
503 if (!__is_supported(place, MAPS_PLACE_IMAGE))
504 return MAPS_ERROR_NOT_SUPPORTED;
506 return MAPS_ERROR_INVALID_PARAMETER;
507 if (!((maps_place_s *) place)->images)
508 return MAPS_ERROR_NOT_FOUND;
509 return maps_item_list_foreach(((maps_place_s *) place)->images,
510 maps_place_image_clone, callback, user_data);
513 EXPORT_API int maps_place_foreach_review(const maps_place_h place,
514 maps_place_reviews_cb callback,
517 if (!maps_condition_check_maps_feature())
518 return MAPS_ERROR_NOT_SUPPORTED;
520 return MAPS_ERROR_INVALID_PARAMETER;
521 if (!__is_supported(place, MAPS_PLACE_REVIEWS))
522 return MAPS_ERROR_NOT_SUPPORTED;
524 return MAPS_ERROR_INVALID_PARAMETER;
525 if (!((maps_place_s *) place)->reviews)
526 return MAPS_ERROR_NOT_FOUND;
527 return maps_item_list_foreach(((maps_place_s *) place)->reviews,
528 maps_place_review_clone, callback, user_data);
531 EXPORT_API int maps_place_get_supplier_link(const maps_place_h place,
532 maps_place_link_object_h *supplier)
534 if (!maps_condition_check_maps_feature())
535 return MAPS_ERROR_NOT_SUPPORTED;
537 return MAPS_ERROR_INVALID_PARAMETER;
538 if (!__is_supported(place, MAPS_PLACE_SUPPLIER))
539 return MAPS_ERROR_NOT_SUPPORTED;
541 return MAPS_ERROR_INVALID_PARAMETER;
542 if (!((maps_place_s *) place)->supplier)
543 return MAPS_ERROR_NOT_FOUND;
544 return maps_place_link_object_clone(((maps_place_s *) place)->supplier, supplier);
547 EXPORT_API int maps_place_get_related_link(const maps_place_h place,
548 maps_place_link_object_h *related)
550 if (!maps_condition_check_maps_feature())
551 return MAPS_ERROR_NOT_SUPPORTED;
553 return MAPS_ERROR_INVALID_PARAMETER;
554 if (!__is_supported(place, MAPS_PLACE_RELATED))
555 return MAPS_ERROR_NOT_SUPPORTED;
557 return MAPS_ERROR_INVALID_PARAMETER;
558 if (!((maps_place_s *) place)->related)
559 return MAPS_ERROR_NOT_FOUND;
560 return maps_place_link_object_clone(((maps_place_s *) place)->related, related);
563 int _maps_place_is_data_supported(const maps_place_h place,
564 maps_service_data_e data, bool *supported)
566 if (!maps_condition_check_maps_feature())
567 return MAPS_ERROR_NOT_SUPPORTED;
568 if (!place || !supported)
569 return MAPS_ERROR_INVALID_PARAMETER;
571 maps_place_s *p = (maps_place_s *)place;
572 if (!p->supported_data) {
573 /* This is a case when the "supported" flags are not set yet */
574 /* No need to limit access to fields */
576 return MAPS_ERROR_NONE;
580 return maps_int_hashtable_contains(p->supported_data, data, supported);
583 /*----------------------------------------------------------------------------*/
585 EXPORT_API int maps_place_set_id(maps_place_h place, const char *id)
587 if (!maps_condition_check_maps_feature())
588 return MAPS_ERROR_NOT_SUPPORTED;
590 return MAPS_ERROR_INVALID_PARAMETER;
591 return maps_set_string(id, _MAPS_PLACE_ID_MAX_LENGTH,
592 &((maps_place_s *) place)->id);
595 EXPORT_API int maps_place_set_name(maps_place_h place, const char *name)
597 if (!maps_condition_check_maps_feature())
598 return MAPS_ERROR_NOT_SUPPORTED;
600 return MAPS_ERROR_INVALID_PARAMETER;
601 return maps_set_string(name, _MAPS_PLACE_NAME_MAX_LENGTH,
602 &((maps_place_s *) place)->name);
605 EXPORT_API int maps_place_set_uri(maps_place_h place, const char *uri)
607 if (!maps_condition_check_maps_feature())
608 return MAPS_ERROR_NOT_SUPPORTED;
610 return MAPS_ERROR_INVALID_PARAMETER;
611 return maps_set_string(uri, _MAPS_PLACE_URI_MAX_LENGTH,
612 &((maps_place_s *) place)->uri);
615 EXPORT_API int maps_place_set_location(maps_place_h place, const maps_coordinates_h location)
617 if (!maps_condition_check_maps_feature())
618 return MAPS_ERROR_NOT_SUPPORTED;
619 if (!place || !location)
620 return MAPS_ERROR_INVALID_PARAMETER;
621 maps_place_s *p = (maps_place_s *) place;
623 maps_coordinates_destroy(p->location);
624 return maps_coordinates_clone(location, &p->location);
627 EXPORT_API int maps_place_set_distance(maps_place_h place, const int distance)
629 if (!maps_condition_check_maps_feature())
630 return MAPS_ERROR_NOT_SUPPORTED;
631 if (!place || distance < 0)
632 return MAPS_ERROR_INVALID_PARAMETER;
633 maps_place_s *p = (maps_place_s *) place;
634 p->distance = distance;
635 return MAPS_ERROR_NONE;
638 EXPORT_API int maps_place_set_address(maps_place_h place, const maps_address_h address)
640 if (!maps_condition_check_maps_feature())
641 return MAPS_ERROR_NOT_SUPPORTED;
642 if (!place || !address)
643 return MAPS_ERROR_INVALID_PARAMETER;
644 maps_place_s *p = (maps_place_s *) place;
646 maps_address_destroy(p->address);
647 return maps_address_clone(address, &p->address);
650 EXPORT_API int maps_place_set_categories(maps_place_h place, const maps_item_list_h categories)
652 if (!maps_condition_check_maps_feature())
653 return MAPS_ERROR_NOT_SUPPORTED;
654 if (!place || !categories)
655 return MAPS_ERROR_INVALID_PARAMETER;
656 maps_place_s *p = (maps_place_s *) place;
658 maps_item_list_remove_all(p->categories, maps_place_category_destroy);
659 maps_item_list_destroy(p->categories);
661 return maps_item_list_clone(categories, maps_place_category_clone, &p->categories);
664 EXPORT_API int maps_place_set_attributes(maps_place_h place, const maps_item_list_h attributes)
666 if (!maps_condition_check_maps_feature())
667 return MAPS_ERROR_NOT_SUPPORTED;
668 if (!place || !attributes)
669 return MAPS_ERROR_INVALID_PARAMETER;
670 maps_place_s *p = (maps_place_s *) place;
672 maps_item_list_remove_all(p->attribute, maps_place_attribute_destroy);
673 maps_item_list_destroy(p->attribute);
675 return maps_item_list_clone(attributes, maps_place_attribute_clone, &p->attribute);
678 EXPORT_API int maps_place_set_contacts(maps_place_h place, const maps_item_list_h contacts)
680 if (!maps_condition_check_maps_feature())
681 return MAPS_ERROR_NOT_SUPPORTED;
682 if (!place || !contacts)
683 return MAPS_ERROR_INVALID_PARAMETER;
684 maps_place_s *p = (maps_place_s *) place;
686 maps_item_list_remove_all(p->contacts, maps_place_contact_destroy);
687 maps_item_list_destroy(p->contacts);
689 return maps_item_list_clone(contacts, maps_place_contact_clone, &p->contacts);
692 EXPORT_API int maps_place_set_editorials(maps_place_h place, const maps_item_list_h editorials)
694 if (!maps_condition_check_maps_feature())
695 return MAPS_ERROR_NOT_SUPPORTED;
696 if (!place || !editorials)
697 return MAPS_ERROR_INVALID_PARAMETER;
698 maps_place_s *p = (maps_place_s *) place;
700 maps_item_list_remove_all(p->editorials, maps_place_editorial_destroy);
701 maps_item_list_destroy(p->editorials);
703 return maps_item_list_clone(editorials, maps_place_editorial_clone, &p->editorials);
706 EXPORT_API int maps_place_set_images(maps_place_h place, const maps_item_list_h images)
708 if (!maps_condition_check_maps_feature())
709 return MAPS_ERROR_NOT_SUPPORTED;
710 if (!place || !images)
711 return MAPS_ERROR_INVALID_PARAMETER;
712 maps_place_s *p = (maps_place_s *) place;
714 maps_item_list_remove_all(p->images, maps_place_image_destroy);
715 maps_item_list_destroy(p->images);
717 return maps_item_list_clone(images, maps_place_image_clone, &p->images);
720 EXPORT_API int maps_place_set_reviews(maps_place_h place, const maps_item_list_h reviews)
722 if (!maps_condition_check_maps_feature())
723 return MAPS_ERROR_NOT_SUPPORTED;
724 if (!place || !reviews)
725 return MAPS_ERROR_INVALID_PARAMETER;
726 maps_place_s *p = (maps_place_s *) place;
728 maps_item_list_remove_all(p->reviews, maps_place_review_destroy);
729 maps_item_list_destroy(p->reviews);
731 return maps_item_list_clone(reviews, maps_place_review_clone, &p->reviews);
734 EXPORT_API int maps_place_set_properties(maps_place_h place,
735 const maps_item_hashtable_h properties)
737 if (!maps_condition_check_maps_feature())
738 return MAPS_ERROR_NOT_SUPPORTED;
739 if (!place || !properties)
740 return MAPS_ERROR_INVALID_PARAMETER;
741 maps_place_s *p = (maps_place_s *) place;
743 maps_item_hashtable_destroy(p->properties);
744 return maps_item_hashtable_clone(properties, &p->properties);
747 EXPORT_API int maps_place_set_rating(maps_place_h place, const maps_place_rating_h rating)
749 if (!maps_condition_check_maps_feature())
750 return MAPS_ERROR_NOT_SUPPORTED;
751 if (!place || !rating)
752 return MAPS_ERROR_INVALID_PARAMETER;
753 maps_place_s *p = (maps_place_s *) place;
755 maps_place_rating_destroy(p->rating);
756 return maps_place_rating_clone(rating, &p->rating);
759 EXPORT_API int maps_place_set_supplier_link(maps_place_h place,
760 const maps_place_link_object_h supplier)
762 if (!maps_condition_check_maps_feature())
763 return MAPS_ERROR_NOT_SUPPORTED;
764 if (!place || !supplier)
765 return MAPS_ERROR_INVALID_PARAMETER;
766 maps_place_s *p = (maps_place_s *) place;
768 maps_place_link_object_destroy(p->supplier);
769 return maps_place_link_object_clone(supplier, &p->supplier);
772 EXPORT_API int maps_place_set_related_link(maps_place_h place,
773 const maps_place_link_object_h related)
775 if (!maps_condition_check_maps_feature())
776 return MAPS_ERROR_NOT_SUPPORTED;
777 if (!place || !related)
778 return MAPS_ERROR_INVALID_PARAMETER;
779 maps_place_s *p = (maps_place_s *) place;
781 maps_place_link_object_destroy(p->related);
782 return maps_place_link_object_clone(related, &p->related);
785 int _maps_place_set_supported_data(maps_place_h place,
786 const maps_int_hashtable_h supported_data)
788 if (!maps_condition_check_maps_feature())
789 return MAPS_ERROR_NOT_SUPPORTED;
790 if (!place || !supported_data)
791 return MAPS_ERROR_INVALID_PARAMETER;
792 maps_place_s *p = (maps_place_s *) place;
793 if (p->supported_data)
794 maps_int_hashtable_destroy(p->supported_data);
795 return maps_int_hashtable_clone(supported_data, &p->supported_data);
798 EXPORT_API int maps_place_list_foreach(const maps_place_list_h place_list,
799 maps_place_cb callback, void *user_data)
801 if (!maps_condition_check_maps_feature())
802 return MAPS_ERROR_NOT_SUPPORTED;
803 if (!place_list || !callback)
804 return MAPS_ERROR_INVALID_PARAMETER;
805 return maps_item_list_foreach_noclone((maps_item_list_h) place_list, callback, user_data);
808 EXPORT_API int maps_place_list_create(maps_place_list_h *place_list)
810 if (!maps_condition_check_maps_feature())
811 return MAPS_ERROR_NOT_SUPPORTED;
813 return MAPS_ERROR_INVALID_PARAMETER;
814 return maps_item_list_create(place_list);
817 EXPORT_API int maps_place_list_destroy(maps_place_list_h place_list)
819 if (!maps_condition_check_maps_feature())
820 return MAPS_ERROR_NOT_SUPPORTED;
822 return MAPS_ERROR_INVALID_PARAMETER;
824 int error = maps_item_list_remove_all(place_list, maps_place_destroy);
825 if (error != MAPS_ERROR_NONE)
827 return maps_item_list_destroy(place_list);