4 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
7 * Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
26 #include "location/location-log.h"
28 #include "location/location-module-internal.h"
30 #include "location/location-geocode.h"
31 #include "location/location-marshal.h"
32 #include "location/location-ielement.h"
34 typedef struct _LocationGeocodePrivate {
36 } LocationGeocodePrivate;
43 #define DEFAULT_SERVICE "decarta"
45 #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOCATION_TYPE_GEOCODE, LocationGeocodePrivate))
47 static void location_ielement_interface_init (LocationIElementInterface *iface);
49 G_DEFINE_TYPE_WITH_CODE (LocationGeocode, location_geocode, G_TYPE_OBJECT,
50 G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT, location_ielement_interface_init));
54 location_geocode_dispose (GObject *gobject)
56 LOCATION_LOGD("location_geocode_dispose");
58 G_OBJECT_CLASS (location_geocode_parent_class)->dispose (gobject);
62 location_geocode_finalize (GObject *gobject)
64 LOCATION_LOGD("location_geocode_finalize");
65 LocationGeocodePrivate* priv = GET_PRIVATE(gobject);
66 module_free(priv->mod, "geocode");
68 G_OBJECT_CLASS (location_geocode_parent_class)->finalize (gobject);
72 location_geocode_get_property (GObject *object,
77 LocationGeocodePrivate *priv = GET_PRIVATE (object);
79 g_return_if_fail(priv->mod);
80 g_return_if_fail(priv->mod->handler);
82 case PROP_SERVICE_NAME:{
83 char* service_name = NULL;
84 if(priv->mod->ops.get_service_name){
85 if( LOCATION_ERROR_NONE != priv->mod->ops.get_service_name(priv->mod->handler, &service_name) ){
89 LOCATION_LOGD("Get prop>> Service name: %s", service_name);
90 g_value_set_string(value, service_name);
95 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
101 location_geocode_get_geocode (LocationGeocode *self,
102 const LocationAddress *address,
103 GList **position_list,
104 GList **accuracy_list)
106 LOCATION_LOGD("location_geocode_get_geocode");
107 LocationGeocodePrivate* priv = GET_PRIVATE(self);
108 g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
109 g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
110 g_return_val_if_fail (priv->mod->ops.get_geocode, LOCATION_ERROR_NOT_AVAILABLE);
111 return (priv->mod->ops.get_geocode)(priv->mod->handler, address, position_list, accuracy_list);
115 location_geocode_get_geocode_freeform (LocationGeocode *self,
116 const gchar *address,
117 GList **position_list,
118 GList **accuracy_list)
120 LOCATION_LOGD("location_geocode_get_geocode_freeform");
121 LocationGeocodePrivate* priv = GET_PRIVATE(self);
122 g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
123 g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
124 g_return_val_if_fail (priv->mod->ops.get_geocode_freetext, LOCATION_ERROR_NOT_AVAILABLE);
125 return (priv->mod->ops.get_geocode_freetext)(priv->mod->handler, address, position_list, accuracy_list);
129 location_geocode_get_reversegeocode (LocationGeocode *self,
130 const LocationPosition *position,
131 LocationAddress **address,
132 LocationAccuracy **accuracy)
134 LOCATION_LOGD("location_geocode_get_reversegeocode");
135 LocationGeocodePrivate* priv = GET_PRIVATE(self);
136 g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
137 g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
138 g_return_val_if_fail (priv->mod->ops.get_reverse_geocode, LOCATION_ERROR_NOT_AVAILABLE);
139 return (priv->mod->ops.get_reverse_geocode)(priv->mod->handler, position, address, accuracy);
143 location_geocode_get_geocode_async (LocationGeocode *self,
144 LocationAddress *address,
145 LocationPositionCB callback,
148 LOCATION_LOGD("location_geocode_get_geocode_async");
149 LocationGeocodePrivate* priv = GET_PRIVATE(self);
150 g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
151 g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
152 g_return_val_if_fail (priv->mod->ops.get_geocode_async, LOCATION_ERROR_NOT_AVAILABLE);
153 return (priv->mod->ops.get_geocode_async)(priv->mod->handler, address, callback, userdata);
157 location_geocode_get_geocode_freeform_async (LocationGeocode *self,
158 const gchar *address,
159 LocationPositionCB callback,
162 LOCATION_LOGD("location_geocode_get_geocode_freeform_async");
163 LocationGeocodePrivate* priv = GET_PRIVATE(self);
164 g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
165 g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
166 g_return_val_if_fail (priv->mod->ops.get_geocode_freetext_async, LOCATION_ERROR_NOT_AVAILABLE);
167 return (priv->mod->ops.get_geocode_freetext_async)(priv->mod->handler, address, callback, userdata);
171 location_geocode_get_reversegeocode_async (LocationGeocode *self,
172 const LocationPosition *position,
173 LocationAddressCB callback,
176 LOCATION_LOGD("location_geocode_get_reversegeocode_async");
177 LocationGeocodePrivate* priv = GET_PRIVATE(self);
178 g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
179 g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
180 g_return_val_if_fail (priv->mod->ops.get_reverse_geocode_async, LOCATION_ERROR_NOT_AVAILABLE);
181 return (priv->mod->ops.get_reverse_geocode_async)(priv->mod->handler, position, callback, userdata);
185 location_ielement_interface_init (LocationIElementInterface *iface)
187 iface->get_geocode = (TYPE_GET_GEOCODE)location_geocode_get_geocode;
188 iface->get_geocode_freeform = (TYPE_GET_GEOCODE_FREEFORM)location_geocode_get_geocode_freeform;
189 iface->get_reversegeocode = (TYPE_GET_REVERSEGEOCODE)location_geocode_get_reversegeocode;
190 iface->get_geocode_async = (TYPE_GET_GEOCODE_ASYNC)location_geocode_get_geocode_async;
191 iface->get_geocode_freeform_async = (TYPE_GET_GEOCODE_FREEFORM_ASYNC)location_geocode_get_geocode_freeform_async;
192 iface->get_reversegeocode_async = (TYPE_GET_REVERSEGEOCODE_ASYNC)location_geocode_get_reversegeocode_async;
196 location_geocode_init (LocationGeocode *self)
198 LOCATION_LOGD("location_geocode_init");
199 LocationGeocodePrivate* priv = GET_PRIVATE(self);
201 priv->mod = (LocationGeoMod*)module_new("geocode");
202 if(!priv->mod) LOCATION_LOGW("module loading failed");
206 location_geocode_class_init (LocationGeocodeClass *klass)
208 LOCATION_LOGD("location_geocode_class_init");
209 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
212 gobject_class->get_property = location_geocode_get_property;
214 gobject_class->dispose = location_geocode_dispose;
215 gobject_class->finalize = location_geocode_finalize;
217 g_type_class_add_private (klass, sizeof (LocationGeocodePrivate));
219 pspec = g_param_spec_string ("service provider",
220 "geocode service provider name prop",
221 "geocode service provider name",
224 g_object_class_install_property (gobject_class,