libmm-glib,modem: new methods to get list of cell infos
This commit is contained in:
@@ -230,6 +230,9 @@ mm_modem_create_bearer_sync
|
|||||||
mm_modem_delete_bearer
|
mm_modem_delete_bearer
|
||||||
mm_modem_delete_bearer_finish
|
mm_modem_delete_bearer_finish
|
||||||
mm_modem_delete_bearer_sync
|
mm_modem_delete_bearer_sync
|
||||||
|
mm_modem_get_cell_info
|
||||||
|
mm_modem_get_cell_info_finish
|
||||||
|
mm_modem_get_cell_info_sync
|
||||||
<SUBSECTION DebugMethods>
|
<SUBSECTION DebugMethods>
|
||||||
mm_modem_command
|
mm_modem_command
|
||||||
mm_modem_command_finish
|
mm_modem_command_finish
|
||||||
|
@@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "mm-common-helpers.h"
|
#include "mm-common-helpers.h"
|
||||||
#include "mm-errors-types.h"
|
#include "mm-errors-types.h"
|
||||||
#include "mm-helpers.h"
|
#include "mm-helpers.h"
|
||||||
@@ -3247,6 +3246,135 @@ mm_modem_set_primary_sim_slot_sync (MMModem *self,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static GList *
|
||||||
|
create_cell_info_list (GVariant *variant,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GError *inner_error = NULL;
|
||||||
|
GList *list = NULL;
|
||||||
|
GVariantIter dict_iter;
|
||||||
|
GVariant *dict;
|
||||||
|
|
||||||
|
/* Input is aa{sv} */
|
||||||
|
g_variant_iter_init (&dict_iter, variant);
|
||||||
|
while ((dict = g_variant_iter_next_value (&dict_iter))) {
|
||||||
|
MMCellInfo *cell_info;
|
||||||
|
|
||||||
|
cell_info = mm_cell_info_new_from_dictionary (dict, &inner_error);
|
||||||
|
if (inner_error)
|
||||||
|
break;
|
||||||
|
|
||||||
|
list = g_list_prepend (list, cell_info);
|
||||||
|
g_variant_unref (dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inner_error) {
|
||||||
|
g_list_free_full (g_steal_pointer (&list), g_object_unref);
|
||||||
|
g_propagate_error (error, inner_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_variant_unref (variant);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_modem_get_cell_info_finish:
|
||||||
|
* @self: A #MMModem.
|
||||||
|
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to
|
||||||
|
* mm_modem_get_cell_info().
|
||||||
|
* @error: Return location for error or %NULL.
|
||||||
|
*
|
||||||
|
* Finishes an operation started with mm_modem_get_cell_info().
|
||||||
|
*
|
||||||
|
* Returns: (transfer full) (element-type ModemManager.CellInfo): a list
|
||||||
|
* of #MMCellInfo objects, or #NULL if @error is set. The returned value
|
||||||
|
* should be freed with g_list_free_full() using g_object_unref() as
|
||||||
|
* #GDestroyNotify function.
|
||||||
|
*
|
||||||
|
* Since: 1.20
|
||||||
|
*/
|
||||||
|
GList *
|
||||||
|
mm_modem_get_cell_info_finish (MMModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GVariant *result = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
|
||||||
|
|
||||||
|
if (!mm_gdbus_modem_call_get_cell_info_finish (MM_GDBUS_MODEM (self), &result, res, error))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return create_cell_info_list (result, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_modem_get_cell_info:
|
||||||
|
* @self: A #MMModem.
|
||||||
|
* @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 requests to get info about serving and neighboring cells.
|
||||||
|
*
|
||||||
|
* 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_get_cell_info_finish() to get the result of the operation.
|
||||||
|
*
|
||||||
|
* See mm_modem_get_cell_info_sync() for the synchronous, blocking version of this
|
||||||
|
* method.
|
||||||
|
*
|
||||||
|
* Since: 1.20
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
mm_modem_get_cell_info (MMModem *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_return_if_fail (MM_IS_MODEM (self));
|
||||||
|
|
||||||
|
mm_gdbus_modem_call_get_cell_info (MM_GDBUS_MODEM (self), cancellable, callback, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_modem_get_cell_info_sync:
|
||||||
|
* @self: A #MMModem.
|
||||||
|
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||||
|
* @error: Return location for error or %NULL.
|
||||||
|
*
|
||||||
|
* Synchronously requests to get info about serving and neighboring cells.
|
||||||
|
*
|
||||||
|
* The calling thread is blocked until a reply is received. See
|
||||||
|
* mm_modem_get_cell_info() for the asynchronous version of this method.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full) (element-type ModemManager.CellInfo): a list
|
||||||
|
* of #MMCellInfo objects, or #NULL if @error is set. The returned value
|
||||||
|
* should be freed with g_list_free_full() using g_object_unref() as
|
||||||
|
* #GDestroyNotify function.
|
||||||
|
*
|
||||||
|
* Since: 1.20
|
||||||
|
*/
|
||||||
|
GList *
|
||||||
|
mm_modem_get_cell_info_sync (MMModem *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GVariant *result = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
|
||||||
|
|
||||||
|
if (!mm_gdbus_modem_call_get_cell_info_sync (MM_GDBUS_MODEM (self), &result, cancellable, error))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return create_cell_info_list (result, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mm_modem_init (MMModem *self)
|
mm_modem_init (MMModem *self)
|
||||||
{
|
{
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include "mm-unlock-retries.h"
|
#include "mm-unlock-retries.h"
|
||||||
#include "mm-sim.h"
|
#include "mm-sim.h"
|
||||||
#include "mm-bearer.h"
|
#include "mm-bearer.h"
|
||||||
|
#include "mm-cell-info.h"
|
||||||
#include "mm-helper-types.h"
|
#include "mm-helper-types.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
@@ -372,6 +373,17 @@ gboolean mm_modem_set_primary_sim_slot_sync (MMModem *self,
|
|||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
void mm_modem_get_cell_info (MMModem *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
GList *mm_modem_get_cell_info_finish (MMModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
GList *mm_modem_get_cell_info_sync (MMModem *self,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* _MM_MODEM_H_ */
|
#endif /* _MM_MODEM_H_ */
|
||||||
|
Reference in New Issue
Block a user