base-call: setup/cleanup custom events when transitioning to/from in-call
This commit is contained in:

committed by
Dan Williams

parent
cfdd6ffc95
commit
7c10db26c2
@@ -539,18 +539,42 @@ mm_base_call_get_path (MMBaseCall *self)
|
|||||||
return self->priv->path;
|
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
|
void
|
||||||
mm_base_call_change_state (MMBaseCall *self,
|
mm_base_call_change_state (MMBaseCall *self,
|
||||||
MMCallState new_state,
|
MMCallState new_state,
|
||||||
MMCallStateReason reason)
|
MMCallStateReason reason)
|
||||||
{
|
{
|
||||||
MMCallState old_state;
|
MMCallState old_state;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
old_state = mm_gdbus_call_get_state (MM_GDBUS_CALL (self));
|
old_state = mm_gdbus_call_get_state (MM_GDBUS_CALL (self));
|
||||||
|
|
||||||
if (old_state == new_state)
|
if (old_state == new_state)
|
||||||
return;
|
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 (MM_GDBUS_CALL (self), new_state);
|
||||||
mm_gdbus_call_set_state_reason (MM_GDBUS_CALL (self), reason);
|
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);
|
mm_gdbus_call_emit_state_changed (MM_GDBUS_CALL (self), old_state, new_state, reason);
|
||||||
|
@@ -79,6 +79,12 @@ struct _MMBaseCallClass {
|
|||||||
gboolean (* send_dtmf_finish) (MMBaseCall *self,
|
gboolean (* send_dtmf_finish) (MMBaseCall *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
/* Setup/cleanup in-call unsolicited events */
|
||||||
|
gboolean (* setup_unsolicited_events) (MMBaseCall *self,
|
||||||
|
GError **error);
|
||||||
|
gboolean (* cleanup_unsolicited_events) (MMBaseCall *self,
|
||||||
|
GError **error);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType mm_base_call_get_type (void);
|
GType mm_base_call_get_type (void);
|
||||||
|
Reference in New Issue
Block a user