diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-07-03 14:49:40 +0200 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2018-10-16 17:09:21 +0000 |
commit | 44413308b295bd52c1b24eba69bc8e9eed6b4fb5 (patch) | |
tree | bc33d93a8627a4d4725ba43fe3b4c71dd65c7717 /src | |
parent | fc0feee65481f7edf1118e8dd74a5352901f677f (diff) |
iface-modem-voice: always create plugin-specified call objects
The Voice interface logic must always use the create_call() object
from its own interface to create call objects, as that is the method
that plugins can subclass to provide plugin-specific call objects.
This applies to both incoming and outgoing calls.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-base-call.c | 42 | ||||
-rw-r--r-- | src/mm-base-call.h | 7 | ||||
-rw-r--r-- | src/mm-iface-modem-voice.c | 45 | ||||
-rw-r--r-- | src/mm-iface-modem-voice.h | 1 |
4 files changed, 40 insertions, 55 deletions
diff --git a/src/mm-base-call.c b/src/mm-base-call.c index a26b0768..b3c6aeb5 100644 --- a/src/mm-base-call.c +++ b/src/mm-base-call.c @@ -939,48 +939,6 @@ mm_base_call_new (MMBaseModem *modem) NULL)); } -MMBaseCall * -mm_base_call_new_from_properties (MMBaseModem *modem, - MMCallProperties *properties, - GError **error) -{ - MMBaseCall *self; - const gchar *number; - MMCallDirection direction; - - g_assert (MM_IS_IFACE_MODEM_VOICE (modem)); - - number = mm_call_properties_get_number (properties); - direction = mm_call_properties_get_direction (properties); - - /* Don't create CALL from properties if either number is missing */ - if (!number) { - g_set_error (error, - MM_CORE_ERROR, - MM_CORE_ERROR_INVALID_ARGS, - "Cannot create call: mandatory parameter 'number' is missing"); - return NULL; - } - - /* if no direction is specified force to outgoing */ - if (direction == MM_CALL_DIRECTION_UNKNOWN) - direction = MM_CALL_DIRECTION_OUTGOING; - - /* Create a call object as defined by the interface */ - self = mm_iface_modem_voice_create_call (MM_IFACE_MODEM_VOICE (modem)); - g_object_set (self, - "state", mm_call_properties_get_state (properties), - "state-reason", mm_call_properties_get_state_reason (properties), - "direction", direction, - "number", number, - NULL); - - /* Only export once properly created */ - mm_base_call_export (self); - - return self; -} - /*****************************************************************************/ static void diff --git a/src/mm-base-call.h b/src/mm-base-call.h index 5b8c06c6..9ae021ad 100644 --- a/src/mm-base-call.h +++ b/src/mm-base-call.h @@ -91,11 +91,8 @@ struct _MMBaseCallClass { GType mm_base_call_get_type (void); -/* This one can be overridden by plugins */ -MMBaseCall *mm_base_call_new (MMBaseModem *modem); -MMBaseCall *mm_base_call_new_from_properties (MMBaseModem *modem, - MMCallProperties *properties, - GError **error); +/* This one can be overriden by plugins */ +MMBaseCall *mm_base_call_new (MMBaseModem *modem); void mm_base_call_export (MMBaseCall *self); void mm_base_call_unexport (MMBaseCall *self); diff --git a/src/mm-iface-modem-voice.c b/src/mm-iface-modem-voice.c index de7ead98..9c15323d 100644 --- a/src/mm-iface-modem-voice.c +++ b/src/mm-iface-modem-voice.c @@ -38,14 +38,46 @@ mm_iface_modem_voice_bind_simple_status (MMIfaceModemVoice *self, /*****************************************************************************/ -MMBaseCall * -mm_iface_modem_voice_create_call (MMIfaceModemVoice *self) +static MMBaseCall * +create_call (MMIfaceModemVoice *self) { g_assert (MM_IFACE_MODEM_VOICE_GET_INTERFACE (self)->create_call != NULL); return MM_IFACE_MODEM_VOICE_GET_INTERFACE (self)->create_call (self); } +static MMBaseCall * +create_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 */ + number = mm_call_properties_get_number (properties) ; + if (!number) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Cannot create call: mandatory parameter 'number' is missing"); + return NULL; + } + + /* 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; +} + +/*****************************************************************************/ + void mm_iface_modem_voice_incoming_call (MMIfaceModemVoice *self) { @@ -71,7 +103,7 @@ mm_iface_modem_voice_incoming_call (MMIfaceModemVoice *self) } mm_dbg ("Creating new incoming call..."); - call = mm_base_call_new (MM_BASE_MODEM (self)); + call = create_call (self); g_object_set (call, "state", MM_CALL_STATE_RINGING_IN, "state-reason", MM_CALL_STATE_REASON_INCOMING_NEW, @@ -270,9 +302,7 @@ handle_create_auth_ready (MMBaseModem *self, return; } - call = mm_base_call_new_from_properties (MM_BASE_MODEM (self), - properties, - &error); + call = create_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); @@ -294,7 +324,8 @@ handle_create_auth_ready (MMBaseModem *self, return; } - /* Add it to the list */ + /* Only export once properly created */ + mm_base_call_export (call); mm_call_list_add_call (list, call); /* Complete the DBus call */ diff --git a/src/mm-iface-modem-voice.h b/src/mm-iface-modem-voice.h index 21278ff2..1c16a42b 100644 --- a/src/mm-iface-modem-voice.h +++ b/src/mm-iface-modem-voice.h @@ -117,7 +117,6 @@ void mm_iface_modem_voice_bind_simple_status (MMIfaceModemVoice *self, MMSimpleStatus *status); /* CALL creation */ -MMBaseCall *mm_iface_modem_voice_create_call (MMIfaceModemVoice *self); void mm_iface_modem_voice_incoming_call (MMIfaceModemVoice *self); gboolean mm_iface_modem_voice_update_incoming_call_number (MMIfaceModemVoice *self, gchar *number, |