Hi Caiwen,
On 08/16/2011 02:39 AM, Caiwen Zhang wrote:
> Check whether air interface flash is valid:
>
> 1. Air interface flash should be sent during a call
>
> 2. flash string may include feature code, digits (0-9) and end marks(*, #),
> along with any additional PIN information, called party number, etc.
> Generally, should be characters can be input in dialer.
>
> 3. flash without a string is allowed, it is used to switch call status.
>
> ---
> src/cdma-voicecall.c | 30 ++++++++++++++++++++++++++++++
> 1 files changed, 30 insertions(+), 0 deletions(-)
>
> diff --git a/src/cdma-voicecall.c b/src/cdma-voicecall.c
> index bbf805f..8de94c7 100644
> --- a/src/cdma-voicecall.c
> +++ b/src/cdma-voicecall.c
> @@ -307,6 +307,30 @@ static DBusMessage
> *voicecall_manager_answer(DBusConnection *conn,
> return NULL;
> }
>
> +static ofono_bool_t is_valid_flash_string(const char *str)
> +{
> + int len;
> + int i;
> +
> + /* flash string is empty, it is allowed */
> + if (str == NULL)
> + return TRUE;
NULL strings are not valid here, they can't be sent over D-Bus. Please
omit this check.
> +
> + len = strlen(str);
> + if (len == 0)
> + return TRUE;
> +
Please write this as:
int len = strlen(str);
int i;
if (len == 0)
return TRUE
...
> + for (i = 0; i < len; i++) {
> + if (g_ascii_isdigit(str[i]) || str[i] == '*' ||
> + str[i] == '#' || str[i] == '+')
> + continue;
> + else
> + return FALSE;
> + }
> +
> + return TRUE;
> +}
> +
> static DBusMessage *voicecall_manager_flash(DBusConnection *conn,
> DBusMessage *msg, void *data)
> {
> @@ -319,10 +343,16 @@ static DBusMessage
> *voicecall_manager_flash(DBusConnection *conn,
> if (vc->driver->send_flash == NULL)
> return __ofono_error_not_implemented(msg);
>
> + if (vc->status == CDMA_CALL_STATUS_DISCONNECTED)
> + return __ofono_error_failed(msg);
> +
Just to double check, can a flash be sent during
dialing/alerting/incoming stage?
> if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &string,
> DBUS_TYPE_INVALID) == FALSE)
> return __ofono_error_invalid_args(msg);
>
> + if (is_valid_flash_string(string) == FALSE)
> + return __ofono_error_invalid_args(msg);
> +
> vc->pending = dbus_message_ref(msg);
>
> vc->driver->send_flash(vc, string, generic_callback, vc);
Regards,
-Denis
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono