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_extra_types.h"
19 #include "maps_util.h"
20 #include "maps_place_category.h"
21 #include "maps_condition.h"
23 typedef struct _maps_place_category_s
28 } maps_place_category_s;
30 const gsize _MAPS_PLACE_CATEGORY_ID_MAX_LENGTH = MAPS_BASE_ID_MAX_LEN;
31 const gsize _MAPS_PLACE_CATEGORY_NAME_MAX_LENGTH = MAPS_BASE_NAME_MAX_LEN;
32 const gsize _MAPS_PLACE_CATEGORY_URL_MAX_LENGTH = MAPS_BASE_URL_MAX_LEN;
34 /*----------------------------------------------------------------------------*/
36 EXPORT_API int maps_place_category_create(maps_place_category_h *place)
38 if (!maps_condition_check_maps_feature())
39 return MAPS_ERROR_NOT_SUPPORTED;
41 return MAPS_ERROR_INVALID_PARAMETER;
42 *place = g_slice_new0(maps_place_category_s);
45 MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
46 return MAPS_ERROR_OUT_OF_MEMORY;
49 return MAPS_ERROR_NONE;
52 EXPORT_API int maps_place_category_destroy(maps_place_category_h place)
54 if (!maps_condition_check_maps_feature())
55 return MAPS_ERROR_NOT_SUPPORTED;
57 return MAPS_ERROR_INVALID_PARAMETER;
58 int error = MAPS_ERROR_NONE;
60 maps_place_category_s *c = (maps_place_category_s *) place;
69 g_slice_free(maps_place_category_s, place);
73 EXPORT_API int maps_place_category_clone(const maps_place_category_h origin,
74 maps_place_category_h *cloned)
76 if (!maps_condition_check_maps_feature())
77 return MAPS_ERROR_NOT_SUPPORTED;
78 if (!cloned || !origin)
79 return MAPS_ERROR_INVALID_PARAMETER;
81 int error = MAPS_ERROR_NONE;
84 error = maps_place_category_create(cloned);
85 if (error != MAPS_ERROR_NONE)
88 maps_place_category_s *c = (maps_place_category_s *) origin;
91 error = maps_place_category_set_id(*cloned, c->id);
92 if (error != MAPS_ERROR_NONE)
97 error = maps_place_category_set_name(*cloned, c->name);
98 if (error != MAPS_ERROR_NONE)
103 error = maps_place_category_set_url(*cloned, c->url);
104 if (error != MAPS_ERROR_NONE)
108 return MAPS_ERROR_NONE;
111 maps_place_category_destroy(*cloned);
116 /*----------------------------------------------------------------------------*/
118 EXPORT_API int maps_place_category_get_name(const maps_place_category_h place, char **name)
120 if (!maps_condition_check_maps_feature())
121 return MAPS_ERROR_NOT_SUPPORTED;
123 return MAPS_ERROR_INVALID_PARAMETER;
124 if (!((maps_place_category_s *) place)->name)
125 return MAPS_ERROR_NOT_FOUND;
126 return maps_get_string(((maps_place_category_s *) place)->name,
127 _MAPS_PLACE_CATEGORY_NAME_MAX_LENGTH, name);
130 EXPORT_API int maps_place_category_get_id(const maps_place_category_h place, char **id)
132 if (!maps_condition_check_maps_feature())
133 return MAPS_ERROR_NOT_SUPPORTED;
135 return MAPS_ERROR_INVALID_PARAMETER;
136 if (!((maps_place_category_s *) place)->id)
137 return MAPS_ERROR_NOT_FOUND;
138 return maps_get_string(((maps_place_category_s *) place)->id,
139 _MAPS_PLACE_CATEGORY_ID_MAX_LENGTH, id);
142 EXPORT_API int maps_place_category_get_url(const maps_place_category_h place, char **url)
144 if (!maps_condition_check_maps_feature())
145 return MAPS_ERROR_NOT_SUPPORTED;
147 return MAPS_ERROR_INVALID_PARAMETER;
148 if (!((maps_place_category_s *) place)->url)
149 return MAPS_ERROR_NOT_FOUND;
150 return maps_get_string(((maps_place_category_s *) place)->url,
151 _MAPS_PLACE_CATEGORY_URL_MAX_LENGTH, url);
154 /*----------------------------------------------------------------------------*/
156 EXPORT_API int maps_place_category_set_id(maps_place_category_h place, const char *id)
158 if (!maps_condition_check_maps_feature())
159 return MAPS_ERROR_NOT_SUPPORTED;
161 return MAPS_ERROR_INVALID_PARAMETER;
162 return maps_set_string(id, _MAPS_PLACE_CATEGORY_ID_MAX_LENGTH,
163 &((maps_place_category_s *) place)->id);
166 EXPORT_API int maps_place_category_set_name(maps_place_category_h place, const char *name)
168 if (!maps_condition_check_maps_feature())
169 return MAPS_ERROR_NOT_SUPPORTED;
171 return MAPS_ERROR_INVALID_PARAMETER;
172 return maps_set_string(name, _MAPS_PLACE_CATEGORY_NAME_MAX_LENGTH,
173 &((maps_place_category_s *) place)->name);
176 EXPORT_API int maps_place_category_set_url(maps_place_category_h place, const char *url)
178 if (!maps_condition_check_maps_feature())
179 return MAPS_ERROR_NOT_SUPPORTED;
181 return MAPS_ERROR_INVALID_PARAMETER;
182 return maps_set_string(url, _MAPS_PLACE_CATEGORY_URL_MAX_LENGTH,
183 &((maps_place_category_s *) place)->url);