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_link_object_plugin.h"
19 #include "maps_util.h"
20 #include "maps_condition.h"
22 typedef struct _maps_place_link_object_s
28 } maps_place_link_object_s;
30 const gsize _MAPS_PLACE_LINK_OBJECT_ID_MAX_LENGTH = MAPS_BASE_ID_MAX_LEN;
31 const gsize _MAPS_PLACE_LINK_OBJECT_NAME_MAX_LENGTH = MAPS_BASE_NAME_MAX_LEN;
32 const gsize _MAPS_PLACE_LINK_OBJECT_TYPE_MAX_LENGTH = MAPS_BASE_NAME_MAX_LEN;
33 const gsize _MAPS_PLACE_LINK_OBJECT_STRING_MAX_LENGTH = MAPS_BASE_URL_MAX_LEN;
35 /*----------------------------------------------------------------------------*/
37 EXPORT_API int maps_place_link_object_create(maps_place_link_object_h *place)
39 if (!maps_condition_check_maps_feature())
40 return MAPS_ERROR_NOT_SUPPORTED;
42 return MAPS_ERROR_INVALID_PARAMETER;
43 *place = (maps_place_link_object_h)
44 g_slice_new0(maps_place_link_object_s);
48 MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
49 return MAPS_ERROR_OUT_OF_MEMORY;
53 return MAPS_ERROR_NONE;
56 EXPORT_API int maps_place_link_object_destroy(maps_place_link_object_h place)
58 if (!maps_condition_check_maps_feature())
59 return MAPS_ERROR_NOT_SUPPORTED;
61 return MAPS_ERROR_INVALID_PARAMETER;
63 maps_place_link_object_s *lo = (maps_place_link_object_s *) place;
74 g_slice_free(maps_place_link_object_s, place);
75 return MAPS_ERROR_NONE;
78 EXPORT_API int maps_place_link_object_clone(const maps_place_link_object_h origin,
79 maps_place_link_object_h *cloned)
81 if (!maps_condition_check_maps_feature())
82 return MAPS_ERROR_NOT_SUPPORTED;
83 if (!cloned || !origin)
84 return MAPS_ERROR_INVALID_PARAMETER;
86 int error = MAPS_ERROR_NONE;
88 error = maps_place_link_object_create(cloned);
89 if (!(*cloned) || (error != MAPS_ERROR_NONE))
92 maps_place_link_object_s *lo =
93 (maps_place_link_object_s *) origin;
96 error = maps_place_link_object_set_id(*cloned, lo->id);
97 if (error != MAPS_ERROR_NONE)
102 error = maps_place_link_object_set_name(*cloned, lo->name);
103 if (error != MAPS_ERROR_NONE)
108 error = maps_place_link_object_set_type(*cloned, lo->type);
109 if (error != MAPS_ERROR_NONE)
114 error = maps_place_link_object_set_string(*cloned, lo->string);
115 if (error != MAPS_ERROR_NONE)
119 return MAPS_ERROR_NONE;
123 maps_place_link_object_destroy(*cloned);
129 /*----------------------------------------------------------------------------*/
131 EXPORT_API int maps_place_link_object_get_string(const maps_place_link_object_h place,
134 if (!maps_condition_check_maps_feature())
135 return MAPS_ERROR_NOT_SUPPORTED;
136 if (!place || !string)
137 return MAPS_ERROR_INVALID_PARAMETER;
138 if (!((maps_place_link_object_s *) place)->string)
139 return MAPS_ERROR_NOT_FOUND;
140 return maps_get_string(((maps_place_link_object_s *) place)->string,
141 _MAPS_PLACE_LINK_OBJECT_STRING_MAX_LENGTH, string);
144 EXPORT_API int maps_place_link_object_get_type(const maps_place_link_object_h place,
147 if (!maps_condition_check_maps_feature())
148 return MAPS_ERROR_NOT_SUPPORTED;
150 return MAPS_ERROR_INVALID_PARAMETER;
151 if (!((maps_place_link_object_s *) place)->type)
152 return MAPS_ERROR_NOT_FOUND;
153 return maps_get_string(((maps_place_link_object_s *) place)->type,
154 _MAPS_PLACE_LINK_OBJECT_TYPE_MAX_LENGTH, type);
157 EXPORT_API int maps_place_link_object_get_id(const maps_place_link_object_h place,
160 if (!maps_condition_check_maps_feature())
161 return MAPS_ERROR_NOT_SUPPORTED;
163 return MAPS_ERROR_INVALID_PARAMETER;
164 if (!((maps_place_link_object_s *) place)->id)
165 return MAPS_ERROR_NOT_FOUND;
166 return maps_get_string(((maps_place_link_object_s *) place)->id,
167 _MAPS_PLACE_LINK_OBJECT_ID_MAX_LENGTH, id);
170 EXPORT_API int maps_place_link_object_get_name(const maps_place_link_object_h place,
173 if (!maps_condition_check_maps_feature())
174 return MAPS_ERROR_NOT_SUPPORTED;
176 return MAPS_ERROR_INVALID_PARAMETER;
177 if (!((maps_place_link_object_s *) place)->name)
178 return MAPS_ERROR_NOT_FOUND;
179 return maps_get_string(((maps_place_link_object_s *) place)->name,
180 _MAPS_PLACE_LINK_OBJECT_NAME_MAX_LENGTH, name);
183 /*----------------------------------------------------------------------------*/
185 EXPORT_API int maps_place_link_object_set_id(maps_place_link_object_h place,
188 if (!maps_condition_check_maps_feature())
189 return MAPS_ERROR_NOT_SUPPORTED;
191 return MAPS_ERROR_INVALID_PARAMETER;
192 return maps_set_string(id, _MAPS_PLACE_LINK_OBJECT_ID_MAX_LENGTH,
193 &((maps_place_link_object_s *) place)->id);
196 EXPORT_API int maps_place_link_object_set_string(maps_place_link_object_h place,
199 if (!maps_condition_check_maps_feature())
200 return MAPS_ERROR_NOT_SUPPORTED;
201 if (!place || !string)
202 return MAPS_ERROR_INVALID_PARAMETER;
203 return maps_set_string(string,
204 _MAPS_PLACE_LINK_OBJECT_STRING_MAX_LENGTH,
205 &((maps_place_link_object_s *) place)->string);
208 EXPORT_API int maps_place_link_object_set_type(maps_place_link_object_h place,
211 if (!maps_condition_check_maps_feature())
212 return MAPS_ERROR_NOT_SUPPORTED;
214 return MAPS_ERROR_INVALID_PARAMETER;
215 return maps_set_string(type, _MAPS_PLACE_LINK_OBJECT_TYPE_MAX_LENGTH,
216 &((maps_place_link_object_s *) place)->type);
219 EXPORT_API int maps_place_link_object_set_name(maps_place_link_object_h place,
222 if (!maps_condition_check_maps_feature())
223 return MAPS_ERROR_NOT_SUPPORTED;
225 return MAPS_ERROR_INVALID_PARAMETER;
226 return maps_set_string(name, _MAPS_PLACE_LINK_OBJECT_NAME_MAX_LENGTH,
227 &((maps_place_link_object_s *) place)->name);