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_editorial_plugin.h"
19 #include "maps_place_media_plugin.h"
20 #include "maps_util.h"
21 #include "maps_condition.h"
23 typedef struct _maps_place_editorial_s
27 maps_place_media_h media;
28 } maps_place_editorial_s;
30 const gsize _MAPS_PLACE_EDITORIAL_DESCRIPTION_MAX_LENGTH = MAPS_BASE_DESC_MAX_LEN;
31 const gsize _MAPS_PLACE_EDITORIAL_LANGUAGE_MAX_LENGTH = MAPS_BASE_TYPE_MAX_LEN;
33 /*----------------------------------------------------------------------------*/
35 EXPORT_API int maps_place_editorial_create(maps_place_editorial_h *place)
37 if (!maps_condition_check_maps_feature())
38 return MAPS_ERROR_NOT_SUPPORTED;
40 return MAPS_ERROR_INVALID_PARAMETER;
42 *place = (maps_place_editorial_h) g_slice_new0(maps_place_editorial_s);
44 MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
45 return MAPS_ERROR_OUT_OF_MEMORY;
48 return MAPS_ERROR_NONE;
51 EXPORT_API int maps_place_editorial_destroy(maps_place_editorial_h place)
53 if (!maps_condition_check_maps_feature())
54 return MAPS_ERROR_NOT_SUPPORTED;
56 return MAPS_ERROR_INVALID_PARAMETER;
58 maps_place_editorial_s *e = (maps_place_editorial_s *) place;
61 g_free(e->description);
66 maps_place_media_destroy(e->media);
68 g_slice_free(maps_place_editorial_s, place);
69 return MAPS_ERROR_NONE;
72 EXPORT_API int maps_place_editorial_clone(const maps_place_editorial_h origin,
73 maps_place_editorial_h *cloned)
75 if (!maps_condition_check_maps_feature())
76 return MAPS_ERROR_NOT_SUPPORTED;
77 if (!cloned || !origin)
78 return MAPS_ERROR_INVALID_PARAMETER;
80 int error = MAPS_ERROR_NONE;
82 error = maps_place_editorial_create(cloned);
83 if (!(*cloned) || (error != MAPS_ERROR_NONE))
86 maps_place_editorial_s *e = (maps_place_editorial_s *) origin;
89 error = maps_place_editorial_set_description(*cloned, e->description);
90 if (error != MAPS_ERROR_NONE)
95 error = maps_place_editorial_set_language(*cloned, e->language);
96 if (error != MAPS_ERROR_NONE)
101 maps_place_editorial_s *e_cloned =
102 (maps_place_editorial_s *) (*cloned);
103 error = maps_place_media_clone(e->media, &e_cloned->media);
104 if (error != MAPS_ERROR_NONE)
108 return MAPS_ERROR_NONE;
111 maps_place_editorial_destroy(*cloned);
116 /*----------------------------------------------------------------------------*/
118 EXPORT_API int maps_place_editorial_get_description(const maps_place_editorial_h place,
121 if (!maps_condition_check_maps_feature())
122 return MAPS_ERROR_NOT_SUPPORTED;
123 if (!place || !description)
124 return MAPS_ERROR_INVALID_PARAMETER;
125 if (!((maps_place_editorial_s *) place)->description)
126 return MAPS_ERROR_NOT_FOUND;
127 return maps_get_string(((maps_place_editorial_s *) place)->description,
128 _MAPS_PLACE_EDITORIAL_DESCRIPTION_MAX_LENGTH, description);
131 EXPORT_API int maps_place_editorial_get_language(const maps_place_editorial_h place,
134 if (!maps_condition_check_maps_feature())
135 return MAPS_ERROR_NOT_SUPPORTED;
136 if (!place || !language)
137 return MAPS_ERROR_INVALID_PARAMETER;
138 if (!((maps_place_editorial_s *) place)->language)
139 return MAPS_ERROR_NOT_FOUND;
140 return maps_get_string(((maps_place_editorial_s *) place)->language,
141 _MAPS_PLACE_EDITORIAL_LANGUAGE_MAX_LENGTH, language);
144 EXPORT_API int maps_place_editorial_get_media(const maps_place_editorial_h place,
145 maps_place_media_h *media)
147 if (!maps_condition_check_maps_feature())
148 return MAPS_ERROR_NOT_SUPPORTED;
149 if (!place || !media)
150 return MAPS_ERROR_INVALID_PARAMETER;
151 if (!((maps_place_editorial_s *) place)->media)
152 return MAPS_ERROR_NOT_FOUND;
153 return maps_place_media_clone(((maps_place_editorial_s *) place)->media, media);
156 /*----------------------------------------------------------------------------*/
158 EXPORT_API int maps_place_editorial_set_description(maps_place_editorial_h place,
159 const char *description)
161 if (!maps_condition_check_maps_feature())
162 return MAPS_ERROR_NOT_SUPPORTED;
163 if (!place || !description)
164 return MAPS_ERROR_INVALID_PARAMETER;
165 return maps_set_string(description, _MAPS_PLACE_EDITORIAL_DESCRIPTION_MAX_LENGTH,
166 &((maps_place_editorial_s *) place)->description);
169 EXPORT_API int maps_place_editorial_set_language(maps_place_editorial_h place,
170 const char *language)
172 if (!maps_condition_check_maps_feature())
173 return MAPS_ERROR_NOT_SUPPORTED;
174 if (!place || !language)
175 return MAPS_ERROR_INVALID_PARAMETER;
176 return maps_set_string(language, _MAPS_PLACE_EDITORIAL_LANGUAGE_MAX_LENGTH,
177 &((maps_place_editorial_s *) place)->language);
180 EXPORT_API int maps_place_editorial_set_media(maps_place_editorial_h place,
181 const maps_place_media_h media)
183 if (!maps_condition_check_maps_feature())
184 return MAPS_ERROR_NOT_SUPPORTED;
185 if (!place || !media)
186 return MAPS_ERROR_INVALID_PARAMETER;
187 maps_place_editorial_s *e = (maps_place_editorial_s *) place;
189 maps_place_media_destroy(e->media);
190 return maps_place_media_clone(media, &e->media);