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_url_plugin.h"
19 #include "maps_util.h"
20 #include "maps_condition.h"
22 typedef struct _maps_place_url_s
28 const gsize _MAPS_PLACE_URL_PATH_MAX_LENGTH = MAPS_BASE_URL_MAX_LEN;
29 const gsize _MAPS_PLACE_URL_DESC_MAX_LENGTH = MAPS_BASE_DESC_MAX_LEN;
31 /*----------------------------------------------------------------------------*/
33 EXPORT_API int maps_place_url_create(maps_place_url_h *place)
35 if (!maps_condition_check_maps_feature())
36 return MAPS_ERROR_NOT_SUPPORTED;
38 return MAPS_ERROR_INVALID_PARAMETER;
40 *place = (maps_place_url_h) g_slice_new0(maps_place_url_s);
42 MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
43 return MAPS_ERROR_OUT_OF_MEMORY;
46 return MAPS_ERROR_NONE;
49 EXPORT_API int maps_place_url_destroy(maps_place_url_h place)
51 if (!maps_condition_check_maps_feature())
52 return MAPS_ERROR_NOT_SUPPORTED;
54 return MAPS_ERROR_INVALID_PARAMETER;
56 maps_place_url_s *u = (maps_place_url_s *) place;
63 g_slice_free(maps_place_url_s, place);
64 return MAPS_ERROR_NONE;
67 EXPORT_API int maps_place_url_clone(const maps_place_url_h origin,
68 maps_place_url_h *cloned)
70 if (!maps_condition_check_maps_feature())
71 return MAPS_ERROR_NOT_SUPPORTED;
72 if (!cloned || !origin)
73 return MAPS_ERROR_INVALID_PARAMETER;
75 int error = MAPS_ERROR_NONE;
77 error = maps_place_url_create(cloned);
78 if (!(*cloned) || (error != MAPS_ERROR_NONE))
81 maps_place_url_s* u = (maps_place_url_s*) origin;
84 error = maps_place_url_set_path(*cloned, u->path);
85 if (error != MAPS_ERROR_NONE)
90 error = maps_place_url_set_description(*cloned,
92 if (error != MAPS_ERROR_NONE)
96 return MAPS_ERROR_NONE;
99 maps_place_url_destroy(*cloned);
104 /*----------------------------------------------------------------------------*/
106 EXPORT_API int maps_place_url_get_path(const maps_place_url_h place, char **path)
108 if (!maps_condition_check_maps_feature())
109 return MAPS_ERROR_NOT_SUPPORTED;
111 return MAPS_ERROR_INVALID_PARAMETER;
112 if (!((maps_place_url_s *) place)->path)
113 return MAPS_ERROR_NOT_FOUND;
114 return maps_get_string(((maps_place_url_s *) place)->path,
115 _MAPS_PLACE_URL_PATH_MAX_LENGTH, path);
118 EXPORT_API int maps_place_url_get_description(const maps_place_url_h place, char **desc)
120 if (!maps_condition_check_maps_feature())
121 return MAPS_ERROR_NOT_SUPPORTED;
123 return MAPS_ERROR_INVALID_PARAMETER;
124 if (!((maps_place_url_s *) place)->desc)
125 return MAPS_ERROR_NOT_FOUND;
126 return maps_get_string(((maps_place_url_s *) place)->desc,
127 _MAPS_PLACE_URL_DESC_MAX_LENGTH, desc);
130 /*----------------------------------------------------------------------------*/
132 EXPORT_API int maps_place_url_set_path(maps_place_url_h place, const char *path)
134 if (!maps_condition_check_maps_feature())
135 return MAPS_ERROR_NOT_SUPPORTED;
137 return MAPS_ERROR_INVALID_PARAMETER;
138 return maps_set_string(path, _MAPS_PLACE_URL_PATH_MAX_LENGTH,
139 &((maps_place_url_s *) place)->path);
142 EXPORT_API int maps_place_url_set_description(maps_place_url_h place,
145 if (!maps_condition_check_maps_feature())
146 return MAPS_ERROR_NOT_SUPPORTED;
148 return MAPS_ERROR_INVALID_PARAMETER;
149 return maps_set_string(desc, _MAPS_PLACE_URL_DESC_MAX_LENGTH,
150 &((maps_place_url_s *) place)->desc);