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_url_plugin.h"
19 #include "maps_util.h"
20 #include "maps_condition.h"
22 typedef struct _maps_place_url_s
28 const gsize _MAPS_PLACE_URL_PATH_MAX_LENGTH = MAPS_BASE_URL_MAX_LEN;
29 const gsize _MAPS_PLACE_URL_DESC_MAX_LENGTH = MAPS_BASE_DESC_MAX_LEN;
31 /*----------------------------------------------------------------------------*/
33 EXPORT_API int maps_place_url_create(maps_place_url_h *place)
35 if (!maps_condition_check_maps_feature())
36 return MAPS_ERROR_NOT_SUPPORTED;
38 return MAPS_ERROR_INVALID_PARAMETER;
40 *place = (maps_place_url_h) g_slice_new0(maps_place_url_s);
43 MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
44 return MAPS_ERROR_OUT_OF_MEMORY;
48 return MAPS_ERROR_NONE;
51 EXPORT_API int maps_place_url_destroy(maps_place_url_h place)
53 if (!maps_condition_check_maps_feature())
54 return MAPS_ERROR_NOT_SUPPORTED;
56 return MAPS_ERROR_INVALID_PARAMETER;
58 maps_place_url_s *u = (maps_place_url_s *) place;
65 g_slice_free(maps_place_url_s, place);
66 return MAPS_ERROR_NONE;
69 EXPORT_API int maps_place_url_clone(const maps_place_url_h origin,
70 maps_place_url_h *cloned)
72 if (!maps_condition_check_maps_feature())
73 return MAPS_ERROR_NOT_SUPPORTED;
74 if (!cloned || !origin)
75 return MAPS_ERROR_INVALID_PARAMETER;
77 int error = MAPS_ERROR_NONE;
79 error = maps_place_url_create(cloned);
80 if (!(*cloned) || (error != MAPS_ERROR_NONE))
83 maps_place_url_s* u = (maps_place_url_s*) origin;
86 error = maps_place_url_set_path(*cloned, u->path);
87 if (error != MAPS_ERROR_NONE)
92 error = maps_place_url_set_description(*cloned,
94 if (error != MAPS_ERROR_NONE)
98 return MAPS_ERROR_NONE;
102 maps_place_url_destroy(*cloned);
108 /*----------------------------------------------------------------------------*/
110 EXPORT_API int maps_place_url_get_path(const maps_place_url_h place, char **path)
112 if (!maps_condition_check_maps_feature())
113 return MAPS_ERROR_NOT_SUPPORTED;
115 return MAPS_ERROR_INVALID_PARAMETER;
116 if (!((maps_place_url_s *) place)->path)
117 return MAPS_ERROR_NOT_FOUND;
118 return maps_get_string(((maps_place_url_s *) place)->path,
119 _MAPS_PLACE_URL_PATH_MAX_LENGTH, path);
122 EXPORT_API int maps_place_url_get_description(const maps_place_url_h place, char **desc)
124 if (!maps_condition_check_maps_feature())
125 return MAPS_ERROR_NOT_SUPPORTED;
127 return MAPS_ERROR_INVALID_PARAMETER;
128 if (!((maps_place_url_s *) place)->desc)
129 return MAPS_ERROR_NOT_FOUND;
130 return maps_get_string(((maps_place_url_s *) place)->desc,
131 _MAPS_PLACE_URL_DESC_MAX_LENGTH, desc);
134 /*----------------------------------------------------------------------------*/
136 EXPORT_API int maps_place_url_set_path(maps_place_url_h place, const char *path)
138 if (!maps_condition_check_maps_feature())
139 return MAPS_ERROR_NOT_SUPPORTED;
141 return MAPS_ERROR_INVALID_PARAMETER;
142 return maps_set_string(path, _MAPS_PLACE_URL_PATH_MAX_LENGTH,
143 &((maps_place_url_s *) place)->path);
146 EXPORT_API int maps_place_url_set_description(maps_place_url_h place,
149 if (!maps_condition_check_maps_feature())
150 return MAPS_ERROR_NOT_SUPPORTED;
152 return MAPS_ERROR_INVALID_PARAMETER;
153 return maps_set_string(desc, _MAPS_PLACE_URL_DESC_MAX_LENGTH,
154 &((maps_place_url_s *) place)->desc);