aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2014-02-06 11:51:03 +0100
committerAleksander Morgado <aleksander@aleksander.es>2014-09-05 11:28:10 +0200
commitcd5ca169f1a4d9de1fd6802a4c735ffec634a245 (patch)
treec476252f1b348e7555d332fb74605a6957e38f14 /libmm-glib
parentfbeee20d5b7789bd0bcd4e4ab1dce784390e5ebd (diff)
libmm-glib,location: add helpers to get/set the SUPL server address
Diffstat (limited to 'libmm-glib')
-rw-r--r--libmm-glib/mm-modem-location.c122
-rw-r--r--libmm-glib/mm-modem-location.h16
2 files changed, 138 insertions, 0 deletions
diff --git a/libmm-glib/mm-modem-location.c b/libmm-glib/mm-modem-location.c
index 7f38a658..229d604a 100644
--- a/libmm-glib/mm-modem-location.c
+++ b/libmm-glib/mm-modem-location.c
@@ -225,6 +225,87 @@ mm_modem_location_setup_sync (MMModemLocation *self,
/*****************************************************************************/
+/**
+ * mm_modem_location_set_supl_server_finish:
+ * @self: A #MMModemLocation.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_location_set_supl_server().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with mm_modem_location_set_supl_server().
+ *
+ * Returns: %TRUE if setting the SUPL server was successful, %FALSE if @error is set.
+ */
+gboolean
+mm_modem_location_set_supl_server_finish (MMModemLocation *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE);
+
+ return mm_gdbus_modem_location_call_set_supl_server_finish (MM_GDBUS_MODEM_LOCATION (self), res, error);
+}
+
+/**
+ * mm_modem_location_set_supl_server:
+ * @self: A #MMModemLocation.
+ * @supl: The SUPL server address, given as IP:PORT or with a full URL.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously configures the address of the SUPL server for A-GPS operation.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call mm_modem_location_set_supl_server_finish() to get the result of the operation.
+ *
+ * See mm_modem_location_set_supl_server_sync() for the synchronous, blocking version of this method.
+ */
+void
+mm_modem_location_set_supl_server (MMModemLocation *self,
+ const gchar *supl,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_return_if_fail (MM_IS_MODEM_LOCATION (self));
+
+ mm_gdbus_modem_location_call_set_supl_server (MM_GDBUS_MODEM_LOCATION (self),
+ supl,
+ cancellable,
+ callback,
+ user_data);
+}
+
+/**
+ * mm_modem_location_set_supl_server_sync:
+ * @self: A #MMModemLocation.
+ * @supl: The SUPL server address, given as IP:PORT or with a full URL.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously configures the address of the SUPL server for A-GPS operation.
+ *
+ * The calling thread is blocked until a reply is received. See mm_modem_location_set_supl_server()
+ * for the asynchronous version of this method.
+ *
+ * Returns: %TRUE if setting the SUPL server was successful, %FALSE if @error is set.
+ */
+gboolean
+mm_modem_location_set_supl_server_sync (MMModemLocation *self,
+ const gchar *supl,
+ GCancellable *cancellable,
+ GError **error)
+{
+ g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE);
+
+ return mm_gdbus_modem_location_call_set_supl_server_sync (MM_GDBUS_MODEM_LOCATION (self),
+ supl,
+ cancellable,
+ error);
+}
+
+/*****************************************************************************/
+
static gboolean
build_locations (GVariant *dictionary,
MMLocation3gpp **location_3gpp,
@@ -669,6 +750,47 @@ mm_modem_location_get_cdma_bs_sync (MMModemLocation *self,
/*****************************************************************************/
+/**
+ * mm_modem_location_get_supl_server:
+ * @self: A #MMModemLocation.
+ *
+ * Gets the address of the SUPL server.
+ *
+ * <warning>The returned value is only valid until the property changes so
+ * it is only safe to use this function on the thread where
+ * @self was constructed. Use mm_modem_dup_supl_server() if on another
+ * thread.</warning>
+ *
+ * Returns: (transfer none): The SUPL server address, or %NULL if none available. Do not free the returned value, it belongs to @self.
+ */
+const gchar *
+mm_modem_location_get_supl_server (MMModemLocation *self)
+{
+ g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), NULL);
+
+ RETURN_NON_EMPTY_CONSTANT_STRING (
+ mm_gdbus_modem_location_get_supl_server (MM_GDBUS_MODEM_LOCATION (self)));
+}
+
+/**
+ * mm_modem_location_dup_supl_server:
+ * @self: A #MMModemLocation.
+ *
+ * Gets the address of the SUPL server.
+ *
+ * Returns: (transfer full): The SUPL server address, or %NULL if none available. The returned value should be freed with g_free().
+ */
+gchar *
+mm_modem_location_dup_supl_server (MMModemLocation *self)
+{
+ g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), NULL);
+
+ RETURN_NON_EMPTY_STRING (
+ mm_gdbus_modem_location_dup_supl_server (MM_GDBUS_MODEM_LOCATION (self)));
+}
+
+/*****************************************************************************/
+
static void
mm_modem_location_init (MMModemLocation *self)
{
diff --git a/libmm-glib/mm-modem-location.h b/libmm-glib/mm-modem-location.h
index 5f6393da..279288d7 100644
--- a/libmm-glib/mm-modem-location.h
+++ b/libmm-glib/mm-modem-location.h
@@ -76,6 +76,9 @@ MMModemLocationSource mm_modem_location_get_enabled (MMModemLocation *self)
gboolean mm_modem_location_signals_location (MMModemLocation *self);
+const gchar *mm_modem_location_get_supl_server (MMModemLocation *self);
+gchar *mm_modem_location_dup_supl_server (MMModemLocation *self);
+
void mm_modem_location_setup (MMModemLocation *self,
MMModemLocationSource sources,
gboolean signal_location,
@@ -91,6 +94,19 @@ gboolean mm_modem_location_setup_sync (MMModemLocation *self,
GCancellable *cancellable,
GError **error);
+void mm_modem_location_set_supl_server (MMModemLocation *self,
+ const gchar *supl,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean mm_modem_location_set_supl_server_finish (MMModemLocation *self,
+ GAsyncResult *res,
+ GError **error);
+gboolean mm_modem_location_set_supl_server_sync (MMModemLocation *self,
+ const gchar *supl,
+ GCancellable *cancellable,
+ GError **error);
+
void mm_modem_location_get_3gpp (MMModemLocation *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,