api: Add Cell Broadcast support
Add access to the modem's CellBroadcast interface and to fetch Cell Broadcast messages. Closes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/253 Signed-off-by: Guido Günther <agx@sigxcpu.org>
This commit is contained in:
committed by
Aleksander Morgado
parent
60357247eb
commit
0e4bc1b6ea
@@ -32,6 +32,7 @@
|
||||
|
||||
#if !defined (_LIBMM_INSIDE_MM)
|
||||
/* This headers are not exported within ModemManager */
|
||||
# include <mm-cbm.h>
|
||||
# include <mm-manager.h>
|
||||
# include <mm-object.h>
|
||||
# include <mm-sim.h>
|
||||
@@ -43,6 +44,7 @@
|
||||
# include <mm-modem-3gpp-profile-manager.h>
|
||||
# include <mm-modem-3gpp-ussd.h>
|
||||
# include <mm-modem-cdma.h>
|
||||
# include <mm-modem-cell-broadcast.h>
|
||||
# include <mm-modem-simple.h>
|
||||
# include <mm-modem-location.h>
|
||||
# include <mm-modem-messaging.h>
|
||||
|
||||
@@ -15,6 +15,7 @@ headers = files(
|
||||
'mm-call-audio-format.h',
|
||||
'mm-call.h',
|
||||
'mm-call-properties.h',
|
||||
'mm-cbm.h',
|
||||
'mm-cdma-manual-activation-properties.h',
|
||||
'mm-cell-info.h',
|
||||
'mm-cell-info-cdma.h',
|
||||
@@ -38,8 +39,10 @@ headers = files(
|
||||
'mm-modem-3gpp-profile-manager.h',
|
||||
'mm-modem-3gpp-ussd.h',
|
||||
'mm-modem-cdma.h',
|
||||
'mm-modem-cell-broadcast.h',
|
||||
'mm-modem-firmware.h',
|
||||
'mm-modem.h',
|
||||
'mm-modem-cell-broadcast.h',
|
||||
'mm-modem-location.h',
|
||||
'mm-modem-messaging.h',
|
||||
'mm-modem-oma.h',
|
||||
@@ -78,6 +81,7 @@ sources = files(
|
||||
'mm-call-audio-format.c',
|
||||
'mm-call.c',
|
||||
'mm-call-properties.c',
|
||||
'mm-cbm.c',
|
||||
'mm-cdma-manual-activation-properties.c',
|
||||
'mm-cell-info.c',
|
||||
'mm-cell-info-cdma.c',
|
||||
@@ -102,6 +106,7 @@ sources = files(
|
||||
'mm-modem-3gpp-ussd.c',
|
||||
'mm-modem.c',
|
||||
'mm-modem-cdma.c',
|
||||
'mm-modem-cell-broadcast.c',
|
||||
'mm-modem-firmware.c',
|
||||
'mm-modem-location.c',
|
||||
'mm-modem-messaging.c',
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* libmm-glib -- Access modem status & information from glib applications
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2024 Guido Günther <agx@sigxcpu.org>
|
||||
*/
|
||||
|
||||
#include "string.h"
|
||||
|
||||
#include "mm-helpers.h"
|
||||
#include "mm-cbm.h"
|
||||
#include "mm-modem.h"
|
||||
|
||||
/**
|
||||
* SECTION: mm-cbm
|
||||
* @title: MMCbm
|
||||
* @short_description: The CBM interface
|
||||
*
|
||||
* The #MMCbm is an object providing access to the methods, signals and
|
||||
* properties of the CBM interface.
|
||||
*
|
||||
* When the CBM is exposed and available in the bus, it is ensured that at
|
||||
* least this interface is also available.
|
||||
*/
|
||||
|
||||
G_DEFINE_TYPE (MMCbm, mm_cbm, MM_GDBUS_TYPE_CBM_PROXY)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_cbm_get_path:
|
||||
* @self: A #MMCbm.
|
||||
*
|
||||
* Gets the DBus path of the #MMCbm object.
|
||||
*
|
||||
* Returns: (transfer none): The DBus path of the #MMCbm object.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
const gchar *
|
||||
mm_cbm_get_path (MMCbm *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_CBM (self), NULL);
|
||||
|
||||
RETURN_NON_EMPTY_CONSTANT_STRING (
|
||||
g_dbus_proxy_get_object_path (G_DBUS_PROXY (self)));
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_cbm_dup_path:
|
||||
* @self: A #MMCbm.
|
||||
*
|
||||
* Gets a copy of the DBus path of the #MMCbm object.
|
||||
*
|
||||
* Returns: (transfer full): The DBus path of the #MMCbm object. The returned
|
||||
* value should be freed with g_free().
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
gchar *
|
||||
mm_cbm_dup_path (MMCbm *self)
|
||||
{
|
||||
gchar *value;
|
||||
|
||||
g_return_val_if_fail (MM_IS_CBM (self), NULL);
|
||||
|
||||
g_object_get (G_OBJECT (self),
|
||||
"g-object-path", &value,
|
||||
NULL);
|
||||
|
||||
RETURN_NON_EMPTY_STRING (value);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_cbm_get_text:
|
||||
* @self: A #MMCbm.
|
||||
*
|
||||
* Gets the message text, in UTF-8.
|
||||
*
|
||||
* <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_cbm_dup_text() if on another thread.</warning>
|
||||
*
|
||||
* Returns: (transfer none): The message text, or %NULL if it doesn't contain
|
||||
* any (e.g. contains data instead).
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
const gchar *
|
||||
mm_cbm_get_text (MMCbm *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_CBM (self), NULL);
|
||||
|
||||
RETURN_NON_EMPTY_CONSTANT_STRING (
|
||||
mm_gdbus_cbm_get_text (MM_GDBUS_CBM (self)));
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_cbm_dup_text:
|
||||
* @self: A #MMCbm.
|
||||
*
|
||||
* Gets the message text, in UTF-8.
|
||||
*
|
||||
* Returns: (transfer full): The message text, or %NULL if it doesn't contain
|
||||
* any (e.g. contains data instead). The returned value should be freed with
|
||||
* g_free().
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
gchar *
|
||||
mm_cbm_dup_text (MMCbm *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_CBM (self), NULL);
|
||||
|
||||
RETURN_NON_EMPTY_STRING (
|
||||
mm_gdbus_cbm_dup_text (MM_GDBUS_CBM (self)));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_cbm_get_state:
|
||||
* @self: A #MMCbm.
|
||||
*
|
||||
* Gets the state of this CBM.
|
||||
*
|
||||
* Returns: A #MMCbmState specifying the state.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
MMCbmState
|
||||
mm_cbm_get_state (MMCbm *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_CBM (self), MM_CBM_STATE_UNKNOWN);
|
||||
|
||||
return (MMCbmState)mm_gdbus_cbm_get_state (MM_GDBUS_CBM (self));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_cbm_get_channel:
|
||||
* @self: A #MMCbm.
|
||||
*
|
||||
* Gets the channel of this CBM.
|
||||
*
|
||||
* Returns: The channel
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
guint
|
||||
mm_cbm_get_channel (MMCbm *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_CBM (self), 0);
|
||||
|
||||
return mm_gdbus_cbm_get_channel (MM_GDBUS_CBM (self));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_cbm_get_message_code:
|
||||
* @self: A #MMCbm.
|
||||
*
|
||||
* Gets the message code of this CBM.
|
||||
*
|
||||
* Returns: The message code
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
guint
|
||||
mm_cbm_get_message_code (MMCbm *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_CBM (self), 0);
|
||||
|
||||
return mm_gdbus_cbm_get_message_code (MM_GDBUS_CBM (self));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_cbm_get_update:
|
||||
* @self: A #MMCbm.
|
||||
*
|
||||
* Gets the update number of this CBM.
|
||||
*
|
||||
* Returns: The update number
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
guint
|
||||
mm_cbm_get_update (MMCbm *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_CBM (self), 0);
|
||||
|
||||
return mm_gdbus_cbm_get_update (MM_GDBUS_CBM (self));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
mm_cbm_init (MMCbm *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
mm_cbm_class_init (MMCbmClass *cbm_class)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* libmm-glib -- Access modem status & information from glib applications
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2024 Guido Günther <agx@sigxcpu.org>
|
||||
*/
|
||||
|
||||
#ifndef _MM_CBM_H_
|
||||
#define _MM_CBM_H_
|
||||
|
||||
#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION)
|
||||
#error "Only <libmm-glib.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <ModemManager.h>
|
||||
|
||||
#include "mm-gdbus-cbm.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MM_TYPE_CBM (mm_cbm_get_type ())
|
||||
#define MM_CBM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_CBM, MMCbm))
|
||||
#define MM_CBM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_CBM, MMCbmClass))
|
||||
#define MM_IS_CBM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_CBM))
|
||||
#define MM_IS_CBM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_CBM))
|
||||
#define MM_CBM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_CBM, MMCbmClass))
|
||||
|
||||
typedef struct _MMCbm MMCbm;
|
||||
typedef struct _MMCbmClass MMCbmClass;
|
||||
|
||||
/**
|
||||
* MMCbm:
|
||||
*
|
||||
* The #MMCbm structure contains private data and should only be accessed
|
||||
* using the provided API.
|
||||
*/
|
||||
struct _MMCbm {
|
||||
/*< private >*/
|
||||
MmGdbusCbmProxy parent;
|
||||
gpointer unused;
|
||||
};
|
||||
|
||||
struct _MMCbmClass {
|
||||
/*< private >*/
|
||||
MmGdbusCbmProxyClass parent;
|
||||
};
|
||||
|
||||
GType mm_cbm_get_type (void);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMCbm, g_object_unref)
|
||||
|
||||
const gchar *mm_cbm_get_path (MMCbm *self);
|
||||
gchar *mm_cbm_dup_path (MMCbm *self);
|
||||
|
||||
const gchar *mm_cbm_get_text (MMCbm *self);
|
||||
gchar *mm_cbm_dup_text (MMCbm *self);
|
||||
|
||||
MMCbmState mm_cbm_get_state (MMCbm *self);
|
||||
|
||||
guint mm_cbm_get_channel (MMCbm *self);
|
||||
guint mm_cbm_get_message_code (MMCbm *self);
|
||||
guint mm_cbm_get_update (MMCbm *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _MM_CBM_H_ */
|
||||
@@ -67,6 +67,7 @@ get_proxy_type (GDBusObjectManagerClient *manager,
|
||||
if (g_once_init_enter (&once_init_value)) {
|
||||
lookup_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
g_hash_table_insert (lookup_hash, (gpointer) "org.freedesktop.ModemManager1.Modem", GSIZE_TO_POINTER (MM_TYPE_MODEM));
|
||||
g_hash_table_insert (lookup_hash, (gpointer) "org.freedesktop.ModemManager1.Modem.CellBroadcast", GSIZE_TO_POINTER (MM_TYPE_MODEM_CELL_BROADCAST));
|
||||
g_hash_table_insert (lookup_hash, (gpointer) "org.freedesktop.ModemManager1.Modem.Messaging", GSIZE_TO_POINTER (MM_TYPE_MODEM_MESSAGING));
|
||||
g_hash_table_insert (lookup_hash, (gpointer) "org.freedesktop.ModemManager1.Modem.Voice", GSIZE_TO_POINTER (MM_TYPE_MODEM_VOICE));
|
||||
g_hash_table_insert (lookup_hash, (gpointer) "org.freedesktop.ModemManager1.Modem.Location", GSIZE_TO_POINTER (MM_TYPE_MODEM_LOCATION));
|
||||
|
||||
@@ -0,0 +1,434 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* libmm-glib -- Access modem status & information from glib applications
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2024 Guido Günther <agx@sigxcpu.org>
|
||||
*/
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "mm-helpers.h"
|
||||
#include "mm-common-helpers.h"
|
||||
#include "mm-errors-types.h"
|
||||
#include "mm-modem-cell-broadcast.h"
|
||||
|
||||
/**
|
||||
* SECTION: mm-modem-cell-broadcast
|
||||
* @title: MMModemCellBroadcast
|
||||
* @short_description: The CellBroadcast interface
|
||||
*
|
||||
* The #MMModemCellBroadcast is an object providing access to the methods, signals and
|
||||
* properties of the CellBroadcast interface.
|
||||
*
|
||||
* The CellBroadcast interface is exposed whenever a modem has cell broadcast capabilities.
|
||||
*/
|
||||
|
||||
G_DEFINE_TYPE (MMModemCellBroadcast, mm_modem_cell_broadcast, MM_GDBUS_TYPE_MODEM_CELL_BROADCAST_PROXY)
|
||||
|
||||
struct _MMModemCellBroadcastPrivate {
|
||||
/* Common mutex to sync access */
|
||||
GMutex mutex;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_modem_cell_broadcast_get_path:
|
||||
* @self: A #MMModemCellBroadcast.
|
||||
*
|
||||
* Gets the DBus path of the #MMObject which implements this interface.
|
||||
*
|
||||
* Returns: (transfer none): The DBus path of the #MMObject object.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
const gchar *
|
||||
mm_modem_cell_broadcast_get_path (MMModemCellBroadcast *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_MODEM_CELL_BROADCAST (self), NULL);
|
||||
|
||||
RETURN_NON_EMPTY_CONSTANT_STRING (
|
||||
g_dbus_proxy_get_object_path (G_DBUS_PROXY (self)));
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_cell_broadcast_dup_path:
|
||||
* @self: A #MMModemCellBroadcast.
|
||||
*
|
||||
* Gets a copy of the DBus path of the #MMObject object which implements this
|
||||
* interface.
|
||||
*
|
||||
* Returns: (transfer full): The DBus path of the #MMObject. The returned value
|
||||
* should be freed with g_free().
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
gchar *
|
||||
mm_modem_cell_broadcast_dup_path (MMModemCellBroadcast *self)
|
||||
{
|
||||
gchar *value;
|
||||
|
||||
g_return_val_if_fail (MM_IS_MODEM_CELL_BROADCAST (self), NULL);
|
||||
|
||||
g_object_get (G_OBJECT (self),
|
||||
"g-object-path", &value,
|
||||
NULL);
|
||||
RETURN_NON_EMPTY_STRING (value);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
gchar **cbm_paths;
|
||||
GList *cbm_objects;
|
||||
guint i;
|
||||
} ListCbmContext;
|
||||
|
||||
static void
|
||||
cbm_object_list_free (GList *list)
|
||||
{
|
||||
g_list_free_full (list, g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
list_cbm_context_free (ListCbmContext *ctx)
|
||||
{
|
||||
g_strfreev (ctx->cbm_paths);
|
||||
cbm_object_list_free (ctx->cbm_objects);
|
||||
g_slice_free (ListCbmContext, ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_cell_broadcast_list_finish:
|
||||
* @self: A #MMModem.
|
||||
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to
|
||||
* mm_modem_cell_broadcast_list().
|
||||
* @error: Return location for error or %NULL.
|
||||
*
|
||||
* Finishes an operation started with mm_modem_cell_broadcast_list().
|
||||
*
|
||||
* Returns: (element-type ModemManager.Cbm) (transfer full): A list of #MMCbm
|
||||
* objects, or #NULL if either not found or @error is set. The returned value
|
||||
* should be freed with g_list_free_full() using g_object_unref() as
|
||||
* #GDestroyNotify function.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
GList *
|
||||
mm_modem_cell_broadcast_list_finish (MMModemCellBroadcast *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_MODEM_CELL_BROADCAST (self), FALSE);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void create_next_cbm (GTask *task);
|
||||
|
||||
static void
|
||||
list_build_object_ready (GDBusConnection *connection,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GObject *cbm;
|
||||
GObject *source_object;
|
||||
ListCbmContext *ctx;
|
||||
|
||||
source_object = g_async_result_get_source_object (res);
|
||||
cbm = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error);
|
||||
g_object_unref (source_object);
|
||||
|
||||
if (error) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
/* Keep the object */
|
||||
ctx->cbm_objects = g_list_prepend (ctx->cbm_objects, cbm);
|
||||
|
||||
/* If no more cbms, just end here. */
|
||||
if (!ctx->cbm_paths[++ctx->i]) {
|
||||
GList *cbm_objects;
|
||||
|
||||
cbm_objects = g_list_copy_deep (ctx->cbm_objects, (GCopyFunc)g_object_ref, NULL);
|
||||
g_task_return_pointer (task, cbm_objects, (GDestroyNotify)cbm_object_list_free);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Keep on creating next object */
|
||||
create_next_cbm (task);
|
||||
}
|
||||
|
||||
static void
|
||||
create_next_cbm (GTask *task)
|
||||
{
|
||||
MMModemCellBroadcast *self;
|
||||
ListCbmContext *ctx;
|
||||
|
||||
self = g_task_get_source_object (task);
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
g_async_initable_new_async (MM_TYPE_CBM,
|
||||
G_PRIORITY_DEFAULT,
|
||||
g_task_get_cancellable (task),
|
||||
(GAsyncReadyCallback)list_build_object_ready,
|
||||
task,
|
||||
"g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
||||
"g-name", MM_DBUS_SERVICE,
|
||||
"g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)),
|
||||
"g-object-path", ctx->cbm_paths[ctx->i],
|
||||
"g-interface-name", "org.freedesktop.ModemManager1.Cbm",
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_cell_broadcast_list:
|
||||
* @self: A #MMModemCellBroadcast.
|
||||
* @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 lists the #MMCbm objects in the modem.
|
||||
*
|
||||
* 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_cell_broadcast_list_finish() to get the result of the operation.
|
||||
*
|
||||
* See mm_modem_cell_broadcast_list_sync() for the synchronous, blocking version of
|
||||
* this method.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
void
|
||||
mm_modem_cell_broadcast_list (MMModemCellBroadcast *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
ListCbmContext *ctx;
|
||||
GTask *task;
|
||||
|
||||
g_return_if_fail (MM_IS_MODEM_CELL_BROADCAST (self));
|
||||
|
||||
ctx = g_slice_new0 (ListCbmContext);
|
||||
ctx->cbm_paths = mm_gdbus_modem_cell_broadcast_dup_cell_broadcasts (MM_GDBUS_MODEM_CELL_BROADCAST (self));
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, ctx, (GDestroyNotify)list_cbm_context_free);
|
||||
|
||||
/* If no CBM, just end here. */
|
||||
if (!ctx->cbm_paths || !ctx->cbm_paths[0]) {
|
||||
g_task_return_pointer (task, NULL, NULL);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Got list of paths. If at least one found, start creating objects for each */
|
||||
ctx->i = 0;
|
||||
create_next_cbm (task);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_cell_broadcast_list_sync:
|
||||
* @self: A #MMModemCellBroadcast.
|
||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||
* @error: Return location for error or %NULL.
|
||||
*
|
||||
* Synchronously lists the #MMCbm objects in the modem.
|
||||
*
|
||||
* The calling thread is blocked until a reply is received. See
|
||||
* mm_modem_cell_broadcast_list() for the asynchronous version of this method.
|
||||
*
|
||||
* Returns: (element-type ModemManager.Cbm) (transfer full): A list of #MMCbm
|
||||
* objects, or #NULL if either not found or @error is set. The returned value
|
||||
* should be freed with g_list_free_full() using g_object_unref() as
|
||||
* #GDestroyNotify function.
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
GList *
|
||||
mm_modem_cell_broadcast_list_sync (MMModemCellBroadcast *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GList *cbm_objects = NULL;
|
||||
gchar **cbm_paths = NULL;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (MM_IS_MODEM_CELL_BROADCAST (self), NULL);
|
||||
|
||||
cbm_paths = mm_gdbus_modem_cell_broadcast_dup_cell_broadcasts (MM_GDBUS_MODEM_CELL_BROADCAST (self));
|
||||
|
||||
/* Only non-empty lists are returned */
|
||||
if (!cbm_paths)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; cbm_paths[i]; i++) {
|
||||
GObject *cbm;
|
||||
|
||||
cbm = g_initable_new (MM_TYPE_CBM,
|
||||
cancellable,
|
||||
error,
|
||||
"g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
|
||||
"g-name", MM_DBUS_SERVICE,
|
||||
"g-connection", g_dbus_proxy_get_connection (G_DBUS_PROXY (self)),
|
||||
"g-object-path", cbm_paths[i],
|
||||
"g-interface-name", "org.freedesktop.ModemManager1.Cbm",
|
||||
NULL);
|
||||
if (!cbm) {
|
||||
cbm_object_list_free (cbm_objects);
|
||||
g_strfreev (cbm_paths);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Keep the object */
|
||||
cbm_objects = g_list_prepend (cbm_objects, cbm);
|
||||
}
|
||||
|
||||
g_strfreev (cbm_paths);
|
||||
return cbm_objects;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_modem_cell_broadcast_delete_finish:
|
||||
* @self: A #MMModemCellBroadcast.
|
||||
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to
|
||||
* mm_modem_cell_broadcast_delete().
|
||||
* @error: Return location for error or %NULL.
|
||||
*
|
||||
* Finishes an operation started with mm_modem_cell_broadcast_delete().
|
||||
*
|
||||
* Returns: %TRUE if the cbm was deleted, %FALSE if @error is set.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
gboolean
|
||||
mm_modem_cell_broadcast_delete_finish (MMModemCellBroadcast *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_MODEM_CELL_BROADCAST (self), FALSE);
|
||||
|
||||
return mm_gdbus_modem_cell_broadcast_call_delete_finish (MM_GDBUS_MODEM_CELL_BROADCAST (self), res, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_cell_broadcast_delete:
|
||||
* @self: A #MMModemCellBroadcast.
|
||||
* @cbm: Path of the #MMCbm to delete.
|
||||
* @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 deletes a given #MMCbm from the modem.
|
||||
*
|
||||
* 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_cell_broadcast_delete_finish() to get the result of the operation.
|
||||
*
|
||||
* See mm_modem_cell_broadcast_delete_sync() for the synchronous, blocking version
|
||||
* of this method.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
void
|
||||
mm_modem_cell_broadcast_delete (MMModemCellBroadcast *self,
|
||||
const gchar *cbm,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (MM_IS_MODEM_CELL_BROADCAST (self));
|
||||
|
||||
mm_gdbus_modem_cell_broadcast_call_delete (MM_GDBUS_MODEM_CELL_BROADCAST (self),
|
||||
cbm,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_cell_broadcast_delete_sync:
|
||||
* @self: A #MMModemCellBroadcast.
|
||||
* @cbm: Path of the #MMCbm to delete.
|
||||
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||
* @error: Return location for error or %NULL.
|
||||
|
||||
* Synchronously deletes a given #MMCbm from the modem.
|
||||
*
|
||||
* The calling thread is blocked until a reply is received. See
|
||||
* mm_modem_cell_broadcast_delete() for the asynchronous version of this method.
|
||||
*
|
||||
* Returns: %TRUE if the CBM was deleted, %FALSE if @error is set.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
gboolean
|
||||
mm_modem_cell_broadcast_delete_sync (MMModemCellBroadcast *self,
|
||||
const gchar *cbm,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_MODEM_CELL_BROADCAST (self), FALSE);
|
||||
|
||||
return mm_gdbus_modem_cell_broadcast_call_delete_sync (MM_GDBUS_MODEM_CELL_BROADCAST (self),
|
||||
cbm,
|
||||
cancellable,
|
||||
error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
mm_modem_cell_broadcast_init (MMModemCellBroadcast *self)
|
||||
{
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_MODEM_CELL_BROADCAST, MMModemCellBroadcastPrivate);
|
||||
g_mutex_init (&self->priv->mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
MMModemCellBroadcast *self = MM_MODEM_CELL_BROADCAST (object);
|
||||
|
||||
g_mutex_clear (&self->priv->mutex);
|
||||
|
||||
G_OBJECT_CLASS (mm_modem_cell_broadcast_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
mm_modem_cell_broadcast_class_init (MMModemCellBroadcastClass *modem_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (modem_class);
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (MMModemCellBroadcastPrivate));
|
||||
|
||||
object_class->finalize = finalize;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* libmm-glib -- Access modem status & information from glib applications
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2024 Guido Günther <agx@sigxcpu.org>
|
||||
*/
|
||||
|
||||
#ifndef _MM_MODEM_CELL_BROADCAST_H_
|
||||
#define _MM_MODEM_CELL_BROADCAST_H_
|
||||
|
||||
#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION)
|
||||
#error "Only <libmm-glib.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <ModemManager.h>
|
||||
|
||||
#include "mm-gdbus-modem.h"
|
||||
#include "mm-cbm.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MM_TYPE_MODEM_CELL_BROADCAST (mm_modem_cell_broadcast_get_type ())
|
||||
#define MM_MODEM_CELL_BROADCAST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_CELL_BROADCAST, MMModemCellBroadcast))
|
||||
#define MM_MODEM_CELL_BROADCAST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_CELL_BROADCAST, MMModemCellBroadcastClass))
|
||||
#define MM_IS_MODEM_CELL_BROADCAST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_CELL_BROADCAST))
|
||||
#define MM_IS_MODEM_CELL_BROADCAST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), MM_TYPE_MODEM_CELL_BROADCAST))
|
||||
#define MM_MODEM_CELL_BROADCAST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_CELL_BROADCAST, MMModemCellBroadcastClass))
|
||||
|
||||
typedef struct _MMModemCellBroadcast MMModemCellBroadcast;
|
||||
typedef struct _MMModemCellBroadcastClass MMModemCellBroadcastClass;
|
||||
typedef struct _MMModemCellBroadcastPrivate MMModemCellBroadcastPrivate;
|
||||
|
||||
/**
|
||||
* MMModemCellBroadcast:
|
||||
*
|
||||
* The #MMModemCellBroadcast structure contains private data and should only be accessed
|
||||
* using the provided API.
|
||||
*/
|
||||
struct _MMModemCellBroadcast {
|
||||
/*< private >*/
|
||||
MmGdbusModemCellBroadcastProxy parent;
|
||||
MMModemCellBroadcastPrivate *priv;
|
||||
};
|
||||
|
||||
struct _MMModemCellBroadcastClass {
|
||||
/*< private >*/
|
||||
MmGdbusModemCellBroadcastProxyClass parent;
|
||||
};
|
||||
|
||||
GType mm_modem_cell_broadcast_get_type (void);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMModemCellBroadcast, g_object_unref)
|
||||
|
||||
const gchar *mm_modem_cell_broadcast_get_path (MMModemCellBroadcast *self);
|
||||
gchar *mm_modem_cell_broadcast_dup_path (MMModemCellBroadcast *self);
|
||||
|
||||
void mm_modem_cell_broadcast_list (MMModemCellBroadcast *self,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
GList *mm_modem_cell_broadcast_list_finish (MMModemCellBroadcast *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
GList *mm_modem_cell_broadcast_list_sync (MMModemCellBroadcast *self,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
void mm_modem_cell_broadcast_delete (MMModemCellBroadcast *self,
|
||||
const gchar *cbm,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_modem_cell_broadcast_delete_finish (MMModemCellBroadcast *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
gboolean mm_modem_cell_broadcast_delete_sync (MMModemCellBroadcast *self,
|
||||
const gchar *cbm,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _MM_MODEM_CELL_BROADCAST_H_ */
|
||||
@@ -320,6 +320,52 @@ mm_object_peek_modem_cdma (MMObject *self)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_object_get_modem_cell_broadcast:
|
||||
* @self: A #MMObject.
|
||||
*
|
||||
* Gets the #MMModemCellBroadcast instance for the D-Bus interface
|
||||
* org.freedesktop.ModemManager1.Modem.ModemCellBroadcast on @self, if any.
|
||||
*
|
||||
* Returns: (transfer full): A #MMModemCellBroadcast that must be freed with
|
||||
* g_object_unref() or %NULL if @self does not implement the interface.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
MMModemCellBroadcast *
|
||||
mm_object_get_modem_cell_broadcast (MMObject *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
||||
|
||||
return (MMModemCellBroadcast *)mm_gdbus_object_get_modem_cell_broadcast (MM_GDBUS_OBJECT (self));
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_object_peek_modem_cell_broadcast: (skip)
|
||||
* @self: A #MMObject.
|
||||
*
|
||||
* Like mm_object_get_mm_modem_cell_broadcast() but doesn't increase the reference count
|
||||
* on the returned object.
|
||||
*
|
||||
* <warning>It is not safe to use the returned object if you are on another
|
||||
* thread than the one where the #MMManager is running.</warning>
|
||||
*
|
||||
* Returns: (transfer none): A #MMModemCellBroadcast or %NULL if @self does not
|
||||
* implement the interface. Do not free the returned object, it is owned by
|
||||
* @self.
|
||||
*
|
||||
* Since: 1.24
|
||||
*/
|
||||
MMModemCellBroadcast *
|
||||
mm_object_peek_modem_cell_broadcast (MMObject *self)
|
||||
{
|
||||
g_return_val_if_fail (MM_IS_OBJECT (MM_GDBUS_OBJECT (self)), NULL);
|
||||
|
||||
return (MMModemCellBroadcast *)mm_gdbus_object_peek_modem_cell_broadcast (MM_GDBUS_OBJECT (self));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
* mm_object_get_modem_simple:
|
||||
* @self: A #MMObject.
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "mm-modem-3gpp-profile-manager.h"
|
||||
#include "mm-modem-3gpp-ussd.h"
|
||||
#include "mm-modem-cdma.h"
|
||||
#include "mm-modem-cell-broadcast.h"
|
||||
#include "mm-modem-simple.h"
|
||||
#include "mm-modem-location.h"
|
||||
#include "mm-modem-messaging.h"
|
||||
@@ -86,6 +87,7 @@ MMModem3gpp *mm_object_get_modem_3gpp (MMObject
|
||||
MMModem3gppProfileManager *mm_object_get_modem_3gpp_profile_manager (MMObject *self);
|
||||
MMModem3gppUssd *mm_object_get_modem_3gpp_ussd (MMObject *self);
|
||||
MMModemCdma *mm_object_get_modem_cdma (MMObject *self);
|
||||
MMModemCellBroadcast *mm_object_get_modem_cell_broadcast (MMObject *self);
|
||||
MMModemSimple *mm_object_get_modem_simple (MMObject *self);
|
||||
MMModemLocation *mm_object_get_modem_location (MMObject *self);
|
||||
MMModemMessaging *mm_object_get_modem_messaging (MMObject *self);
|
||||
@@ -101,6 +103,7 @@ MMModem3gpp *mm_object_peek_modem_3gpp (MMObject
|
||||
MMModem3gppProfileManager *mm_object_peek_modem_3gpp_profile_manager (MMObject *self);
|
||||
MMModem3gppUssd *mm_object_peek_modem_3gpp_ussd (MMObject *self);
|
||||
MMModemCdma *mm_object_peek_modem_cdma (MMObject *self);
|
||||
MMModemCellBroadcast *mm_object_peek_modem_cell_broadcast (MMObject *self);
|
||||
MMModemSimple *mm_object_peek_modem_simple (MMObject *self);
|
||||
MMModemLocation *mm_object_peek_modem_location (MMObject *self);
|
||||
MMModemMessaging *mm_object_peek_modem_messaging (MMObject *self);
|
||||
|
||||
Reference in New Issue
Block a user