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_plugin_info.h"
19 #include "maps_util.h"
20 #include "maps_condition.h"
22 typedef struct _maps_plugin_info_s
27 const gsize _MAPS_PLUGIN_INFO_NAME_MAX_LENGTH = MAPS_BASE_NAME_MAX_LEN;
29 /*----------------------------------------------------------------------------*/
31 EXPORT_API int maps_plugin_info_create(maps_plugin_info_h *info)
33 if (!maps_condition_check_maps_feature())
34 return MAPS_ERROR_NOT_SUPPORTED;
36 return MAPS_ERROR_INVALID_PARAMETER;
37 *info = g_slice_new0(maps_plugin_info_s);
41 MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
42 return MAPS_ERROR_OUT_OF_MEMORY;
46 return MAPS_ERROR_NONE;
49 EXPORT_API int maps_plugin_info_destroy(maps_plugin_info_h info)
51 if (!maps_condition_check_maps_feature())
52 return MAPS_ERROR_NOT_SUPPORTED;
54 return MAPS_ERROR_INVALID_PARAMETER;
55 int error = MAPS_ERROR_NONE;
57 maps_plugin_info_s *c = (maps_plugin_info_s *) info;
60 g_free(c->provider_name);
62 g_slice_free(maps_plugin_info_s, info);
66 EXPORT_API int maps_plugin_info_clone(const maps_plugin_info_h origin,
67 maps_plugin_info_h *cloned)
69 if (!maps_condition_check_maps_feature())
70 return MAPS_ERROR_NOT_SUPPORTED;
71 if (!cloned || !origin)
72 return MAPS_ERROR_INVALID_PARAMETER;
74 int error = MAPS_ERROR_NONE;
77 error = maps_plugin_info_create(cloned);
78 if (error != MAPS_ERROR_NONE)
81 maps_plugin_info_s *c = (maps_plugin_info_s *) origin;
83 if (c->provider_name) {
84 error = maps_plugin_info_set_provider_name(*cloned, c->provider_name);
85 if (error != MAPS_ERROR_NONE)
89 return MAPS_ERROR_NONE;
93 maps_plugin_info_destroy(*cloned);
99 /*----------------------------------------------------------------------------*/
101 EXPORT_API int maps_plugin_info_get_provider_name(const maps_plugin_info_h info,
102 char **provider_name)
104 if (!maps_condition_check_maps_feature())
105 return MAPS_ERROR_NOT_SUPPORTED;
106 if (!info || !provider_name)
107 return MAPS_ERROR_INVALID_PARAMETER;
108 return maps_get_string(((maps_plugin_info_s *) info)->provider_name,
109 _MAPS_PLUGIN_INFO_NAME_MAX_LENGTH, provider_name);
112 /*----------------------------------------------------------------------------*/
114 EXPORT_API int maps_plugin_info_set_provider_name(maps_plugin_info_h info,
115 const char *provider_name)
117 if (!maps_condition_check_maps_feature())
118 return MAPS_ERROR_NOT_SUPPORTED;
119 if (!info || !provider_name)
120 return MAPS_ERROR_INVALID_PARAMETER;
121 return maps_set_string(provider_name, _MAPS_PLUGIN_INFO_NAME_MAX_LENGTH,
122 &((maps_plugin_info_s *) info)->provider_name);