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);
45 MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
46 return MAPS_ERROR_OUT_OF_MEMORY;
50 return MAPS_ERROR_NONE;
53 EXPORT_API int maps_place_editorial_destroy(maps_place_editorial_h place)
55 if (!maps_condition_check_maps_feature())
56 return MAPS_ERROR_NOT_SUPPORTED;
58 return MAPS_ERROR_INVALID_PARAMETER;
60 maps_place_editorial_s *e = (maps_place_editorial_s *) place;
63 g_free(e->description);
68 maps_place_media_destroy(e->media);
70 g_slice_free(maps_place_editorial_s, place);
71 return MAPS_ERROR_NONE;
74 EXPORT_API int maps_place_editorial_clone(const maps_place_editorial_h origin,
75 maps_place_editorial_h *cloned)
77 if (!maps_condition_check_maps_feature())
78 return MAPS_ERROR_NOT_SUPPORTED;
79 if (!cloned || !origin)
80 return MAPS_ERROR_INVALID_PARAMETER;
82 int error = MAPS_ERROR_NONE;
84 error = maps_place_editorial_create(cloned);
85 if (!(*cloned) || (error != MAPS_ERROR_NONE))
88 maps_place_editorial_s *e = (maps_place_editorial_s *) origin;
91 error = maps_place_editorial_set_description(*cloned, e->description);
92 if (error != MAPS_ERROR_NONE)
97 error = maps_place_editorial_set_language(*cloned, e->language);
98 if (error != MAPS_ERROR_NONE)
103 maps_place_editorial_s *e_cloned =
104 (maps_place_editorial_s *) (*cloned);
105 error = maps_place_media_clone(e->media, &e_cloned->media);
106 if (error != MAPS_ERROR_NONE)
110 return MAPS_ERROR_NONE;
114 maps_place_editorial_destroy(*cloned);
120 /*----------------------------------------------------------------------------*/
122 EXPORT_API int maps_place_editorial_get_description(const maps_place_editorial_h place,
125 if (!maps_condition_check_maps_feature())
126 return MAPS_ERROR_NOT_SUPPORTED;
127 if (!place || !description)
128 return MAPS_ERROR_INVALID_PARAMETER;
129 if (!((maps_place_editorial_s *) place)->description)
130 return MAPS_ERROR_NOT_FOUND;
131 return maps_get_string(((maps_place_editorial_s *) place)->description,
132 _MAPS_PLACE_EDITORIAL_DESCRIPTION_MAX_LENGTH, description);
135 EXPORT_API int maps_place_editorial_get_language(const maps_place_editorial_h place,
138 if (!maps_condition_check_maps_feature())
139 return MAPS_ERROR_NOT_SUPPORTED;
140 if (!place || !language)
141 return MAPS_ERROR_INVALID_PARAMETER;
142 if (!((maps_place_editorial_s *) place)->language)
143 return MAPS_ERROR_NOT_FOUND;
144 return maps_get_string(((maps_place_editorial_s *) place)->language,
145 _MAPS_PLACE_EDITORIAL_LANGUAGE_MAX_LENGTH, language);
148 EXPORT_API int maps_place_editorial_get_media(const maps_place_editorial_h place,
149 maps_place_media_h *media)
151 if (!maps_condition_check_maps_feature())
152 return MAPS_ERROR_NOT_SUPPORTED;
153 if (!place || !media)
154 return MAPS_ERROR_INVALID_PARAMETER;
155 if (!((maps_place_editorial_s *) place)->media)
156 return MAPS_ERROR_NOT_FOUND;
157 return maps_place_media_clone(((maps_place_editorial_s *) place)->media, media);
160 /*----------------------------------------------------------------------------*/
162 EXPORT_API int maps_place_editorial_set_description(maps_place_editorial_h place,
163 const char *description)
165 if (!maps_condition_check_maps_feature())
166 return MAPS_ERROR_NOT_SUPPORTED;
167 if (!place || !description)
168 return MAPS_ERROR_INVALID_PARAMETER;
169 return maps_set_string(description, _MAPS_PLACE_EDITORIAL_DESCRIPTION_MAX_LENGTH,
170 &((maps_place_editorial_s *) place)->description);
173 EXPORT_API int maps_place_editorial_set_language(maps_place_editorial_h place,
174 const char *language)
176 if (!maps_condition_check_maps_feature())
177 return MAPS_ERROR_NOT_SUPPORTED;
178 if (!place || !language)
179 return MAPS_ERROR_INVALID_PARAMETER;
180 return maps_set_string(language, _MAPS_PLACE_EDITORIAL_LANGUAGE_MAX_LENGTH,
181 &((maps_place_editorial_s *) place)->language);
184 EXPORT_API int maps_place_editorial_set_media(maps_place_editorial_h place,
185 const maps_place_media_h media)
187 if (!maps_condition_check_maps_feature())
188 return MAPS_ERROR_NOT_SUPPORTED;
189 if (!place || !media)
190 return MAPS_ERROR_INVALID_PARAMETER;
191 maps_place_editorial_s *e = (maps_place_editorial_s *) place;
193 maps_place_media_destroy(e->media);
194 return maps_place_media_clone(media, &e->media);