mm-iface-mode: provide direction and number when creating calls
Calls created from property bundles are always outgoing, while calls created as input events from URCs during runtime are always incoming. This change makes it mandatory to provide at least direction of the call when the object is created, leaving the number as an optional property that may or may not be known in advance (e.g. it would be optional only for incoming calls).
This commit is contained in:
committed by
Dan Williams
parent
44413308b2
commit
887376fe44
@@ -2987,10 +2987,12 @@ modem_voice_disable_unsolicited_events (MMIfaceModemVoice *self,
|
||||
/* Create call (Voice interface) */
|
||||
|
||||
static MMBaseCall *
|
||||
create_call (MMIfaceModemVoice *self)
|
||||
create_call (MMIfaceModemVoice *self,
|
||||
MMCallDirection direction,
|
||||
const gchar *number)
|
||||
{
|
||||
/* New Huawei Call */
|
||||
return mm_call_huawei_new (MM_BASE_MODEM (self));
|
||||
return mm_call_huawei_new (MM_BASE_MODEM (self), direction, number);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -201,10 +201,14 @@ cleanup_unsolicited_events (MMBaseCall *self,
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBaseCall *
|
||||
mm_call_huawei_new (MMBaseModem *modem)
|
||||
mm_call_huawei_new (MMBaseModem *modem,
|
||||
MMCallDirection direction,
|
||||
const gchar *number)
|
||||
{
|
||||
return MM_BASE_CALL (g_object_new (MM_TYPE_CALL_HUAWEI,
|
||||
MM_BASE_CALL_MODEM, modem,
|
||||
"direction", direction,
|
||||
"number", number,
|
||||
MM_BASE_CALL_SUPPORTS_DIALING_TO_RINGING, TRUE,
|
||||
MM_BASE_CALL_SUPPORTS_RINGING_TO_ACTIVE, TRUE,
|
||||
NULL));
|
||||
|
||||
@@ -43,6 +43,8 @@ struct _MMCallHuaweiClass {
|
||||
|
||||
GType mm_call_huawei_get_type (void);
|
||||
|
||||
MMBaseCall *mm_call_huawei_new (MMBaseModem *modem);
|
||||
MMBaseCall *mm_call_huawei_new (MMBaseModem *modem,
|
||||
MMCallDirection direction,
|
||||
const gchar *number);
|
||||
|
||||
#endif /* MM_CALL_HUAWEI_H */
|
||||
|
||||
+5
-1
@@ -932,10 +932,14 @@ call_send_dtmf (MMBaseCall *self,
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBaseCall *
|
||||
mm_base_call_new (MMBaseModem *modem)
|
||||
mm_base_call_new (MMBaseModem *modem,
|
||||
MMCallDirection direction,
|
||||
const gchar *number)
|
||||
{
|
||||
return MM_BASE_CALL (g_object_new (MM_TYPE_BASE_CALL,
|
||||
MM_BASE_CALL_MODEM, modem,
|
||||
"direction", direction,
|
||||
"number", number,
|
||||
NULL));
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -92,7 +92,9 @@ struct _MMBaseCallClass {
|
||||
GType mm_base_call_get_type (void);
|
||||
|
||||
/* This one can be overriden by plugins */
|
||||
MMBaseCall *mm_base_call_new (MMBaseModem *modem);
|
||||
MMBaseCall *mm_base_call_new (MMBaseModem *modem,
|
||||
MMCallDirection direction,
|
||||
const gchar *number);
|
||||
|
||||
void mm_base_call_export (MMBaseCall *self);
|
||||
void mm_base_call_unexport (MMBaseCall *self);
|
||||
|
||||
@@ -7115,9 +7115,11 @@ modem_voice_enable_unsolicited_events (MMIfaceModemVoice *self,
|
||||
/* Create CALL (Voice interface) */
|
||||
|
||||
static MMBaseCall *
|
||||
modem_voice_create_call (MMIfaceModemVoice *self)
|
||||
modem_voice_create_call (MMIfaceModemVoice *self,
|
||||
MMCallDirection direction,
|
||||
const gchar *number)
|
||||
{
|
||||
return mm_base_call_new (MM_BASE_MODEM (self));
|
||||
return mm_base_call_new (MM_BASE_MODEM (self), direction, number);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
+11
-19
@@ -39,19 +39,19 @@ mm_iface_modem_voice_bind_simple_status (MMIfaceModemVoice *self,
|
||||
/*****************************************************************************/
|
||||
|
||||
static MMBaseCall *
|
||||
create_call (MMIfaceModemVoice *self)
|
||||
create_incoming_call (MMIfaceModemVoice *self,
|
||||
const gchar *number)
|
||||
{
|
||||
g_assert (MM_IFACE_MODEM_VOICE_GET_INTERFACE (self)->create_call != NULL);
|
||||
|
||||
return MM_IFACE_MODEM_VOICE_GET_INTERFACE (self)->create_call (self);
|
||||
return MM_IFACE_MODEM_VOICE_GET_INTERFACE (self)->create_call (self, MM_CALL_DIRECTION_INCOMING, number);
|
||||
}
|
||||
|
||||
static MMBaseCall *
|
||||
create_call_from_properties (MMIfaceModemVoice *self,
|
||||
MMCallProperties *properties,
|
||||
GError **error)
|
||||
create_outgoing_call_from_properties (MMIfaceModemVoice *self,
|
||||
MMCallProperties *properties,
|
||||
GError **error)
|
||||
{
|
||||
MMBaseCall *call;
|
||||
const gchar *number;
|
||||
|
||||
/* Don't create CALL from properties if either number is missing */
|
||||
@@ -66,14 +66,7 @@ create_call_from_properties (MMIfaceModemVoice *self,
|
||||
|
||||
/* Create a call object as defined by the interface */
|
||||
g_assert (MM_IFACE_MODEM_VOICE_GET_INTERFACE (self)->create_call != NULL);
|
||||
call = MM_IFACE_MODEM_VOICE_GET_INTERFACE (self)->create_call (self);
|
||||
g_object_set (call,
|
||||
"state", mm_call_properties_get_state (properties),
|
||||
"state-reason", mm_call_properties_get_state_reason (properties),
|
||||
"direction", mm_call_properties_get_direction (properties),
|
||||
"number", number,
|
||||
NULL);
|
||||
return call;
|
||||
return MM_IFACE_MODEM_VOICE_GET_INTERFACE (self)->create_call (self, MM_CALL_DIRECTION_OUTGOING, number);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -103,11 +96,10 @@ mm_iface_modem_voice_incoming_call (MMIfaceModemVoice *self)
|
||||
}
|
||||
|
||||
mm_dbg ("Creating new incoming call...");
|
||||
call = create_call (self);
|
||||
call = create_incoming_call (self, NULL);
|
||||
g_object_set (call,
|
||||
"state", MM_CALL_STATE_RINGING_IN,
|
||||
"state-reason", MM_CALL_STATE_REASON_INCOMING_NEW,
|
||||
"direction", MM_CALL_DIRECTION_INCOMING,
|
||||
"state", MM_CALL_STATE_RINGING_IN,
|
||||
"state-reason", MM_CALL_STATE_REASON_INCOMING_NEW,
|
||||
NULL);
|
||||
|
||||
/* Start its validity timeout */
|
||||
@@ -302,7 +294,7 @@ handle_create_auth_ready (MMBaseModem *self,
|
||||
return;
|
||||
}
|
||||
|
||||
call = create_call_from_properties (MM_IFACE_MODEM_VOICE (self), properties, &error);
|
||||
call = create_outgoing_call_from_properties (MM_IFACE_MODEM_VOICE (self), properties, &error);
|
||||
if (!call) {
|
||||
g_object_unref (properties);
|
||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||
|
||||
@@ -78,7 +78,9 @@ struct _MMIfaceModemVoice {
|
||||
GError **error);
|
||||
|
||||
/* Create CALL objects */
|
||||
MMBaseCall * (* create_call) (MMIfaceModemVoice *self);
|
||||
MMBaseCall * (* create_call) (MMIfaceModemVoice *self,
|
||||
MMCallDirection direction,
|
||||
const gchar *number);
|
||||
};
|
||||
|
||||
GType mm_iface_modem_voice_get_type (void);
|
||||
|
||||
Reference in New Issue
Block a user