diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2024-04-18 12:33:46 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2024-05-06 13:45:38 +0000 |
commit | 0a91a6035bc5b0376540a76bdcf81580a9192681 (patch) | |
tree | d90b2150a562a96f0512d6492f6826eb63f3642e | |
parent | cc2f1317b308b822c92dd0b172c2a5dd6287b2ac (diff) |
iface-modem-simple: use G_DECLARE|DEFINE_INTERFACE() macros
-rw-r--r-- | src/mm-broadband-modem.c | 4 | ||||
-rw-r--r-- | src/mm-iface-modem-simple.c | 65 | ||||
-rw-r--r-- | src/mm-iface-modem-simple.h | 15 |
3 files changed, 29 insertions, 55 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index d6d20c3c..2f367944 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -66,7 +66,7 @@ static void iface_modem_3gpp_init (MMIfaceModem3gppInterface static void iface_modem_3gpp_profile_manager_init (MMIfaceModem3gppProfileManagerInterface *iface); static void iface_modem_3gpp_ussd_init (MMIfaceModem3gppUssdInterface *iface); static void iface_modem_cdma_init (MMIfaceModemCdma *iface); -static void iface_modem_simple_init (MMIfaceModemSimple *iface); +static void iface_modem_simple_init (MMIfaceModemSimpleInterface *iface); static void iface_modem_location_init (MMIfaceModemLocationInterface *iface); static void iface_modem_messaging_init (MMIfaceModemMessagingInterface *iface); static void iface_modem_voice_init (MMIfaceModemVoice *iface); @@ -13665,7 +13665,7 @@ iface_modem_cdma_init (MMIfaceModemCdma *iface) } static void -iface_modem_simple_init (MMIfaceModemSimple *iface) +iface_modem_simple_init (MMIfaceModemSimpleInterface *iface) { } diff --git a/src/mm-iface-modem-simple.c b/src/mm-iface-modem-simple.c index 194c5c0b..4397bf3e 100644 --- a/src/mm-iface-modem-simple.c +++ b/src/mm-iface-modem-simple.c @@ -30,6 +30,8 @@ #include "mm-log-object.h" #include "mm-log-helpers.h" +G_DEFINE_INTERFACE (MMIfaceModemSimple, mm_iface_modem_simple, MM_TYPE_IFACE_MODEM) + /*****************************************************************************/ /* Private data context */ @@ -1166,52 +1168,29 @@ mm_iface_modem_simple_shutdown (MMIfaceModemSimple *self) /*****************************************************************************/ static void -iface_modem_simple_init (gpointer g_iface) +mm_iface_modem_simple_default_init (MMIfaceModemSimpleInterface *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_SIMPLE_DBUS_SKELETON, - "Simple DBus skeleton", - "DBus skeleton for the Simple interface", - MM_GDBUS_TYPE_MODEM_SIMPLE_SKELETON, - G_PARAM_READWRITE)); - - g_object_interface_install_property - (g_iface, - g_param_spec_object (MM_IFACE_MODEM_SIMPLE_STATUS, - "Simple status", - "Compilation of status values", - MM_TYPE_SIMPLE_STATUS, - G_PARAM_READWRITE)); - - initialized = TRUE; -} - -GType -mm_iface_modem_simple_get_type (void) -{ - static GType iface_modem_simple_type = 0; - - if (!G_UNLIKELY (iface_modem_simple_type)) { - static const GTypeInfo info = { - sizeof (MMIfaceModemSimple), /* class_size */ - iface_modem_simple_init, /* base_init */ - NULL, /* base_finalize */ - }; - - iface_modem_simple_type = g_type_register_static (G_TYPE_INTERFACE, - "MMIfaceModemSimple", - &info, - 0); - - g_type_interface_add_prerequisite (iface_modem_simple_type, MM_TYPE_IFACE_MODEM); - } - - return iface_modem_simple_type; + g_object_interface_install_property ( + iface, + g_param_spec_object (MM_IFACE_MODEM_SIMPLE_DBUS_SKELETON, + "Simple DBus skeleton", + "DBus skeleton for the Simple interface", + MM_GDBUS_TYPE_MODEM_SIMPLE_SKELETON, + G_PARAM_READWRITE)); + + g_object_interface_install_property ( + iface, + g_param_spec_object (MM_IFACE_MODEM_SIMPLE_STATUS, + "Simple status", + "Compilation of status values", + MM_TYPE_SIMPLE_STATUS, + G_PARAM_READWRITE)); + + g_once_init_leave (&initialized, 1); } diff --git a/src/mm-iface-modem-simple.h b/src/mm-iface-modem-simple.h index 673a1ad7..7068a037 100644 --- a/src/mm-iface-modem-simple.h +++ b/src/mm-iface-modem-simple.h @@ -19,23 +19,18 @@ #include <glib-object.h> #include <gio/gio.h> -#define MM_TYPE_IFACE_MODEM_SIMPLE (mm_iface_modem_simple_get_type ()) -#define MM_IFACE_MODEM_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_MODEM_SIMPLE, MMIfaceModemSimple)) -#define MM_IS_IFACE_MODEM_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_IFACE_MODEM_SIMPLE)) -#define MM_IFACE_MODEM_SIMPLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_IFACE_MODEM_SIMPLE, MMIfaceModemSimple)) +#include "mm-iface-modem.h" + +#define MM_TYPE_IFACE_MODEM_SIMPLE mm_iface_modem_simple_get_type () +G_DECLARE_INTERFACE (MMIfaceModemSimple, mm_iface_modem_simple, MM, IFACE_MODEM_SIMPLE, MMIfaceModem) #define MM_IFACE_MODEM_SIMPLE_DBUS_SKELETON "iface-modem-simple-dbus-skeleton" #define MM_IFACE_MODEM_SIMPLE_STATUS "iface-modem-simple-status" -typedef struct _MMIfaceModemSimple MMIfaceModemSimple; - -struct _MMIfaceModemSimple { +struct _MMIfaceModemSimpleInterface { GTypeInterface g_iface; }; -GType mm_iface_modem_simple_get_type (void); -G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMIfaceModemSimple, g_object_unref) - /* Initialize Modem Simple interface */ void mm_iface_modem_simple_initialize (MMIfaceModemSimple *self); |