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-setting.h"
27 #include "location/location-log.h"
29 #include "location/location-module-internal.h"
31 #include "location/location-ips.h"
32 #include "location/location-marshal.h"
33 #include "location/location-ielement.h"
35 typedef struct _LocationIpsPrivate {
37 LocationPosition *pos;
38 LocationAccuracy *acc;
47 #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOCATION_TYPE_IPS, LocationIpsPrivate))
49 static void location_ielement_interface_init (LocationIElementInterface *iface);
51 G_DEFINE_TYPE_WITH_CODE (LocationIps, location_ips, G_TYPE_OBJECT,
52 G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT,
53 location_ielement_interface_init));
56 location_ips_dispose (GObject *gobject)
58 LOCATION_LOGD("location_ips_dispose");
59 G_OBJECT_CLASS (location_ips_parent_class)->dispose (gobject);
63 location_ips_finalize (GObject *gobject)
65 LOCATION_LOGD("location_ips_finalize");
66 LocationIpsPrivate* priv = GET_PRIVATE(gobject);
67 module_free(priv->mod, "ips");
70 G_OBJECT_CLASS (location_ips_parent_class)->finalize (gobject);
74 location_ips_get_property (GObject *object,
79 LocationIpsPrivate *priv = GET_PRIVATE (object);
82 case PROP_METHOD_TYPE:
83 g_value_set_int(value, LOCATION_METHOD_IPS);
85 case PROP_LAST_POSITION:{
86 g_value_set_boxed (value, priv->pos);
90 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
96 location_ips_get_position (LocationIps *self,
97 LocationPosition **position,
98 LocationAccuracy **accuracy)
100 LOCATION_LOGD("location_ips_get_position");
102 LocationIpsPrivate *priv = GET_PRIVATE (self);
103 g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
104 setting_retval_if_fail(GPS_ENABLED);
105 setting_retval_if_fail(NETWORK_ENABLED);
107 LocModIpsOps ops = priv->mod->ops;
108 g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
109 g_return_val_if_fail (ops.get_position, LOCATION_ERROR_NOT_AVAILABLE);
110 int ret = ops.get_position(priv->mod->handler, position, accuracy);
111 if (priv->pos) location_position_free(priv->pos);
112 if (priv->acc) location_accuracy_free(priv->acc);
113 priv->pos = location_position_copy(*position);
114 priv->acc = location_accuracy_copy(*accuracy);
119 location_ielement_interface_init (LocationIElementInterface *iface)
121 iface->get_position = (TYPE_GET_POSITION)location_ips_get_position;
125 location_ips_init (LocationIps *self)
127 LOCATION_LOGD("location_ips_init");
128 LocationIpsPrivate* priv = GET_PRIVATE(self);
130 priv->mod = (LocationIpsMod*)module_new("ips");
131 if(!priv->mod) LOCATION_LOGW("module loading failed");
138 location_ips_class_init (LocationIpsClass *klass)
140 LOCATION_LOGD("location_ips_class_init");
141 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
144 gobject_class->get_property = location_ips_get_property;
146 gobject_class->dispose = location_ips_dispose;
147 gobject_class->finalize = location_ips_finalize;
149 g_type_class_add_private (klass, sizeof (LocationIpsPrivate));
151 pspec = g_param_spec_int ("method",
153 "location method type name",
158 g_object_class_install_property (gobject_class,
162 pspec = g_param_spec_boxed ("last-position",
163 "ips last position prop",
164 "ips last position data",
165 LOCATION_TYPE_POSITION,
167 g_object_class_install_property (gobject_class,