aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2024-04-18 09:48:36 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2024-05-06 13:27:04 +0000
commit9aab129759ce9f9c713b88049a0fb32b43b0adf9 (patch)
treec17d4404fd9d2f0d04d4afe1b00f0e9bf92ffb4d /src
parent1e26e16168d4815a48ab77610e1c282dfc345567 (diff)
iface-port-at: use G_DECLARE|DEFINE_INTERFACE() macros
Diffstat (limited to 'src')
-rw-r--r--src/mm-iface-port-at.c56
-rw-r--r--src/mm-iface-port-at.h13
-rw-r--r--src/mm-port-serial-at.c4
-rw-r--r--src/plugins/fibocom/mm-port-mbim-fibocom.c4
4 files changed, 25 insertions, 52 deletions
diff --git a/src/mm-iface-port-at.c b/src/mm-iface-port-at.c
index 4a21cd9f..28748096 100644
--- a/src/mm-iface-port-at.c
+++ b/src/mm-iface-port-at.c
@@ -17,10 +17,11 @@
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
-#include "mm-port.h"
#include "mm-iface-port-at.h"
#include "mm-log-object.h"
+G_DEFINE_INTERFACE (MMIfacePortAt, mm_iface_port_at, MM_TYPE_PORT)
+
/*****************************************************************************/
gboolean
@@ -32,12 +33,12 @@ mm_iface_port_at_check_support (MMIfacePortAt *self,
/* If the object implementing the interface doesn't provide a check_support() method,
* we assume the feature is unconditionally supported. */
- if (!MM_IFACE_PORT_AT_GET_INTERFACE (self)->check_support) {
+ if (!MM_IFACE_PORT_AT_GET_IFACE (self)->check_support) {
*out_supported = TRUE;
return TRUE;
}
- return MM_IFACE_PORT_AT_GET_INTERFACE (self)->check_support (self, out_supported, error);
+ return MM_IFACE_PORT_AT_GET_IFACE (self)->check_support (self, out_supported, error);
}
/*****************************************************************************/
@@ -47,7 +48,7 @@ mm_iface_port_at_command_finish (MMIfacePortAt *self,
GAsyncResult *res,
GError **error)
{
- return MM_IFACE_PORT_AT_GET_INTERFACE (self)->command_finish (self, res, error);
+ return MM_IFACE_PORT_AT_GET_IFACE (self)->command_finish (self, res, error);
}
void
@@ -60,45 +61,22 @@ mm_iface_port_at_command (MMIfacePortAt *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- g_assert (MM_IFACE_PORT_AT_GET_INTERFACE (self)->command);
- g_assert (MM_IFACE_PORT_AT_GET_INTERFACE (self)->command_finish);
-
- MM_IFACE_PORT_AT_GET_INTERFACE (self)->command (self,
- command,
- timeout_seconds,
- is_raw,
- allow_cached,
- cancellable,
- callback,
- user_data);
+ g_assert (MM_IFACE_PORT_AT_GET_IFACE (self)->command);
+ g_assert (MM_IFACE_PORT_AT_GET_IFACE (self)->command_finish);
+
+ MM_IFACE_PORT_AT_GET_IFACE (self)->command (self,
+ command,
+ timeout_seconds,
+ is_raw,
+ allow_cached,
+ cancellable,
+ callback,
+ user_data);
}
/*****************************************************************************/
static void
-iface_port_at_init (gpointer g_iface)
-{
-}
-
-GType
-mm_iface_port_at_get_type (void)
+mm_iface_port_at_default_init (MMIfacePortAtInterface *iface)
{
- static GType iface_port_at_type = 0;
-
- if (!G_UNLIKELY (iface_port_at_type)) {
- static const GTypeInfo info = {
- sizeof (MMIfacePortAt), /* class_size */
- iface_port_at_init, /* base_init */
- NULL, /* base_finalize */
- };
-
- iface_port_at_type = g_type_register_static (G_TYPE_INTERFACE,
- "MMIfacePortAt",
- &info,
- 0);
-
- g_type_interface_add_prerequisite (iface_port_at_type, MM_TYPE_PORT);
- }
-
- return iface_port_at_type;
}
diff --git a/src/mm-iface-port-at.h b/src/mm-iface-port-at.h
index afcc86dc..e360af17 100644
--- a/src/mm-iface-port-at.h
+++ b/src/mm-iface-port-at.h
@@ -22,14 +22,12 @@
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
-#define MM_TYPE_IFACE_PORT_AT (mm_iface_port_at_get_type ())
-#define MM_IFACE_PORT_AT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_IFACE_PORT_AT, MMIfacePortAt))
-#define MM_IS_IFACE_PORT_AT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_IFACE_PORT_AT))
-#define MM_IFACE_PORT_AT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_IFACE_PORT_AT, MMIfacePortAt))
+#include "mm-port.h"
-typedef struct _MMIfacePortAt MMIfacePortAt;
+#define MM_TYPE_IFACE_PORT_AT mm_iface_port_at_get_type ()
+G_DECLARE_INTERFACE (MMIfacePortAt, mm_iface_port_at, MM, IFACE_PORT_AT, MMPort)
-struct _MMIfacePortAt {
+struct _MMIfacePortAtInterface {
GTypeInterface g_iface;
gboolean (* check_support) (MMIfacePortAt *self,
@@ -49,9 +47,6 @@ struct _MMIfacePortAt {
GError **error);
};
-GType mm_iface_port_at_get_type (void);
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMIfacePortAt, g_object_unref)
-
gboolean mm_iface_port_at_check_support (MMIfacePortAt *self,
gboolean *out_supported,
GError **error);
diff --git a/src/mm-port-serial-at.c b/src/mm-port-serial-at.c
index bb714ece..0130b62d 100644
--- a/src/mm-port-serial-at.c
+++ b/src/mm-port-serial-at.c
@@ -25,7 +25,7 @@
#include "mm-port-serial-at.h"
#include "mm-log-object.h"
-static void iface_port_at_init (MMIfacePortAt *iface);
+static void iface_port_at_init (MMIfacePortAtInterface *iface);
G_DEFINE_TYPE_EXTENDED (MMPortSerialAt, mm_port_serial_at, MM_TYPE_PORT_SERIAL, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_PORT_AT, iface_port_at_init))
@@ -625,7 +625,7 @@ finalize (GObject *object)
}
static void
-iface_port_at_init (MMIfacePortAt *iface)
+iface_port_at_init (MMIfacePortAtInterface *iface)
{
iface->check_support = NULL;
iface->command = iface_port_at_command;
diff --git a/src/plugins/fibocom/mm-port-mbim-fibocom.c b/src/plugins/fibocom/mm-port-mbim-fibocom.c
index e7d26ed0..76957064 100644
--- a/src/plugins/fibocom/mm-port-mbim-fibocom.c
+++ b/src/plugins/fibocom/mm-port-mbim-fibocom.c
@@ -26,7 +26,7 @@
#include "mm-port-mbim-fibocom.h"
#include "mm-log-object.h"
-static void iface_port_at_init (MMIfacePortAt *iface);
+static void iface_port_at_init (MMIfacePortAtInterface *iface);
G_DEFINE_TYPE_EXTENDED (MMPortMbimFibocom, mm_port_mbim_fibocom, MM_TYPE_PORT_MBIM, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_PORT_AT, iface_port_at_init))
@@ -260,7 +260,7 @@ finalize (GObject *object)
}
static void
-iface_port_at_init (MMIfacePortAt *iface)
+iface_port_at_init (MMIfacePortAtInterface *iface)
{
iface->check_support = iface_port_at_check_support;
iface->command = iface_port_at_command;