|
Packit |
d14447 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
Packit |
d14447 |
/*
|
|
Packit |
d14447 |
* libmm -- Access modem status & information from glib applications
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
d14447 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
d14447 |
* License as published by the Free Software Foundation; either
|
|
Packit |
d14447 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
d14447 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
d14447 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
d14447 |
* Lesser General Public License for more details.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
d14447 |
* License along with this library; if not, write to the
|
|
Packit |
d14447 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Packit |
d14447 |
* Boston, MA 02110-1301 USA.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Copyright (C) 2011 - 2012 Aleksander Morgado <aleksander@gnu.org>
|
|
Packit |
d14447 |
* Copyright (C) 2012 Google, Inc.
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
#include <gio/gio.h>
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
#include "mm-helpers.h"
|
|
Packit |
d14447 |
#include "mm-errors-types.h"
|
|
Packit |
d14447 |
#include "mm-modem-simple.h"
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* SECTION: mm-modem-simple
|
|
Packit |
d14447 |
* @title: MMModemSimple
|
|
Packit |
d14447 |
* @short_description: The Simple interface
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* The #MMModemSimple is an object providing access to the methods, signals and
|
|
Packit |
d14447 |
* properties of the Simple interface.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* The Simple interface is exposed on modems which are not in %MM_MODEM_STATE_FAILED state.
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
G_DEFINE_TYPE (MMModemSimple, mm_modem_simple, MM_GDBUS_TYPE_MODEM_SIMPLE_PROXY)
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/*****************************************************************************/
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* mm_modem_simple_get_path:
|
|
Packit |
d14447 |
* @self: A #MMModemSimple.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Gets the DBus path of the #MMObject which implements this interface.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Returns: (transfer none): The DBus path of the #MMObject object.
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
const gchar *
|
|
Packit |
d14447 |
mm_modem_simple_get_path (MMModemSimple *self)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
RETURN_NON_EMPTY_CONSTANT_STRING (
|
|
Packit |
d14447 |
g_dbus_proxy_get_object_path (G_DBUS_PROXY (self)));
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* mm_modem_simple_dup_path:
|
|
Packit |
d14447 |
* @self: A #MMModemSimple.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Gets a copy of the DBus path of the #MMObject object which implements this interface.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Returns: (transfer full): The DBus path of the #MMObject. The returned value should be freed with g_free().
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
gchar *
|
|
Packit |
d14447 |
mm_modem_simple_dup_path (MMModemSimple *self)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
gchar *value;
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
g_object_get (G_OBJECT (self),
|
|
Packit |
d14447 |
"g-object-path", &value,
|
|
Packit |
d14447 |
NULL);
|
|
Packit |
d14447 |
RETURN_NON_EMPTY_STRING (value);
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/*****************************************************************************/
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* mm_modem_simple_connect_finish:
|
|
Packit |
d14447 |
* @self: A #MMModemSimple.
|
|
Packit |
d14447 |
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_simple_connect().
|
|
Packit |
d14447 |
* @error: Return location for error or %NULL.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Finishes an operation started with mm_modem_simple_connect().
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Returns: (transfer full): A #MMBearer, or %FALSE if @error is set. The returned value must be freed with g_object_ref().
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
MMBearer *
|
|
Packit |
d14447 |
mm_modem_simple_connect_finish (MMModemSimple *self,
|
|
Packit |
d14447 |
GAsyncResult *res,
|
|
Packit |
d14447 |
GError **error)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
return g_task_propagate_pointer (G_TASK (res), error);
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
static void
|
|
Packit |
d14447 |
new_bearer_ready (GDBusConnection *connection,
|
|
Packit |
d14447 |
GAsyncResult *res,
|
|
Packit |
d14447 |
GTask *task)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
GError *error = NULL;
|
|
Packit |
d14447 |
GObject *bearer;
|
|
Packit |
d14447 |
GObject *source_object;
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
source_object = g_async_result_get_source_object (res);
|
|
Packit |
d14447 |
bearer = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error);
|
|
Packit |
d14447 |
g_object_unref (source_object);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
if (error)
|
|
Packit |
d14447 |
g_task_return_error (task, error);
|
|
Packit |
d14447 |
else
|
|
Packit |
d14447 |
g_task_return_pointer (task, bearer, g_object_unref);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
g_object_unref (task);
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
static void
|
|
Packit |
d14447 |
simple_connect_ready (MMModemSimple *self,
|
|
Packit |
d14447 |
GAsyncResult *res,
|
|
Packit |
d14447 |
GTask *task)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
GError *error = NULL;
|
|
Packit |
d14447 |
gchar *bearer_path = NULL;
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
if (!mm_gdbus_modem_simple_call_connect_finish (MM_GDBUS_MODEM_SIMPLE (self),
|
|
Packit |
d14447 |
&bearer_path,
|
|
Packit |
d14447 |
res,
|
|
Packit |
d14447 |
&error)) {
|
|
Packit |
d14447 |
g_task_return_error (task, error);
|
|
Packit |
d14447 |
g_object_unref (task);
|
|
Packit |
d14447 |
return;
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
g_async_initable_new_async (MM_TYPE_BEARER,
|
|
Packit |
d14447 |
G_PRIORITY_DEFAULT,
|
|
Packit |
d14447 |
g_task_get_cancellable (task),
|
|
Packit |
d14447 |
(GAsyncReadyCallback)new_bearer_ready,
|
|
Packit |
d14447 |
task,
|
|
Packit |
d14447 |
"g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
|
Packit |
d14447 |
"g-name", MM_DBUS_SERVICE,
|
|
Packit |
d14447 |
"g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)),
|
|
Packit |
d14447 |
"g-object-path", bearer_path,
|
|
Packit |
d14447 |
"g-interface-name", "org.freedesktop.ModemManager1.Bearer",
|
|
Packit |
d14447 |
NULL);
|
|
Packit |
d14447 |
g_free (bearer_path);
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* mm_modem_simple_connect:
|
|
Packit |
d14447 |
* @self: A #MMModemSimple.
|
|
Packit |
d14447 |
* @properties: (transfer none): A #MMSimpleConnectProperties bundle.
|
|
Packit |
d14447 |
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
|
Packit |
d14447 |
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
|
|
Packit |
d14447 |
* @user_data: User data to pass to @callback.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Asynchronously requests to connect the modem using the given @properties.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* 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.
|
|
Packit |
d14447 |
* You can then call mm_modem_simple_connect_finish() to get the result of the operation.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* See mm_modem_simple_connect_sync() for the synchronous, blocking version of this method.
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
void
|
|
Packit |
d14447 |
mm_modem_simple_connect (MMModemSimple *self,
|
|
Packit |
d14447 |
MMSimpleConnectProperties *properties,
|
|
Packit |
d14447 |
GCancellable *cancellable,
|
|
Packit |
d14447 |
GAsyncReadyCallback callback,
|
|
Packit |
d14447 |
gpointer user_data)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
GTask *task;
|
|
Packit |
d14447 |
GVariant *variant;
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
g_return_if_fail (MM_IS_MODEM_SIMPLE (self));
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
task = g_task_new (self, cancellable, callback, user_data);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
variant = mm_simple_connect_properties_get_dictionary (properties);
|
|
Packit |
d14447 |
mm_gdbus_modem_simple_call_connect (
|
|
Packit |
d14447 |
MM_GDBUS_MODEM_SIMPLE (self),
|
|
Packit |
d14447 |
variant,
|
|
Packit |
d14447 |
cancellable,
|
|
Packit |
d14447 |
(GAsyncReadyCallback)simple_connect_ready,
|
|
Packit |
d14447 |
task);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
g_variant_unref (variant);
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* mm_modem_simple_connect_sync:
|
|
Packit |
d14447 |
* @self: A #MMModemSimple.
|
|
Packit |
d14447 |
* @properties: (transfer none): A #MMSimpleConnectProperties bundle.
|
|
Packit |
d14447 |
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
|
Packit |
d14447 |
* @error: Return location for error or %NULL.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Synchronously requests to connect the modem using the given @properties.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* The calling thread is blocked until a reply is received. See mm_modem_simple_connect()
|
|
Packit |
d14447 |
* for the asynchronous version of this method.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Returns: (transfer full): A #MMBearer, or %FALSE if @error is set. The returned value must be freed with g_object_ref().
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
MMBearer *
|
|
Packit |
d14447 |
mm_modem_simple_connect_sync (MMModemSimple *self,
|
|
Packit |
d14447 |
MMSimpleConnectProperties *properties,
|
|
Packit |
d14447 |
GCancellable *cancellable,
|
|
Packit |
d14447 |
GError **error)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
GObject *bearer = NULL;
|
|
Packit |
d14447 |
gchar *bearer_path = NULL;
|
|
Packit |
d14447 |
GVariant *variant;
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
variant = mm_simple_connect_properties_get_dictionary (properties);
|
|
Packit |
d14447 |
mm_gdbus_modem_simple_call_connect_sync (MM_GDBUS_MODEM_SIMPLE (self),
|
|
Packit |
d14447 |
variant,
|
|
Packit |
d14447 |
&bearer_path,
|
|
Packit |
d14447 |
cancellable,
|
|
Packit |
d14447 |
error);
|
|
Packit |
d14447 |
if (bearer_path) {
|
|
Packit |
d14447 |
bearer = g_initable_new (MM_TYPE_BEARER,
|
|
Packit |
d14447 |
cancellable,
|
|
Packit |
d14447 |
error,
|
|
Packit |
d14447 |
"g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
|
Packit |
d14447 |
"g-name", MM_DBUS_SERVICE,
|
|
Packit |
d14447 |
"g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)),
|
|
Packit |
d14447 |
"g-object-path", bearer_path,
|
|
Packit |
d14447 |
"g-interface-name", "org.freedesktop.ModemManager1.Bearer",
|
|
Packit |
d14447 |
NULL);
|
|
Packit |
d14447 |
g_free (bearer_path);
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
g_variant_unref (variant);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
return (bearer ? MM_BEARER (bearer) : NULL);
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/*****************************************************************************/
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* mm_modem_simple_disconnect_finish:
|
|
Packit |
d14447 |
* @self: A #MMModemSimple.
|
|
Packit |
d14447 |
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_simple_disconnect().
|
|
Packit |
d14447 |
* @error: Return location for error or %NULL.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Finishes an operation started with mm_modem_simple_disconnect().
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Returns: %TRUE if the modem is successfully disconnected, %FALSE if @error is set.
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
gboolean
|
|
Packit |
d14447 |
mm_modem_simple_disconnect_finish (MMModemSimple *self,
|
|
Packit |
d14447 |
GAsyncResult *res,
|
|
Packit |
d14447 |
GError **error)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), FALSE);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
return mm_gdbus_modem_simple_call_disconnect_finish (MM_GDBUS_MODEM_SIMPLE (self), res, error);
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* mm_modem_simple_disconnect:
|
|
Packit |
d14447 |
* @self: A #MMModemSimple.
|
|
Packit |
d14447 |
* @bearer: (allow-none): Path of the bearer to disconnect, or %NULL to disconnect all connected bearers.
|
|
Packit |
d14447 |
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
|
Packit |
d14447 |
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
|
|
Packit |
d14447 |
* @user_data: User data to pass to @callback.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Asynchronously requests to disconnect the modem.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* 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.
|
|
Packit |
d14447 |
* You can then call mm_modem_simple_disconnect_finish() to get the result of the operation.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* See mm_modem_simple_disconnect_sync() for the synchronous, blocking version of this method.
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
void
|
|
Packit |
d14447 |
mm_modem_simple_disconnect (MMModemSimple *self,
|
|
Packit |
d14447 |
const gchar *bearer,
|
|
Packit |
d14447 |
GCancellable *cancellable,
|
|
Packit |
d14447 |
GAsyncReadyCallback callback,
|
|
Packit |
d14447 |
gpointer user_data)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
g_return_if_fail (MM_IS_MODEM_SIMPLE (self));
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
mm_gdbus_modem_simple_call_disconnect (MM_GDBUS_MODEM_SIMPLE (self),
|
|
Packit |
d14447 |
bearer ? bearer : "/",
|
|
Packit |
d14447 |
cancellable,
|
|
Packit |
d14447 |
callback,
|
|
Packit |
d14447 |
user_data);
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* mm_modem_simple_disconnect_sync:
|
|
Packit |
d14447 |
* @self: A #MMModemSimple.
|
|
Packit |
d14447 |
* @bearer: (allow-none): Path of the bearer to disconnect, or %NULL to disconnect all connected bearers.
|
|
Packit |
d14447 |
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
|
Packit |
d14447 |
* @error: Return location for error or %NULL.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Synchronously requests to disconnect the modem.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* The calling thread is blocked until a reply is received. See mm_modem_simple_disconnect()
|
|
Packit |
d14447 |
* for the asynchronous version of this method.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Returns: %TRUE if the modem is successfully disconnected, %FALSE if @error is set.
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
gboolean
|
|
Packit |
d14447 |
mm_modem_simple_disconnect_sync (MMModemSimple *self,
|
|
Packit |
d14447 |
const gchar *bearer,
|
|
Packit |
d14447 |
GCancellable *cancellable,
|
|
Packit |
d14447 |
GError **error)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), FALSE);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
return mm_gdbus_modem_simple_call_disconnect_sync (MM_GDBUS_MODEM_SIMPLE (self),
|
|
Packit |
d14447 |
bearer ? bearer : "/",
|
|
Packit |
d14447 |
cancellable,
|
|
Packit |
d14447 |
error);
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/*****************************************************************************/
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* mm_modem_simple_get_status_finish:
|
|
Packit |
d14447 |
* @self: A #MMModemSimple.
|
|
Packit |
d14447 |
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_simple_connect().
|
|
Packit |
d14447 |
* @error: Return location for error or %NULL.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Finishes an operation started with mm_modem_simple_get_status().
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Returns: (transfer full): A #MMSimpleStatus, or %FALSE if @error is set. The returned value must be freed with g_object_ref().
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
MMSimpleStatus *
|
|
Packit |
d14447 |
mm_modem_simple_get_status_finish (MMModemSimple *self,
|
|
Packit |
d14447 |
GAsyncResult *res,
|
|
Packit |
d14447 |
GError **error)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
MMSimpleStatus *status;
|
|
Packit |
d14447 |
GVariant *dictionary = NULL;
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
if (!mm_gdbus_modem_simple_call_get_status_finish (MM_GDBUS_MODEM_SIMPLE (self), &dictionary, res, error))
|
|
Packit |
d14447 |
return NULL;
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
status = mm_simple_status_new_from_dictionary (dictionary, error);
|
|
Packit |
d14447 |
g_variant_unref (dictionary);
|
|
Packit |
d14447 |
return status;
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* mm_modem_simple_get_status:
|
|
Packit |
d14447 |
* @self: A #MMModemSimple.
|
|
Packit |
d14447 |
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
|
Packit |
d14447 |
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
|
|
Packit |
d14447 |
* @user_data: User data to pass to @callback.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Asynchronously requests a compilation of the status of the modem.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* 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.
|
|
Packit |
d14447 |
* You can then call mm_modem_simple_get_status_finish() to get the result of the operation.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* See mm_modem_simple_get_status_sync() for the synchronous, blocking version of this method.
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
void
|
|
Packit |
d14447 |
mm_modem_simple_get_status (MMModemSimple *self,
|
|
Packit |
d14447 |
GCancellable *cancellable,
|
|
Packit |
d14447 |
GAsyncReadyCallback callback,
|
|
Packit |
d14447 |
gpointer user_data)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
g_return_if_fail (MM_IS_MODEM_SIMPLE (self));
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
mm_gdbus_modem_simple_call_get_status (MM_GDBUS_MODEM_SIMPLE (self),
|
|
Packit |
d14447 |
cancellable,
|
|
Packit |
d14447 |
callback,
|
|
Packit |
d14447 |
user_data);
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/**
|
|
Packit |
d14447 |
* mm_modem_simple_get_status_sync:
|
|
Packit |
d14447 |
* @self: A #MMModemSimple.
|
|
Packit |
d14447 |
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
|
Packit |
d14447 |
* @error: Return location for error or %NULL.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Synchronously requests a compilation of the status of the modem.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* The calling thread is blocked until a reply is received. See mm_modem_simple_get_status()
|
|
Packit |
d14447 |
* for the asynchronous version of this method.
|
|
Packit |
d14447 |
*
|
|
Packit |
d14447 |
* Returns: (transfer full): A #MMSimpleStatus, or %FALSE if @error is set. The returned value must be freed with g_object_ref().
|
|
Packit |
d14447 |
*/
|
|
Packit |
d14447 |
MMSimpleStatus *
|
|
Packit |
d14447 |
mm_modem_simple_get_status_sync (MMModemSimple *self,
|
|
Packit |
d14447 |
GCancellable *cancellable,
|
|
Packit |
d14447 |
GError **error)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
MMSimpleStatus *status;
|
|
Packit |
d14447 |
GVariant *dictionary = NULL;
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
g_return_val_if_fail (MM_IS_MODEM_SIMPLE (self), NULL);
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
if (!mm_gdbus_modem_simple_call_get_status_sync (MM_GDBUS_MODEM_SIMPLE (self), &dictionary, cancellable, error))
|
|
Packit |
d14447 |
return NULL;
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
status = mm_simple_status_new_from_dictionary (dictionary, error);
|
|
Packit |
d14447 |
g_variant_unref (dictionary);
|
|
Packit |
d14447 |
return status;
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
/*****************************************************************************/
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
static void
|
|
Packit |
d14447 |
mm_modem_simple_init (MMModemSimple *self)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
}
|
|
Packit |
d14447 |
|
|
Packit |
d14447 |
static void
|
|
Packit |
d14447 |
mm_modem_simple_class_init (MMModemSimpleClass *modem_class)
|
|
Packit |
d14447 |
{
|
|
Packit |
d14447 |
}
|