diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-06-14 14:43:10 +0200 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2018-10-16 17:09:21 +0000 |
commit | 7c10db26c20cd39862059e08ddd237e6eeb406d0 (patch) | |
tree | 86f170ae6c2713f0d5ce0701b9cdd3793ae21f70 /src/mm-base-call.c | |
parent | cfdd6ffc95e611452281fc74bd403bdab9d2c79c (diff) |
base-call: setup/cleanup custom events when transitioning to/from in-call
Diffstat (limited to 'src/mm-base-call.c')
-rw-r--r-- | src/mm-base-call.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/mm-base-call.c b/src/mm-base-call.c index c28ce476..9e0673de 100644 --- a/src/mm-base-call.c +++ b/src/mm-base-call.c @@ -539,18 +539,42 @@ mm_base_call_get_path (MMBaseCall *self) return self->priv->path; } +/* Define the states in which we want to handle in-call events */ +#define MM_CALL_STATE_IS_IN_CALL(state) \ + (state == MM_CALL_STATE_DIALING || \ + state == MM_CALL_STATE_RINGING_OUT || \ + state == MM_CALL_STATE_ACTIVE) + void -mm_base_call_change_state (MMBaseCall *self, - MMCallState new_state, - MMCallStateReason reason) +mm_base_call_change_state (MMBaseCall *self, + MMCallState new_state, + MMCallStateReason reason) { - MMCallState old_state; + MMCallState old_state; + GError *error = NULL; old_state = mm_gdbus_call_get_state (MM_GDBUS_CALL (self)); if (old_state == new_state) return; + /* Setup/cleanup unsolicited events based on state transitions to/from ACTIVE */ + if (!MM_CALL_STATE_IS_IN_CALL (old_state) && MM_CALL_STATE_IS_IN_CALL (new_state)) { + mm_dbg ("Setting up in-call unsolicited events..."); + if (MM_BASE_CALL_GET_CLASS (self)->setup_unsolicited_events && + !MM_BASE_CALL_GET_CLASS (self)->setup_unsolicited_events (self, &error)) { + mm_warn ("Couldn't setup in-call unsolicited events: %s", error->message); + g_error_free (error); + } + } else if (MM_CALL_STATE_IS_IN_CALL (old_state) && !MM_CALL_STATE_IS_IN_CALL (new_state)) { + mm_dbg ("Cleaning up in-call unsolicited events..."); + if (MM_BASE_CALL_GET_CLASS (self)->cleanup_unsolicited_events && + !MM_BASE_CALL_GET_CLASS (self)->cleanup_unsolicited_events (self, &error)) { + mm_warn ("Couldn't cleanup in-call unsolicited events: %s", error->message); + g_error_free (error); + } + } + mm_gdbus_call_set_state (MM_GDBUS_CALL (self), new_state); mm_gdbus_call_set_state_reason (MM_GDBUS_CALL (self), reason); mm_gdbus_call_emit_state_changed (MM_GDBUS_CALL (self), old_state, new_state, reason); |