diff options
author | Dan Williams <dan@ioncontrol.co> | 2025-04-19 10:30:58 -0500 |
---|---|---|
committer | Dan Williams <dan@ioncontrol.co> | 2025-05-08 20:24:37 -0500 |
commit | b81f23e24aad7d4fb37e837bbdcab4f43bccfc71 (patch) | |
tree | 2750873e396cc0176926f4deca31bc6fa835044a /src/mm-iface-modem-messaging.c | |
parent | 9830e3955a3e45ff82c1c76bcba3b53432eaa51e (diff) |
base-sms,sms-list,iface-messaging: move MMBaseSms creation to MMBroadbandModem class
This commit moves creation of the MMBaseSms objects out of MMSmsList and up
into MMIfaceModemMessaging (which is already a MMBroadbandModem) and
the MMBroadbandModem subclasses themselves.
This flattens the creation of MMBaseSms objects by passing them down
from the object that creates the SMS parts, rather than having a
convoluted callback scheme relying on MMSmsList and MMBaseSms having
direct knowledge of their owning modem.
The goal is to eventually remove usage of MMBaseModem from MMBaseSms
and MMSmsList so that we can test them more easily.
Signed-off-by: Dan Williams <dan@ioncontrol.co>
Diffstat (limited to 'src/mm-iface-modem-messaging.c')
-rw-r--r-- | src/mm-iface-modem-messaging.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/mm-iface-modem-messaging.c b/src/mm-iface-modem-messaging.c index ef6b546c..51c8b24e 100644 --- a/src/mm-iface-modem-messaging.c +++ b/src/mm-iface-modem-messaging.c @@ -22,6 +22,7 @@ #include "mm-sms-list.h" #include "mm-error-helpers.h" #include "mm-log-object.h" +#include "mm-broadband-modem.h" #define SUPPORT_CHECKED_TAG "messaging-support-checked-tag" #define SUPPORTED_TAG "messaging-supported-tag" @@ -91,16 +92,6 @@ mm_iface_modem_messaging_bind_simple_status (MMIfaceModemMessaging *self, /*****************************************************************************/ -MMBaseSms * -mm_iface_modem_messaging_create_sms (MMIfaceModemMessaging *self) -{ - g_assert (MM_IFACE_MODEM_MESSAGING_GET_IFACE (self)->create_sms != NULL); - - return MM_IFACE_MODEM_MESSAGING_GET_IFACE (self)->create_sms (self); -} - -/*****************************************************************************/ - void mm_iface_modem_messaging_lock_storages (MMIfaceModemMessaging *self, MMSmsStorage mem1, @@ -339,8 +330,8 @@ handle_create_auth_ready (MMIfaceAuth *auth, return; } - sms = mm_base_sms_new_from_properties (MM_BASE_MODEM (self), properties, &error); - if (!sms) { + sms = mm_broadband_modem_create_sms (MM_BROADBAND_MODEM (self)); + if (!mm_base_sms_init_from_properties (sms, MM_BASE_MODEM (self), properties, &error)) { mm_dbus_method_invocation_take_error (ctx->invocation, error); handle_create_context_free (ctx); return; @@ -525,13 +516,14 @@ handle_set_default_storage (MmGdbusModemMessaging *skeleton, /*****************************************************************************/ gboolean -mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self, - MMSmsPart *sms_part, - MMSmsState state, - MMSmsStorage storage) +mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self, + MMBaseSms *uninitialized_sms, + MMSmsPart *sms_part, + MMSmsState state, + MMSmsStorage storage, + GError **error) { g_autoptr(MMSmsList) list = NULL; - g_autoptr(GError) error = NULL; gboolean added = FALSE; g_object_get (self, @@ -539,15 +531,20 @@ mm_iface_modem_messaging_take_part (MMIfaceModemMessaging *self, NULL); if (list) { - added = mm_sms_list_take_part (list, sms_part, state, storage, &error); + added = mm_sms_list_take_part (list, uninitialized_sms, sms_part, state, storage, error); if (!added) - mm_obj_dbg (self, "couldn't take part in SMS list: %s", error->message); + g_prefix_error (error, "couldn't take part in SMS list: "); } - /* If part wasn't taken, we need to free the part ourselves */ + /* If part wasn't taken, we need to free the part and SMS ourselves */ if (!added) mm_sms_part_free (sms_part); + /* Always drop original ref to the uninialized SMS, as MMSmsList will have + * taken a reference to the SMS if it wants to keep it around. + */ + g_object_unref (uninitialized_sms); + return added; } |