aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2024-04-19 13:21:40 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2024-05-06 13:45:39 +0000
commit92a89efd0282adb0c4cd86063671ebd3d8b5d0f3 (patch)
tree6905e23a07905162d02525256e87a6e4a0ab7634 /src
parent0f48695d543d1fa1eb5673a80bf00acaef844054 (diff)
iface-modem-oma: use G_DECLARE|DEFINE_INTERFACE() macros
Diffstat (limited to 'src')
-rw-r--r--src/mm-broadband-modem-qmi.c4
-rw-r--r--src/mm-broadband-modem.c4
-rw-r--r--src/mm-iface-modem-oma.c129
-rw-r--r--src/mm-iface-modem-oma.h15
4 files changed, 63 insertions, 89 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 708ad6be..b002d9b3 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -61,7 +61,7 @@ static void iface_modem_voice_init (MMIfaceModemVoiceInterface
static void iface_modem_cdma_init (MMIfaceModemCdma *iface);
static void iface_modem_messaging_init (MMIfaceModemMessagingInterface *iface);
static void iface_modem_location_init (MMIfaceModemLocationInterface *iface);
-static void iface_modem_oma_init (MMIfaceModemOma *iface);
+static void iface_modem_oma_init (MMIfaceModemOmaInterface *iface);
static void iface_modem_firmware_init (MMIfaceModemFirmwareInterface *iface);
static void iface_modem_sar_init (MMIfaceModemSarInterface *iface);
static void iface_modem_signal_init (MMIfaceModemSignalInterface *iface);
@@ -14152,7 +14152,7 @@ iface_modem_signal_init (MMIfaceModemSignalInterface *iface)
}
static void
-iface_modem_oma_init (MMIfaceModemOma *iface)
+iface_modem_oma_init (MMIfaceModemOmaInterface *iface)
{
iface->check_support = oma_check_support;
iface->check_support_finish = oma_check_support_finish;
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index ab2204ad..2cc01a76 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -72,7 +72,7 @@ static void iface_modem_messaging_init (MMIfaceModemMessagingInterfac
static void iface_modem_voice_init (MMIfaceModemVoiceInterface *iface);
static void iface_modem_time_init (MMIfaceModemTimeInterface *iface);
static void iface_modem_signal_init (MMIfaceModemSignalInterface *iface);
-static void iface_modem_oma_init (MMIfaceModemOma *iface);
+static void iface_modem_oma_init (MMIfaceModemOmaInterface *iface);
static void iface_modem_firmware_init (MMIfaceModemFirmwareInterface *iface);
static void iface_modem_sar_init (MMIfaceModemSarInterface *iface);
@@ -13763,7 +13763,7 @@ iface_modem_signal_init (MMIfaceModemSignalInterface *iface)
}
static void
-iface_modem_oma_init (MMIfaceModemOma *iface)
+iface_modem_oma_init (MMIfaceModemOmaInterface *iface)
{
}
diff --git a/src/mm-iface-modem-oma.c b/src/mm-iface-modem-oma.c
index 9d30997c..ca3278b8 100644
--- a/src/mm-iface-modem-oma.c
+++ b/src/mm-iface-modem-oma.c
@@ -28,6 +28,8 @@
static GQuark support_checked_quark;
static GQuark supported_quark;
+G_DEFINE_INTERFACE (MMIfaceModemOma, mm_iface_modem_oma, MM_TYPE_IFACE_MODEM)
+
/*****************************************************************************/
void
@@ -168,7 +170,7 @@ setup_ready (MMIfaceModemOma *self,
{
GError *error = NULL;
- if (!MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->setup_finish (self, res, &error))
+ if (!MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->setup_finish (self, res, &error))
mm_dbus_method_invocation_take_error (ctx->invocation, error);
else {
/* Update current features in the interface */
@@ -205,8 +207,8 @@ handle_setup_auth_ready (MMBaseModem *self,
return;
}
- if (!MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->setup ||
- !MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->setup_finish) {
+ if (!MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->setup ||
+ !MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->setup_finish) {
mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
"Cannot setup OMA: operation not supported");
handle_setup_context_free (ctx);
@@ -217,7 +219,7 @@ handle_setup_auth_ready (MMBaseModem *self,
mm_obj_dbg (self, "setting up OMA features: '%s'", str);
g_free (str);
- MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->setup (
+ MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->setup (
ctx->self,
ctx->features,
(GAsyncReadyCallback)setup_ready,
@@ -272,7 +274,7 @@ start_client_initiated_session_ready (MMIfaceModemOma *self,
{
GError *error = NULL;
- if (!MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->start_client_initiated_session_finish (self, res, &error))
+ if (!MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->start_client_initiated_session_finish (self, res, &error))
mm_dbus_method_invocation_take_error (ctx->invocation, error);
else {
/* Update interface info */
@@ -310,8 +312,8 @@ handle_start_client_initiated_session_auth_ready (MMBaseModem *self,
return;
}
- if (!MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->start_client_initiated_session ||
- !MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->start_client_initiated_session_finish) {
+ if (!MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->start_client_initiated_session ||
+ !MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->start_client_initiated_session_finish) {
mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
"Cannot start client-initiated OMA session: "
"operation not supported");
@@ -332,7 +334,7 @@ handle_start_client_initiated_session_auth_ready (MMBaseModem *self,
mm_obj_dbg (self, "starting client-initiated OMA session (%s)",
mm_oma_session_type_get_string (ctx->session_type));
- MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->start_client_initiated_session (
+ MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->start_client_initiated_session (
ctx->self,
ctx->session_type,
(GAsyncReadyCallback)start_client_initiated_session_ready,
@@ -389,7 +391,7 @@ accept_network_initiated_session_ready (MMIfaceModemOma *self,
{
GError *error = NULL;
- if (!MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->accept_network_initiated_session_finish (self, res, &error))
+ if (!MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->accept_network_initiated_session_finish (self, res, &error))
mm_dbus_method_invocation_take_error (ctx->invocation, error);
else {
/* If accepted or rejected, remove from pending */
@@ -464,8 +466,8 @@ handle_accept_network_initiated_session_auth_ready (MMBaseModem *self,
return;
}
- if (!MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->accept_network_initiated_session ||
- !MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->accept_network_initiated_session_finish) {
+ if (!MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->accept_network_initiated_session ||
+ !MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->accept_network_initiated_session_finish) {
mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
"Cannot accept network-initiated OMA session: "
"operation not supported");
@@ -487,7 +489,7 @@ handle_accept_network_initiated_session_auth_ready (MMBaseModem *self,
ctx->accept ? "accepting" : "rejecting",
mm_oma_session_type_get_string (ctx->session_type),
ctx->session_id);
- MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->accept_network_initiated_session (
+ MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->accept_network_initiated_session (
ctx->self,
ctx->session_id,
ctx->accept,
@@ -545,7 +547,7 @@ cancel_session_ready (MMIfaceModemOma *self,
{
GError *error = NULL;
- if (!MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->cancel_session_finish (self, res, &error))
+ if (!MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->cancel_session_finish (self, res, &error))
mm_dbus_method_invocation_take_error (ctx->invocation, error);
else {
/* Clear interface info when cancelled */
@@ -583,8 +585,8 @@ handle_cancel_session_auth_ready (MMBaseModem *self,
return;
}
- if (!MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->cancel_session ||
- !MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->cancel_session_finish) {
+ if (!MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->cancel_session ||
+ !MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->cancel_session_finish) {
mm_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
"Cannot cancel OMA session: operation not supported");
handle_cancel_session_context_free (ctx);
@@ -592,7 +594,7 @@ handle_cancel_session_auth_ready (MMBaseModem *self,
}
mm_obj_dbg (self, "cancelling OMA session");
- MM_IFACE_MODEM_OMA_GET_INTERFACE (ctx->self)->cancel_session (
+ MM_IFACE_MODEM_OMA_GET_IFACE (ctx->self)->cancel_session (
ctx->self,
(GAsyncReadyCallback)cancel_session_ready,
ctx);
@@ -659,7 +661,7 @@ disable_unsolicited_events_ready (MMIfaceModemOma *self,
DisablingContext *ctx;
GError *error = NULL;
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->disable_unsolicited_events_finish (self, res, &error);
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->disable_unsolicited_events_finish (self, res, &error);
if (error) {
g_task_return_error (task, error);
g_object_unref (task);
@@ -680,7 +682,7 @@ cleanup_unsolicited_events_ready (MMIfaceModemOma *self,
DisablingContext *ctx;
GError *error = NULL;
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->cleanup_unsolicited_events_finish (self, res, &error);
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->cleanup_unsolicited_events_finish (self, res, &error);
if (error) {
g_task_return_error (task, error);
g_object_unref (task);
@@ -709,9 +711,9 @@ interface_disabling_step (GTask *task)
case DISABLING_STEP_DISABLE_UNSOLICITED_EVENTS:
/* Allow cleaning up unsolicited events */
- if (MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->disable_unsolicited_events &&
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->disable_unsolicited_events_finish) {
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->disable_unsolicited_events (
+ if (MM_IFACE_MODEM_OMA_GET_IFACE (self)->disable_unsolicited_events &&
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->disable_unsolicited_events_finish) {
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->disable_unsolicited_events (
self,
(GAsyncReadyCallback)disable_unsolicited_events_ready,
task);
@@ -722,9 +724,9 @@ interface_disabling_step (GTask *task)
case DISABLING_STEP_CLEANUP_UNSOLICITED_EVENTS:
/* Allow cleaning up unsolicited events */
- if (MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->cleanup_unsolicited_events &&
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->cleanup_unsolicited_events_finish) {
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->cleanup_unsolicited_events (
+ if (MM_IFACE_MODEM_OMA_GET_IFACE (self)->cleanup_unsolicited_events &&
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->cleanup_unsolicited_events_finish) {
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->cleanup_unsolicited_events (
self,
(GAsyncReadyCallback)cleanup_unsolicited_events_ready,
task);
@@ -818,7 +820,7 @@ load_features_ready (MMIfaceModemOma *self,
GError *error = NULL;
MMOmaFeature features;
- features = MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->load_features_finish (self, res, &error);
+ features = MM_IFACE_MODEM_OMA_GET_IFACE (self)->load_features_finish (self, res, &error);
if (error) {
g_task_return_error (task, error);
g_object_unref (task);
@@ -843,7 +845,7 @@ setup_unsolicited_events_ready (MMIfaceModemOma *self,
EnablingContext *ctx;
GError *error = NULL;
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->setup_unsolicited_events_finish (self, res, &error);
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->setup_unsolicited_events_finish (self, res, &error);
if (error) {
g_task_return_error (task, error);
g_object_unref (task);
@@ -865,7 +867,7 @@ enable_unsolicited_events_ready (MMIfaceModemOma *self,
GError *error = NULL;
/* Not critical! */
- if (!MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->enable_unsolicited_events_finish (self, res, &error)) {
+ if (!MM_IFACE_MODEM_OMA_GET_IFACE (self)->enable_unsolicited_events_finish (self, res, &error)) {
mm_obj_dbg (self, "couldn't enable unsolicited events: %s", error->message);
g_error_free (error);
}
@@ -897,9 +899,9 @@ interface_enabling_step (GTask *task)
/* fall through */
case ENABLING_STEP_LOAD_FEATURES:
- if (MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->load_features &&
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->load_features_finish) {
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->load_features (
+ if (MM_IFACE_MODEM_OMA_GET_IFACE (self)->load_features &&
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->load_features_finish) {
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->load_features (
self,
(GAsyncReadyCallback)load_features_ready,
task);
@@ -910,9 +912,9 @@ interface_enabling_step (GTask *task)
case ENABLING_STEP_SETUP_UNSOLICITED_EVENTS:
/* Allow setting up unsolicited events */
- if (MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->setup_unsolicited_events &&
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->setup_unsolicited_events_finish) {
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->setup_unsolicited_events (
+ if (MM_IFACE_MODEM_OMA_GET_IFACE (self)->setup_unsolicited_events &&
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->setup_unsolicited_events_finish) {
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->setup_unsolicited_events (
self,
(GAsyncReadyCallback)setup_unsolicited_events_ready,
task);
@@ -923,9 +925,9 @@ interface_enabling_step (GTask *task)
case ENABLING_STEP_ENABLE_UNSOLICITED_EVENTS:
/* Allow setting up unsolicited events */
- if (MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->enable_unsolicited_events &&
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->enable_unsolicited_events_finish) {
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->enable_unsolicited_events (
+ if (MM_IFACE_MODEM_OMA_GET_IFACE (self)->enable_unsolicited_events &&
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->enable_unsolicited_events_finish) {
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->enable_unsolicited_events (
self,
(GAsyncReadyCallback)enable_unsolicited_events_ready,
task);
@@ -1009,7 +1011,7 @@ check_support_ready (MMIfaceModemOma *self,
InitializationContext *ctx;
GError *error = NULL;
- if (!MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->check_support_finish (self, res, &error)) {
+ if (!MM_IFACE_MODEM_OMA_GET_IFACE (self)->check_support_finish (self, res, &error)) {
if (error) {
/* This error shouldn't be treated as critical */
mm_obj_dbg (self, "OMA support check failed: %s", error->message);
@@ -1068,9 +1070,9 @@ interface_initialization_step (GTask *task)
supported_quark,
GUINT_TO_POINTER (FALSE));
- if (MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->check_support &&
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->check_support_finish) {
- MM_IFACE_MODEM_OMA_GET_INTERFACE (self)->check_support (
+ if (MM_IFACE_MODEM_OMA_GET_IFACE (self)->check_support &&
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->check_support_finish) {
+ MM_IFACE_MODEM_OMA_GET_IFACE (self)->check_support (
self,
(GAsyncReadyCallback)check_support_ready,
task);
@@ -1192,44 +1194,21 @@ mm_iface_modem_oma_shutdown (MMIfaceModemOma *self)
/*****************************************************************************/
static void
-iface_modem_oma_init (gpointer g_iface)
+mm_iface_modem_oma_default_init (MMIfaceModemOmaInterface *iface)
{
- static gboolean initialized = FALSE;
+ static gsize initialized = 0;
- if (initialized)
+ if (!g_once_init_enter (&initialized))
return;
/* Properties */
- g_object_interface_install_property
- (g_iface,
- g_param_spec_object (MM_IFACE_MODEM_OMA_DBUS_SKELETON,
- "OMA DBus skeleton",
- "DBus skeleton for the OMA interface",
- MM_GDBUS_TYPE_MODEM_OMA_SKELETON,
- G_PARAM_READWRITE));
-
- initialized = TRUE;
-}
-
-GType
-mm_iface_modem_oma_get_type (void)
-{
- static GType iface_modem_oma_type = 0;
-
- if (!G_UNLIKELY (iface_modem_oma_type)) {
- static const GTypeInfo info = {
- sizeof (MMIfaceModemOma), /* class_size */
- iface_modem_oma_init, /* base_init */
- NULL, /* base_finalize */
- };
-
- iface_modem_oma_type = g_type_register_static (G_TYPE_INTERFACE,
- "MMIfaceModemOma",
- &info,
- 0);
-
- g_type_interface_add_prerequisite (iface_modem_oma_type, MM_TYPE_IFACE_MODEM);
- }
-
- return iface_modem_oma_type;
+ g_object_interface_install_property (
+ iface,
+ g_param_spec_object (MM_IFACE_MODEM_OMA_DBUS_SKELETON,
+ "OMA DBus skeleton",
+ "DBus skeleton for the OMA interface",
+ MM_GDBUS_TYPE_MODEM_OMA_SKELETON,
+ G_PARAM_READWRITE));
+
+ g_once_init_leave (&initialized, 1);
}
diff --git a/src/mm-iface-modem-oma.h b/src/mm-iface-modem-oma.h
index 8117ebe6..44ea52d3 100644
--- a/src/mm-iface-modem-oma.h
+++ b/src/mm-iface-modem-oma.h
@@ -22,16 +22,14 @@
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
-#define MM_TYPE_IFACE_MODEM_OMA (mm_iface_modem_oma_get_type ())
-#define MM_IFACE_MODEM_OMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_MODEM_OMA, MMIfaceModemOma))
-#define MM_IS_IFACE_MODEM_OMA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_IFACE_MODEM_OMA))
-#define MM_IFACE_MODEM_OMA_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_IFACE_MODEM_OMA, MMIfaceModemOma))
+#include "mm-iface-modem.h"
-#define MM_IFACE_MODEM_OMA_DBUS_SKELETON "iface-modem-oma-dbus-skeleton"
+#define MM_TYPE_IFACE_MODEM_OMA mm_iface_modem_oma_get_type ()
+G_DECLARE_INTERFACE (MMIfaceModemOma, mm_iface_modem_oma, MM, IFACE_MODEM_OMA, MMIfaceModem)
-typedef struct _MMIfaceModemOma MMIfaceModemOma;
+#define MM_IFACE_MODEM_OMA_DBUS_SKELETON "iface-modem-oma-dbus-skeleton"
-struct _MMIfaceModemOma {
+struct _MMIfaceModemOmaInterface {
GTypeInterface g_iface;
/* Check for Oma support (async) */
@@ -119,9 +117,6 @@ struct _MMIfaceModemOma {
GError **error);
};
-GType mm_iface_modem_oma_get_type (void);
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMIfaceModemOma, g_object_unref)
-
/* Initialize Oma interface (async) */
void mm_iface_modem_oma_initialize (MMIfaceModemOma *self,
GCancellable *cancellable,