diff options
author | Dylan Van Assche <me@dylanvanassche.be> | 2021-05-01 15:53:55 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-05-26 13:14:52 +0000 |
commit | 41db2e5e820f222ce36b6fd228054642edfb4746 (patch) | |
tree | 10e477400be6f80893aba00c03469961c9e2aee3 /src/mm-broadband-modem.c | |
parent | e58d525826c7693a6c2cf3a31485b62d870e59d2 (diff) |
iface-modem-time: synchronize state when resuming
On resume, fetch the current network time as
the network time may be changed when suspended.
Diffstat (limited to 'src/mm-broadband-modem.c')
-rw-r--r-- | src/mm-broadband-modem.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index 3466e833..4827c283 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -11943,6 +11943,7 @@ enable (MMBaseModem *self, typedef enum { SYNCING_STEP_FIRST, + SYNCING_STEP_IFACE_TIME, SYNCING_STEP_LAST, } SyncingStep; @@ -11950,6 +11951,8 @@ typedef struct { SyncingStep step; } SyncingContext; +static void syncing_step (GTask *task); + static gboolean synchronize_finish (MMBaseModem *self, GAsyncResult *res, @@ -11959,6 +11962,24 @@ synchronize_finish (MMBaseModem *self, } static void +iface_modem_time_sync_ready (MMIfaceModemTime *self, + GAsyncResult *res, + GTask *task) +{ + SyncingContext *ctx; + g_autoptr(GError) error = NULL; + + ctx = g_task_get_task_data (task); + + if (!mm_iface_modem_time_sync_finish (self, res, &error)) + mm_obj_warn (self, "time interface synchronization failed: %s", error->message); + + /* Go on to next step */ + ctx->step++; + syncing_step (task); +} + +static void syncing_step (GTask *task) { MMBroadbandModem *self; @@ -11972,6 +11993,15 @@ syncing_step (GTask *task) ctx->step++; /* fall through */ + case SYNCING_STEP_IFACE_TIME: + /* + * Synchronize asynchronously the Time interface. + */ + mm_obj_info (self, "resume synchronization state (%d/%d): time interface sync", + ctx->step, SYNCING_STEP_LAST); + mm_iface_modem_time_sync (MM_IFACE_MODEM_TIME (self), (GAsyncReadyCallback)iface_modem_time_sync_ready, task); + return; + case SYNCING_STEP_LAST: mm_obj_info (self, "resume synchronization state (%d/%d): all done", ctx->step, SYNCING_STEP_LAST); |