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);
40 MAPS_LOGE("OUT_OF_MEMORY(0x%08x)", MAPS_ERROR_OUT_OF_MEMORY);
41 return MAPS_ERROR_OUT_OF_MEMORY;
44 return MAPS_ERROR_NONE;
47 EXPORT_API int maps_plugin_info_destroy(maps_plugin_info_h info)
49 if (!maps_condition_check_maps_feature())
50 return MAPS_ERROR_NOT_SUPPORTED;
52 return MAPS_ERROR_INVALID_PARAMETER;
53 int error = MAPS_ERROR_NONE;
55 maps_plugin_info_s *c = (maps_plugin_info_s *) info;
58 g_free(c->provider_name);
60 g_slice_free(maps_plugin_info_s, info);
64 EXPORT_API int maps_plugin_info_clone(const maps_plugin_info_h origin,
65 maps_plugin_info_h *cloned)
67 if (!maps_condition_check_maps_feature())
68 return MAPS_ERROR_NOT_SUPPORTED;
69 if (!cloned || !origin)
70 return MAPS_ERROR_INVALID_PARAMETER;
72 int error = MAPS_ERROR_NONE;
75 error = maps_plugin_info_create(cloned);
76 if (error != MAPS_ERROR_NONE)
79 maps_plugin_info_s *c = (maps_plugin_info_s *) origin;
81 if (c->provider_name) {
82 error = maps_plugin_info_set_provider_name(*cloned, c->provider_name);
83 if (error != MAPS_ERROR_NONE)
87 return MAPS_ERROR_NONE;
90 maps_plugin_info_destroy(*cloned);
95 /*----------------------------------------------------------------------------*/
97 EXPORT_API int maps_plugin_info_get_provider_name(const maps_plugin_info_h info,
100 if (!maps_condition_check_maps_feature())
101 return MAPS_ERROR_NOT_SUPPORTED;
102 if (!info || !provider_name)
103 return MAPS_ERROR_INVALID_PARAMETER;
104 return maps_get_string(((maps_plugin_info_s *) info)->provider_name,
105 _MAPS_PLUGIN_INFO_NAME_MAX_LENGTH, provider_name);
108 /*----------------------------------------------------------------------------*/
110 EXPORT_API int maps_plugin_info_set_provider_name(maps_plugin_info_h info,
111 const char *provider_name)
113 if (!maps_condition_check_maps_feature())
114 return MAPS_ERROR_NOT_SUPPORTED;
115 if (!info || !provider_name)
116 return MAPS_ERROR_INVALID_PARAMETER;
117 return maps_set_string(provider_name, _MAPS_PLUGIN_INFO_NAME_MAX_LENGTH,
118 &((maps_plugin_info_s *) info)->provider_name);