All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add air interface flash validation in CDMA voice call
@ 2011-08-16  7:39 Caiwen Zhang
  2011-08-18 19:01 ` Denis Kenzior
  0 siblings, 1 reply; 3+ messages in thread
From: Caiwen Zhang @ 2011-08-16  7:39 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1938 bytes --]

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;
+
+	len = strlen(str);
+	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);
+
 	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);
-- 
1.7.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-19  5:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-16  7:39 [PATCH] Add air interface flash validation in CDMA voice call Caiwen Zhang
2011-08-18 19:01 ` Denis Kenzior
2011-08-19  5:46   ` Zhang, Caiwen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.