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);
46 MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
47 return MAPS_ERROR_OUT_OF_MEMORY;
51 return MAPS_ERROR_NONE;
54 EXPORT_API int maps_place_category_destroy(maps_place_category_h place)
56 if (!maps_condition_check_maps_feature())
57 return MAPS_ERROR_NOT_SUPPORTED;
59 return MAPS_ERROR_INVALID_PARAMETER;
60 int error = MAPS_ERROR_NONE;
62 maps_place_category_s *c = (maps_place_category_s *) place;
71 g_slice_free(maps_place_category_s, place);
75 EXPORT_API int maps_place_category_clone(const maps_place_category_h origin,
76 maps_place_category_h *cloned)
78 if (!maps_condition_check_maps_feature())
79 return MAPS_ERROR_NOT_SUPPORTED;
80 if (!cloned || !origin)
81 return MAPS_ERROR_INVALID_PARAMETER;
83 int error = MAPS_ERROR_NONE;
86 error = maps_place_category_create(cloned);
87 if (error != MAPS_ERROR_NONE)
90 maps_place_category_s *c = (maps_place_category_s *) origin;
93 error = maps_place_category_set_id(*cloned, c->id);
94 if (error != MAPS_ERROR_NONE)
99 error = maps_place_category_set_name(*cloned, c->name);
100 if (error != MAPS_ERROR_NONE)
105 error = maps_place_category_set_url(*cloned, c->url);
106 if (error != MAPS_ERROR_NONE)
110 return MAPS_ERROR_NONE;
114 maps_place_category_destroy(*cloned);
120 /*----------------------------------------------------------------------------*/
122 EXPORT_API int maps_place_category_get_name(const maps_place_category_h place, char **name)
124 if (!maps_condition_check_maps_feature())
125 return MAPS_ERROR_NOT_SUPPORTED;
127 return MAPS_ERROR_INVALID_PARAMETER;
128 if (!((maps_place_category_s *) place)->name)
129 return MAPS_ERROR_NOT_FOUND;
130 return maps_get_string(((maps_place_category_s *) place)->name,
131 _MAPS_PLACE_CATEGORY_NAME_MAX_LENGTH, name);
134 EXPORT_API int maps_place_category_get_id(const maps_place_category_h place, char **id)
136 if (!maps_condition_check_maps_feature())
137 return MAPS_ERROR_NOT_SUPPORTED;
139 return MAPS_ERROR_INVALID_PARAMETER;
140 if (!((maps_place_category_s *) place)->id)
141 return MAPS_ERROR_NOT_FOUND;
142 return maps_get_string(((maps_place_category_s *) place)->id,
143 _MAPS_PLACE_CATEGORY_ID_MAX_LENGTH, id);
146 EXPORT_API int maps_place_category_get_url(const maps_place_category_h place, char **url)
148 if (!maps_condition_check_maps_feature())
149 return MAPS_ERROR_NOT_SUPPORTED;
151 return MAPS_ERROR_INVALID_PARAMETER;
152 if (!((maps_place_category_s *) place)->url)
153 return MAPS_ERROR_NOT_FOUND;
154 return maps_get_string(((maps_place_category_s *) place)->url,
155 _MAPS_PLACE_CATEGORY_URL_MAX_LENGTH, url);
158 /*----------------------------------------------------------------------------*/
160 EXPORT_API int maps_place_category_set_id(maps_place_category_h place, const char *id)
162 if (!maps_condition_check_maps_feature())
163 return MAPS_ERROR_NOT_SUPPORTED;
165 return MAPS_ERROR_INVALID_PARAMETER;
166 return maps_set_string(id, _MAPS_PLACE_CATEGORY_ID_MAX_LENGTH,
167 &((maps_place_category_s *) place)->id);
170 EXPORT_API int maps_place_category_set_name(maps_place_category_h place, const char *name)
172 if (!maps_condition_check_maps_feature())
173 return MAPS_ERROR_NOT_SUPPORTED;
175 return MAPS_ERROR_INVALID_PARAMETER;
176 return maps_set_string(name, _MAPS_PLACE_CATEGORY_NAME_MAX_LENGTH,
177 &((maps_place_category_s *) place)->name);
180 EXPORT_API int maps_place_category_set_url(maps_place_category_h place, const char *url)
182 if (!maps_condition_check_maps_feature())
183 return MAPS_ERROR_NOT_SUPPORTED;
185 return MAPS_ERROR_INVALID_PARAMETER;
186 return maps_set_string(url, _MAPS_PLACE_CATEGORY_URL_MAX_LENGTH,
187 &((maps_place_category_s *) place)->url);