summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>2014-06-26 22:00:27 +0100
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>2014-06-27 19:09:18 +0100
commit7bdce141ce083c0296ec82ec0407dd0c39cf5e0b (patch)
tree00cd7f9316e3ecdf9b3c03c8fae34ee85e0b47ee
parent30291530360d37999fb44bd8aa9a77f802ed8fce (diff)
Add CDMA location support
-rw-r--r--configure.ac15
-rw-r--r--src/Makefile.am4
-rw-r--r--src/gclue-cdma.c261
-rw-r--r--src/gclue-cdma.h69
-rw-r--r--src/gclue-locator.c8
-rw-r--r--src/gclue-marshal.list1
-rw-r--r--src/gclue-modem-manager.c140
-rw-r--r--src/gclue-modem.c67
-rw-r--r--src/gclue-modem.h110
9 files changed, 625 insertions, 50 deletions
diff --git a/configure.ac b/configure.ac
index 6ba927e..b417b77 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,18 @@ else
fi
AM_CONDITIONAL([BUILD_3G_SOURCE], [test "$build_3g_source" = "yes"])
+# CDMA source
+AC_ARG_ENABLE(cdma-source,
+ AS_HELP_STRING([--disable-cdma-source], [Disable CDMA backend (requires ModemManager)]),
+ [build_cdma_source=$enableval], [build_cdma_source=yes])
+if test "$build_cdma_source" = "yes"; then
+ build_modem_source=yes
+ AC_DEFINE([GCLUE_USE_CDMA_SOURCE], [1], [Build CDMA source?])
+else
+ AC_DEFINE([GCLUE_USE_CDMA_SOURCE], [0], [Build CDMA source?])
+fi
+AM_CONDITIONAL([BUILD_CDMA_SOURCE], [test "$build_cdma_source" = "yes"])
+
# GPS source
AC_ARG_ENABLE(modem-gps-source,
AS_HELP_STRING([--disable-modem-gps-source], [Disable modem GPS backend (requires ModemManager)]),
@@ -81,7 +93,7 @@ else
fi
AM_CONDITIONAL([BUILD_MODEM_GPS_SOURCE], [test "$build_modem_gps_source" = "yes"])
-# Modem source is used in common by GPS and 3G sources
+# Modem source is used in common by GPS, 3G and CDMA sources
if test "$build_modem_source" = "yes"; then
require_modemmanager=yes
fi
@@ -194,5 +206,6 @@ AC_MSG_NOTICE([
systemdsystemunitdir: ${systemdsystemunitdir}
3G source: ${build_3g_source}
+ CDMA source: ${build_cdma_source}
Modem GPS source: ${build_modem_gps_source}
])
diff --git a/src/Makefile.am b/src/Makefile.am
index f542d8f..bb9ad39 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -105,6 +105,10 @@ if BUILD_3G_SOURCE
libgeoclue_la_SOURCES += gclue-3g.c gclue-3g.h
endif
+if BUILD_CDMA_SOURCE
+libgeoclue_la_SOURCES += gclue-cdma.c gclue-cdma.h
+endif
+
if BUILD_MODEM_GPS_SOURCE
libgeoclue_la_SOURCES += gclue-modem-gps.c gclue-modem-gps.h
endif
diff --git a/src/gclue-cdma.c b/src/gclue-cdma.c
new file mode 100644
index 0000000..c1caada
--- /dev/null
+++ b/src/gclue-cdma.c
@@ -0,0 +1,261 @@
+/* vim: set et ts=8 sw=8: */
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * Geoclue is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * Geoclue is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with Geoclue; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
+ */
+
+#include <stdlib.h>
+#include <glib.h>
+#include <string.h>
+#include "gclue-cdma.h"
+#include "gclue-modem-manager.h"
+#include "geocode-glib/geocode-location.h"
+
+/**
+ * SECTION:gclue-cdma
+ * @short_description: WiFi-based geolocation
+ * @include: gclue-glib/gclue-cdma.h
+ *
+ * Contains functions to get the geolocation from a CDMA cell tower.
+ **/
+
+struct _GClueCDMAPrivate {
+ GClueModem *modem;
+
+ GCancellable *cancellable;
+
+ gulong cdma_notify_id;
+};
+
+
+G_DEFINE_TYPE (GClueCDMA, gclue_cdma, GCLUE_TYPE_LOCATION_SOURCE)
+
+static gboolean
+gclue_cdma_start (GClueLocationSource *source);
+static gboolean
+gclue_cdma_stop (GClueLocationSource *source);
+
+static void
+refresh_accuracy_level (GClueCDMA *source)
+{
+ GClueAccuracyLevel new, existing;
+
+ existing = gclue_location_source_get_available_accuracy_level
+ (GCLUE_LOCATION_SOURCE (source));
+
+ if (gclue_modem_get_is_cdma_available (source->priv->modem))
+ new = GCLUE_ACCURACY_LEVEL_NEIGHBORHOOD;
+ else
+ new = GCLUE_ACCURACY_LEVEL_NONE;
+
+ if (new != existing) {
+ g_debug ("Available accuracy level from %s: %u",
+ G_OBJECT_TYPE_NAME (source), new);
+ g_object_set (G_OBJECT (source),
+ "available-accuracy-level", new,
+ NULL);
+ }
+}
+
+static void
+on_cdma_enabled (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GClueCDMA *source = GCLUE_CDMA (user_data);
+ GError *error = NULL;
+
+ if (!gclue_modem_enable_cdma_finish (source->priv->modem,
+ result,
+ &error)) {
+ g_warning ("Failed to enable CDMA: %s", error->message);
+ g_error_free (error);
+ }
+}
+
+static void
+on_is_cdma_available_notify (GObject *gobject,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ GClueCDMA *source = GCLUE_CDMA (user_data);
+ GClueCDMAPrivate *priv = source->priv;
+
+ refresh_accuracy_level (source);
+
+ if (gclue_location_source_get_active (GCLUE_LOCATION_SOURCE (source)) &&
+ gclue_modem_get_is_cdma_available (priv->modem))
+ gclue_modem_enable_cdma (priv->modem,
+ priv->cancellable,
+ on_cdma_enabled,
+ source);
+}
+
+static void
+gclue_cdma_finalize (GObject *gcdma)
+{
+ GClueCDMAPrivate *priv = GCLUE_CDMA (gcdma)->priv;
+
+ G_OBJECT_CLASS (gclue_cdma_parent_class)->finalize (gcdma);
+
+ g_signal_handler_disconnect (priv->modem,
+ priv->cdma_notify_id);
+ priv->cdma_notify_id = 0;
+
+ g_cancellable_cancel (priv->cancellable);
+ g_clear_object (&priv->cancellable);
+ g_clear_object (&priv->modem);
+}
+
+static void
+gclue_cdma_class_init (GClueCDMAClass *klass)
+{
+ GClueLocationSourceClass *source_class = GCLUE_LOCATION_SOURCE_CLASS (klass);
+ GObjectClass *gcdma_class = G_OBJECT_CLASS (klass);
+
+ gcdma_class->finalize = gclue_cdma_finalize;
+
+ source_class->start = gclue_cdma_start;
+ source_class->stop = gclue_cdma_stop;
+
+ g_type_class_add_private (klass, sizeof (GClueCDMAPrivate));
+}
+
+static void
+gclue_cdma_init (GClueCDMA *source)
+{
+ GClueCDMAPrivate *priv;
+
+ source->priv = G_TYPE_INSTANCE_GET_PRIVATE ((source), GCLUE_TYPE_CDMA, GClueCDMAPrivate);
+ priv = source->priv;
+
+ priv->cancellable = g_cancellable_new ();
+
+ priv->modem = gclue_modem_manager_get_singleton ();
+ priv->cdma_notify_id =
+ g_signal_connect (priv->modem,
+ "notify::is-cdma-available",
+ G_CALLBACK (on_is_cdma_available_notify),
+ source);
+}
+
+static void
+on_cdma_destroyed (gpointer data,
+ GObject *where_the_object_was)
+{
+ GClueCDMA **source = (GClueCDMA **) data;
+
+ *source = NULL;
+}
+
+/**
+ * gclue_cdma_get_singleton:
+ *
+ * Get the #GClueCDMA singleton.
+ *
+ * Returns: (transfer full): a new ref to #GClueCDMA. Use g_object_unref()
+ * when done.
+ **/
+GClueCDMA *
+gclue_cdma_get_singleton (void)
+{
+ static GClueCDMA *source = NULL;
+
+ if (source == NULL) {
+ source = g_object_new (GCLUE_TYPE_CDMA, NULL);
+ g_object_weak_ref (G_OBJECT (source),
+ on_cdma_destroyed,
+ &source);
+ } else
+ g_object_ref (source);
+
+ return source;
+}
+
+static void
+on_fix_cdma (GClueModem *modem,
+ gdouble latitude,
+ gdouble longitude,
+ gpointer user_data)
+{
+ GeocodeLocation *location;
+
+ location = geocode_location_new (latitude,
+ longitude,
+ 1000); /* Assume 1 km accuracy */
+
+ gclue_location_source_set_location (GCLUE_LOCATION_SOURCE (user_data),
+ location);
+ g_object_unref (location);
+}
+
+static gboolean
+gclue_cdma_start (GClueLocationSource *source)
+{
+ GClueLocationSourceClass *base_class;
+ GClueCDMAPrivate *priv;
+
+ g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), FALSE);
+ priv = GCLUE_CDMA (source)->priv;
+
+ base_class = GCLUE_LOCATION_SOURCE_CLASS (gclue_cdma_parent_class);
+ if (!base_class->start (source))
+ return FALSE;
+
+ g_signal_connect (priv->modem,
+ "fix-cdma",
+ G_CALLBACK (on_fix_cdma),
+ source);
+
+ if (gclue_modem_get_is_cdma_available (priv->modem))
+ gclue_modem_enable_cdma (priv->modem,
+ priv->cancellable,
+ on_cdma_enabled,
+ source);
+
+ return TRUE;
+}
+
+static gboolean
+gclue_cdma_stop (GClueLocationSource *source)
+{
+ GClueCDMAPrivate *priv = GCLUE_CDMA (source)->priv;
+ GClueLocationSourceClass *base_class;
+ GError *error = NULL;
+
+ g_return_val_if_fail (GCLUE_IS_LOCATION_SOURCE (source), FALSE);
+
+ base_class = GCLUE_LOCATION_SOURCE_CLASS (gclue_cdma_parent_class);
+ if (!base_class->stop (source))
+ return FALSE;
+
+ g_signal_handlers_disconnect_by_func (G_OBJECT (priv->modem),
+ G_CALLBACK (on_fix_cdma),
+ source);
+
+ if (gclue_modem_get_is_cdma_available (priv->modem))
+ if (!gclue_modem_disable_cdma (priv->modem,
+ priv->cancellable,
+ &error)) {
+ g_warning ("Failed to disable CDMA: %s",
+ error->message);
+ g_error_free (error);
+ }
+
+ return TRUE;
+}
diff --git a/src/gclue-cdma.h b/src/gclue-cdma.h
new file mode 100644
index 0000000..b05f087
--- /dev/null
+++ b/src/gclue-cdma.h
@@ -0,0 +1,69 @@
+/* vim: set et ts=8 sw=8: */
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * Geoclue is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * Geoclue is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with Geoclue; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
+ */
+
+#ifndef GCLUE_CDMA_H
+#define GCLUE_CDMA_H
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "gclue-location-source.h"
+
+G_BEGIN_DECLS
+
+GType gclue_cdma_get_type (void) G_GNUC_CONST;
+
+#define GCLUE_TYPE_CDMA (gclue_cdma_get_type ())
+#define GCLUE_CDMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCLUE_TYPE_CDMA, GClueCDMA))
+#define GCLUE_IS_CDMA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCLUE_TYPE_CDMA))
+#define GCLUE_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCLUE_TYPE_CDMA, GClueCDMAClass))
+#define GCLUE_IS_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCLUE_TYPE_CDMA))
+#define GCLUE_CDMA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCLUE_TYPE_CDMA, GClueCDMAClass))
+
+/**
+ * GClueCDMA:
+ *
+ * All the fields in the #GClueCDMA structure are private and should never be accessed directly.
+**/
+typedef struct _GClueCDMA GClueCDMA;
+typedef struct _GClueCDMAClass GClueCDMAClass;
+typedef struct _GClueCDMAPrivate GClueCDMAPrivate;
+
+struct _GClueCDMA {
+ /* <private> */
+ GClueLocationSource parent_instance;
+ GClueCDMAPrivate *priv;
+};
+
+/**
+ * GClueCDMAClass:
+ *
+ * All the fields in the #GClueCDMAClass structure are private and should never be accessed directly.
+**/
+struct _GClueCDMAClass {
+ /* <private> */
+ GClueLocationSourceClass parent_class;
+};
+
+GClueCDMA * gclue_cdma_get_singleton (void);
+
+G_END_DECLS
+
+#endif /* GCLUE_CDMA_H */
diff --git a/src/gclue-locator.c b/src/gclue-locator.c
index f69cd2d..910f035 100644
--- a/src/gclue-locator.c
+++ b/src/gclue-locator.c
@@ -33,6 +33,10 @@
#include "gclue-3g.h"
#endif
+#if GCLUE_USE_CDMA_SOURCE
+#include "gclue-cdma.h"
+#endif
+
#if GCLUE_USE_MODEM_GPS_SOURCE
#include "gclue-modem-gps.h"
#endif
@@ -266,6 +270,10 @@ gclue_locator_constructed (GObject *object)
GClue3G *source = gclue_3g_get_singleton ();
locator->priv->sources = g_list_append (locator->priv->sources, source);
#endif
+#if GCLUE_USE_CDMA_SOURCE
+ GClueCDMA *cdma = gclue_cdma_get_singleton ();
+ locator->priv->sources = g_list_append (locator->priv->sources, cdma);
+#endif
if (locator->priv->accuracy_level >= GCLUE_ACCURACY_LEVEL_CITY) {
GClueWifi *wifi = gclue_wifi_get_singleton
(locator->priv->accuracy_level);
diff --git a/src/gclue-marshal.list b/src/gclue-marshal.list
index 586dfa2..06068f0 100644
--- a/src/gclue-marshal.list
+++ b/src/gclue-marshal.list
@@ -1 +1,2 @@
VOID:UINT,UINT,ULONG,ULONG
+VOID:DOUBLE,DOUBLE
diff --git a/src/gclue-modem-manager.c b/src/gclue-modem-manager.c
index 57c461b..cce3065 100644
--- a/src/gclue-modem-manager.c
+++ b/src/gclue-modem-manager.c
@@ -57,6 +57,7 @@ enum
{
PROP_0,
PROP_IS_3G_AVAILABLE,
+ PROP_IS_CDMA_AVAILABLE,
PROP_IS_GPS_AVAILABLE,
LAST_PROP
};
@@ -65,6 +66,7 @@ static GParamSpec *gParamSpecs[LAST_PROP];
enum {
FIX_3G,
+ FIX_CDMA,
FIX_GPS,
SIGNAL_LAST
};
@@ -74,6 +76,8 @@ static guint signals[SIGNAL_LAST];
static gboolean
gclue_modem_manager_get_is_3g_available (GClueModem *modem);
static gboolean
+gclue_modem_manager_get_is_cdma_available (GClueModem *modem);
+static gboolean
gclue_modem_manager_get_is_gps_available (GClueModem *modem);
static void
gclue_modem_manager_enable_3g (GClueModem *modem,
@@ -85,6 +89,15 @@ gclue_modem_manager_enable_3g_finish (GClueModem *modem,
GAsyncResult *result,
GError **error);
static void
+gclue_modem_manager_enable_cdma (GClueModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+static gboolean
+gclue_modem_manager_enable_cdma_finish (GClueModem *modem,
+ GAsyncResult *result,
+ GError **error);
+static void
gclue_modem_manager_enable_gps (GClueModem *modem,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -98,6 +111,10 @@ gclue_modem_manager_disable_3g (GClueModem *modem,
GCancellable *cancellable,
GError **error);
static gboolean
+gclue_modem_manager_disable_cdma (GClueModem *modem,
+ GCancellable *cancellable,
+ GError **error);
+static gboolean
gclue_modem_manager_disable_gps (GClueModem *modem,
GCancellable *cancellable,
GError **error);
@@ -132,6 +149,11 @@ gclue_modem_manager_get_property (GObject *object,
gclue_modem_get_is_3g_available (modem));
break;
+ case PROP_IS_CDMA_AVAILABLE:
+ g_value_set_boolean (value,
+ gclue_modem_get_is_cdma_available (modem));
+ break;
+
case PROP_IS_GPS_AVAILABLE:
g_value_set_boolean (value,
gclue_modem_get_is_gps_available (modem));
@@ -163,6 +185,12 @@ gclue_modem_manager_class_init (GClueModemManagerClass *klass)
g_object_class_find_property (gmodem_class,
"is-3g-available");
g_object_class_override_property (gmodem_class,
+ PROP_IS_CDMA_AVAILABLE,
+ "is-cdma-available");
+ gParamSpecs[PROP_IS_CDMA_AVAILABLE] =
+ g_object_class_find_property (gmodem_class,
+ "is-cdma-available");
+ g_object_class_override_property (gmodem_class,
PROP_IS_GPS_AVAILABLE,
"is-gps-available");
gParamSpecs[PROP_IS_GPS_AVAILABLE] =
@@ -170,6 +198,7 @@ gclue_modem_manager_class_init (GClueModemManagerClass *klass)
"is-gps-available");
signals[FIX_3G] = g_signal_lookup ("fix-3g", GCLUE_TYPE_MODEM);
+ signals[FIX_CDMA] = g_signal_lookup ("fix-cdma", GCLUE_TYPE_MODEM);
signals[FIX_GPS] = g_signal_lookup ("fix-gps", GCLUE_TYPE_MODEM);
}
@@ -177,12 +206,16 @@ static void
gclue_modem_interface_init (GClueModemInterface *iface)
{
iface->get_is_3g_available = gclue_modem_manager_get_is_3g_available;
+ iface->get_is_cdma_available = gclue_modem_manager_get_is_cdma_available;
iface->get_is_gps_available = gclue_modem_manager_get_is_gps_available;
iface->enable_3g = gclue_modem_manager_enable_3g;
iface->enable_3g_finish = gclue_modem_manager_enable_3g_finish;
+ iface->enable_cdma = gclue_modem_manager_enable_cdma;
+ iface->enable_cdma_finish = gclue_modem_manager_enable_cdma_finish;
iface->enable_gps = gclue_modem_manager_enable_gps;
iface->enable_gps_finish = gclue_modem_manager_enable_gps_finish;
iface->disable_3g = gclue_modem_manager_disable_3g;
+ iface->disable_cdma = gclue_modem_manager_disable_cdma;
iface->disable_gps = gclue_modem_manager_disable_gps;
}
@@ -255,6 +288,38 @@ on_get_3gpp_ready (GObject *source_object,
}
static void
+on_get_cdma_ready (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GClueModemManager *manager = GCLUE_MODEM_MANAGER (user_data);
+ MMModemLocation *modem_location = MM_MODEM_LOCATION (source_object);
+ MMLocationCdmaBs *location_cdma;
+ GError *error = NULL;
+
+ location_cdma = mm_modem_location_get_cdma_bs_finish (modem_location,
+ res,
+ &error);
+ if (error != NULL) {
+ g_warning ("Failed to get location from 3GPP: %s",
+ error->message);
+ g_error_free (error);
+ return;
+ }
+
+ if (location_cdma == NULL) {
+ g_debug ("No CDMA");
+ return;
+ }
+
+ g_signal_emit (manager,
+ signals[FIX_CDMA],
+ 0,
+ mm_location_cdma_bs_get_latitude (location_cdma),
+ mm_location_cdma_bs_get_longitude (location_cdma));
+}
+
+static void
on_get_gps_nmea_ready (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
@@ -299,10 +364,16 @@ on_location_changed (GObject *modem_object,
MMModemLocation *modem_location = MM_MODEM_LOCATION (modem_object);
GClueModemManager *manager = GCLUE_MODEM_MANAGER (user_data);
- mm_modem_location_get_3gpp (modem_location,
- manager->priv->cancellable,
- on_get_3gpp_ready,
- manager);
+ if ((manager->priv->caps & MM_MODEM_LOCATION_SOURCE_3GPP_LAC_CI) != 0)
+ mm_modem_location_get_3gpp (modem_location,
+ manager->priv->cancellable,
+ on_get_3gpp_ready,
+ manager);
+ if ((manager->priv->caps & MM_MODEM_LOCATION_SOURCE_CDMA_BS) != 0)
+ mm_modem_location_get_cdma_bs (modem_location,
+ manager->priv->cancellable,
+ on_get_cdma_ready,
+ manager);
if ((manager->priv->caps & MM_MODEM_LOCATION_SOURCE_GPS_NMEA) != 0)
mm_modem_location_get_gps_nmea (modem_location,
manager->priv->cancellable,
@@ -467,6 +538,7 @@ on_mm_object_added (GDBusObjectManager *object_manager,
manager);
g_object_notify_by_pspec (G_OBJECT (manager), gParamSpecs[PROP_IS_3G_AVAILABLE]);
+ g_object_notify_by_pspec (G_OBJECT (manager), gParamSpecs[PROP_IS_CDMA_AVAILABLE]);
g_object_notify_by_pspec (G_OBJECT (manager), gParamSpecs[PROP_IS_GPS_AVAILABLE]);
}
@@ -491,6 +563,7 @@ on_mm_object_removed (GDBusObjectManager *object_manager,
g_clear_object (&priv->modem_location);
g_object_notify_by_pspec (G_OBJECT (manager), gParamSpecs[PROP_IS_3G_AVAILABLE]);
+ g_object_notify_by_pspec (G_OBJECT (manager), gParamSpecs[PROP_IS_CDMA_AVAILABLE]);
g_object_notify_by_pspec (G_OBJECT (manager), gParamSpecs[PROP_IS_GPS_AVAILABLE]);
}
@@ -622,7 +695,16 @@ gclue_modem_manager_get_is_3g_available (GClueModem *modem)
g_return_val_if_fail (GCLUE_IS_MODEM_MANAGER (modem), FALSE);
return modem_has_caps (GCLUE_MODEM_MANAGER (modem),
- MM_MODEM_LOCATION_SOURCE_3GPP_LAC_CI);
+ MM_MODEM_LOCATION_SOURCE_3GPP_LAC_CI);
+}
+
+static gboolean
+gclue_modem_manager_get_is_cdma_available (GClueModem *modem)
+{
+ g_return_val_if_fail (GCLUE_IS_MODEM_MANAGER (modem), FALSE);
+
+ return modem_has_caps (GCLUE_MODEM_MANAGER (modem),
+ MM_MODEM_LOCATION_SOURCE_CDMA_BS);
}
static gboolean
@@ -663,6 +745,34 @@ gclue_modem_manager_enable_3g_finish (GClueModem *modem,
}
static void
+gclue_modem_manager_enable_cdma (GClueModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_return_if_fail (GCLUE_IS_MODEM_MANAGER (modem));
+ g_return_if_fail (gclue_modem_manager_get_is_cdma_available (modem));
+
+ enable_caps (GCLUE_MODEM_MANAGER (modem),
+ MM_MODEM_LOCATION_SOURCE_CDMA_BS,
+ cancellable,
+ callback,
+ user_data);
+}
+
+static gboolean
+gclue_modem_manager_enable_cdma_finish (GClueModem *modem,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (GCLUE_IS_MODEM_MANAGER (modem), FALSE);
+
+ return enable_caps_finish (GCLUE_MODEM_MANAGER (modem),
+ result,
+ error);
+}
+
+static void
gclue_modem_manager_enable_gps (GClueModem *modem,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -710,6 +820,26 @@ gclue_modem_manager_disable_3g (GClueModem *modem,
}
static gboolean
+gclue_modem_manager_disable_cdma (GClueModem *modem,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GClueModemManager *manager;
+
+ g_return_val_if_fail (GCLUE_IS_MODEM_MANAGER (modem), FALSE);
+ g_return_val_if_fail (gclue_modem_manager_get_is_cdma_available (modem), FALSE);
+ manager = GCLUE_MODEM_MANAGER (modem);
+
+ g_clear_object (&manager->priv->location_3gpp);
+ g_debug ("Clearing CDMA location caps from modem");
+ return clear_caps (manager,
+ MM_MODEM_LOCATION_SOURCE_CDMA_BS,
+ cancellable,
+ error);
+}
+
+
+static gboolean
gclue_modem_manager_disable_gps (GClueModem *modem,
GCancellable *cancellable,
GError **error)
diff --git a/src/gclue-modem.c b/src/gclue-modem.c
index 2dcee0a..dd5516f 100644
--- a/src/gclue-modem.c
+++ b/src/gclue-modem.c
@@ -49,6 +49,13 @@ gclue_modem_default_init (GClueModemInterface *iface)
G_PARAM_READABLE);
g_object_interface_install_property (iface, spec);
+ spec = g_param_spec_boolean ("is-cdma-available",
+ "IsCDMAAvailable",
+ "Is CDMA Available?",
+ FALSE,
+ G_PARAM_READABLE);
+ g_object_interface_install_property (iface, spec);
+
spec = g_param_spec_boolean ("is-gps-available",
"IsGPSAvailable",
"Is GPS Available?",
@@ -70,6 +77,18 @@ gclue_modem_default_init (GClueModemInterface *iface)
G_TYPE_ULONG,
G_TYPE_ULONG);
+ g_signal_new ("fix-cdma",
+ GCLUE_TYPE_MODEM,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ gclue_marshal_VOID__DOUBLE_DOUBLE,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_DOUBLE,
+ G_TYPE_DOUBLE);
+
g_signal_new ("fix-gps",
GCLUE_TYPE_MODEM,
G_SIGNAL_RUN_LAST,
@@ -91,6 +110,14 @@ gclue_modem_get_is_3g_available (GClueModem *modem)
}
gboolean
+gclue_modem_get_is_cdma_available (GClueModem *modem)
+{
+ g_return_val_if_fail (GCLUE_IS_MODEM (modem), FALSE);
+
+ return GCLUE_MODEM_GET_INTERFACE (modem)->get_is_cdma_available (modem);
+}
+
+gboolean
gclue_modem_get_is_gps_available (GClueModem *modem)
{
g_return_val_if_fail (GCLUE_IS_MODEM (modem), FALSE);
@@ -126,6 +153,33 @@ gclue_modem_enable_3g_finish (GClueModem *modem,
}
void
+gclue_modem_enable_cdma (GClueModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_return_if_fail (GCLUE_IS_MODEM (modem));
+ g_return_if_fail (gclue_modem_get_is_cdma_available (modem));
+
+ GCLUE_MODEM_GET_INTERFACE (modem)->enable_cdma (modem,
+ cancellable,
+ callback,
+ user_data);
+}
+
+gboolean
+gclue_modem_enable_cdma_finish (GClueModem *modem,
+ GAsyncResult *result,
+ GError **error)
+{
+ g_return_val_if_fail (GCLUE_IS_MODEM (modem), FALSE);
+
+ return GCLUE_MODEM_GET_INTERFACE (modem)->enable_cdma_finish (modem,
+ result,
+ error);
+}
+
+void
gclue_modem_enable_gps (GClueModem *modem,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -166,6 +220,19 @@ gclue_modem_disable_3g (GClueModem *modem,
}
gboolean
+gclue_modem_disable_cdma (GClueModem *modem,
+ GCancellable *cancellable,
+ GError **error)
+{
+ g_return_val_if_fail (GCLUE_IS_MODEM (modem), FALSE);
+ g_return_val_if_fail (gclue_modem_get_is_cdma_available (modem), FALSE);
+
+ return GCLUE_MODEM_GET_INTERFACE (modem)->disable_cdma (modem,
+ cancellable,
+ error);
+}
+
+gboolean
gclue_modem_disable_gps (GClueModem *modem,
GCancellable *cancellable,
GError **error)
diff --git a/src/gclue-modem.h b/src/gclue-modem.h
index 4a03c30..efcef98 100644
--- a/src/gclue-modem.h
+++ b/src/gclue-modem.h
@@ -40,52 +40,74 @@ struct _GClueModemInterface {
/* <private> */
GTypeInterface parent_iface;
- gboolean (*get_is_3g_available) (GClueModem *modem);
- gboolean (*get_is_gps_available) (GClueModem *modem);
- void (*enable_3g) (GClueModem *modem,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*enable_3g_finish) (GClueModem *modem,
- GAsyncResult *result,
- GError **error);
- void (*enable_gps) (GClueModem *modem,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
- gboolean (*enable_gps_finish) (GClueModem *modem,
- GAsyncResult *result,
- GError **error);
- gboolean (*disable_3g) (GClueModem *modem,
- GCancellable *cancellable,
- GError **error);
- gboolean (*disable_gps) (GClueModem *modem,
- GCancellable *cancellable,
- GError **error);
+ gboolean (*get_is_3g_available) (GClueModem *modem);
+ gboolean (*get_is_cdma_available) (GClueModem *modem);
+ gboolean (*get_is_gps_available) (GClueModem *modem);
+ void (*enable_3g) (GClueModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*enable_3g_finish) (GClueModem *modem,
+ GAsyncResult *result,
+ GError **error);
+ void (*enable_cdma) (GClueModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*enable_cdma_finish) (GClueModem *modem,
+ GAsyncResult *result,
+ GError **error);
+ void (*enable_gps) (GClueModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+ gboolean (*enable_gps_finish) (GClueModem *modem,
+ GAsyncResult *result,
+ GError **error);
+ gboolean (*disable_3g) (GClueModem *modem,
+ GCancellable *cancellable,
+ GError **error);
+ gboolean (*disable_cdma) (GClueModem *modem,
+ GCancellable *cancellable,
+ GError **error);
+ gboolean (*disable_gps) (GClueModem *modem,
+ GCancellable *cancellable,
+ GError **error);
};
-gboolean gclue_modem_get_is_3g_available (GClueModem *modem);
-gboolean gclue_modem_get_is_gps_available (GClueModem *modem);
-void gclue_modem_enable_3g (GClueModem *modem,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean gclue_modem_enable_3g_finish (GClueModem *modem,
- GAsyncResult *result,
- GError **error);
-void gclue_modem_enable_gps (GClueModem *modem,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean gclue_modem_enable_gps_finish (GClueModem *modem,
- GAsyncResult *result,
- GError **error);
-gboolean gclue_modem_disable_3g (GClueModem *modem,
- GCancellable *cancellable,
- GError **error);
-gboolean gclue_modem_disable_gps (GClueModem *modem,
- GCancellable *cancellable,
- GError **error);
+gboolean gclue_modem_get_is_3g_available (GClueModem *modem);
+gboolean gclue_modem_get_is_cdma_available (GClueModem *modem);
+gboolean gclue_modem_get_is_gps_available (GClueModem *modem);
+void gclue_modem_enable_3g (GClueModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean gclue_modem_enable_3g_finish (GClueModem *modem,
+ GAsyncResult *result,
+ GError **error);
+void gclue_modem_enable_cdma (GClueModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean gclue_modem_enable_cdma_finish (GClueModem *modem,
+ GAsyncResult *result,
+ GError **error);
+void gclue_modem_enable_gps (GClueModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean gclue_modem_enable_gps_finish (GClueModem *modem,
+ GAsyncResult *result,
+ GError **error);
+gboolean gclue_modem_disable_3g (GClueModem *modem,
+ GCancellable *cancellable,
+ GError **error);
+gboolean gclue_modem_disable_cdma (GClueModem *modem,
+ GCancellable *cancellable,
+ GError **error);
+gboolean gclue_modem_disable_gps (GClueModem *modem,
+ GCancellable *cancellable,
+ GError **error);
G_END_DECLS