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);
47 MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
48 return MAPS_ERROR_OUT_OF_MEMORY;
51 return MAPS_ERROR_NONE;
54 EXPORT_API int maps_place_link_object_destroy(maps_place_link_object_h place)
56 if (!maps_condition_check_maps_feature())
57 return MAPS_ERROR_NOT_SUPPORTED;
59 return MAPS_ERROR_INVALID_PARAMETER;
61 maps_place_link_object_s *lo = (maps_place_link_object_s *) place;
72 g_slice_free(maps_place_link_object_s, place);
73 return MAPS_ERROR_NONE;
76 EXPORT_API int maps_place_link_object_clone(const maps_place_link_object_h origin,
77 maps_place_link_object_h *cloned)
79 if (!maps_condition_check_maps_feature())
80 return MAPS_ERROR_NOT_SUPPORTED;
81 if (!cloned || !origin)
82 return MAPS_ERROR_INVALID_PARAMETER;
84 int error = MAPS_ERROR_NONE;
86 error = maps_place_link_object_create(cloned);
87 if (!(*cloned) || (error != MAPS_ERROR_NONE))
90 maps_place_link_object_s *lo =
91 (maps_place_link_object_s *) origin;
94 error = maps_place_link_object_set_id(*cloned, lo->id);
95 if (error != MAPS_ERROR_NONE)
100 error = maps_place_link_object_set_name(*cloned, lo->name);
101 if (error != MAPS_ERROR_NONE)
106 error = maps_place_link_object_set_type(*cloned, lo->type);
107 if (error != MAPS_ERROR_NONE)
112 error = maps_place_link_object_set_string(*cloned, lo->string);
113 if (error != MAPS_ERROR_NONE)
117 return MAPS_ERROR_NONE;
120 maps_place_link_object_destroy(*cloned);
125 /*----------------------------------------------------------------------------*/
127 EXPORT_API int maps_place_link_object_get_string(const maps_place_link_object_h place,
130 if (!maps_condition_check_maps_feature())
131 return MAPS_ERROR_NOT_SUPPORTED;
132 if (!place || !string)
133 return MAPS_ERROR_INVALID_PARAMETER;
134 if (!((maps_place_link_object_s *) place)->string)
135 return MAPS_ERROR_NOT_FOUND;
136 return maps_get_string(((maps_place_link_object_s *) place)->string,
137 _MAPS_PLACE_LINK_OBJECT_STRING_MAX_LENGTH, string);
140 EXPORT_API int maps_place_link_object_get_type(const maps_place_link_object_h place,
143 if (!maps_condition_check_maps_feature())
144 return MAPS_ERROR_NOT_SUPPORTED;
146 return MAPS_ERROR_INVALID_PARAMETER;
147 if (!((maps_place_link_object_s *) place)->type)
148 return MAPS_ERROR_NOT_FOUND;
149 return maps_get_string(((maps_place_link_object_s *) place)->type,
150 _MAPS_PLACE_LINK_OBJECT_TYPE_MAX_LENGTH, type);
153 EXPORT_API int maps_place_link_object_get_id(const maps_place_link_object_h place,
156 if (!maps_condition_check_maps_feature())
157 return MAPS_ERROR_NOT_SUPPORTED;
159 return MAPS_ERROR_INVALID_PARAMETER;
160 if (!((maps_place_link_object_s *) place)->id)
161 return MAPS_ERROR_NOT_FOUND;
162 return maps_get_string(((maps_place_link_object_s *) place)->id,
163 _MAPS_PLACE_LINK_OBJECT_ID_MAX_LENGTH, id);
166 EXPORT_API int maps_place_link_object_get_name(const maps_place_link_object_h place,
169 if (!maps_condition_check_maps_feature())
170 return MAPS_ERROR_NOT_SUPPORTED;
172 return MAPS_ERROR_INVALID_PARAMETER;
173 if (!((maps_place_link_object_s *) place)->name)
174 return MAPS_ERROR_NOT_FOUND;
175 return maps_get_string(((maps_place_link_object_s *) place)->name,
176 _MAPS_PLACE_LINK_OBJECT_NAME_MAX_LENGTH, name);
179 /*----------------------------------------------------------------------------*/
181 EXPORT_API int maps_place_link_object_set_id(maps_place_link_object_h place,
184 if (!maps_condition_check_maps_feature())
185 return MAPS_ERROR_NOT_SUPPORTED;
187 return MAPS_ERROR_INVALID_PARAMETER;
188 return maps_set_string(id, _MAPS_PLACE_LINK_OBJECT_ID_MAX_LENGTH,
189 &((maps_place_link_object_s *) place)->id);
192 EXPORT_API int maps_place_link_object_set_string(maps_place_link_object_h place,
195 if (!maps_condition_check_maps_feature())
196 return MAPS_ERROR_NOT_SUPPORTED;
197 if (!place || !string)
198 return MAPS_ERROR_INVALID_PARAMETER;
199 return maps_set_string(string,
200 _MAPS_PLACE_LINK_OBJECT_STRING_MAX_LENGTH,
201 &((maps_place_link_object_s *) place)->string);
204 EXPORT_API int maps_place_link_object_set_type(maps_place_link_object_h place,
207 if (!maps_condition_check_maps_feature())
208 return MAPS_ERROR_NOT_SUPPORTED;
210 return MAPS_ERROR_INVALID_PARAMETER;
211 return maps_set_string(type, _MAPS_PLACE_LINK_OBJECT_TYPE_MAX_LENGTH,
212 &((maps_place_link_object_s *) place)->type);
215 EXPORT_API int maps_place_link_object_set_name(maps_place_link_object_h place,
218 if (!maps_condition_check_maps_feature())
219 return MAPS_ERROR_NOT_SUPPORTED;
221 return MAPS_ERROR_INVALID_PARAMETER;
222 return maps_set_string(name, _MAPS_PLACE_LINK_OBJECT_NAME_MAX_LENGTH,
223 &((maps_place_link_object_s *) place)->name);