Immediate digit response
v2 cover Immediate digit response
Introduce a new STK method to get digit response on single key press. This method asks to not display the entered digit and does not accept the character '+'.
Philippe Nunes (4):
doc: Add new STK Agent API to get digit response on single key press
stkagent: Add new API to get digit response on single key press
stk: Ask for immediate digit response if specified by command
qualifier
test: Update with RequestQuickDigit API
doc/stk-api.txt | 9 +++++++++ src/stk.c | 9 +++++++-- src/stkagent.c | 32 ++++++++++++++++++++++++++++++++ src/stkagent.h | 5 +++++ test/test-stk-menu | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v2 1/4 doc: Add new STK Agent API to get digit response on single key press
--- doc/stk-api.txt | 9 +++++++++ 1 file changed, 9 insertions(+)
doc/stk-api.txt +9 -0
@@ -193,6 +193,15 @@ Methods byte RequestSelection(string title, byte icon_id, Possible Errors: [service].Error.SimToolkit.GoBack [service].Error.SimToolkit.EndSession + string RequestQuickDigit(string alpha, byte icon_id) + + Same as above but the entered digit shall not be + displayed and the response shall be sent immediately + after the key press. "+" is not allowed for user input. + + Possible Errors: [service].Error.SimToolkit.GoBack + [service].Error.SimToolkit.EndSession + boolean RequestConfirmation(string alpha, byte icon_id) Asks the agent to get confirmation from the user.
Signature · 1 line
1.7.9.5
Denis Kenzior
AppliedRe: [PATCH v2 1/4] doc: Add new STK Agent API to get digit response on single key press
Hi Philippe,
Quoted 4 lines · Philippe Nunes
--- doc/stk-api.txt | 9 +++++++++ 1 file changed, 9 insertions(+)
I applied this patch, after having to manually fix trailing whitespace errors.
Regards,
-Denis
PATCH v2 2/4 stkagent: Add new API to get digit response on single key press
In reply to Philippe Nunes--- src/stkagent.c | 32 ++++++++++++++++++++++++++++++++ src/stkagent.h | 5 +++++ 2 files changed, 37 insertions(+)
src/stkagent.c +32 -0
@@ -584,6 +584,38 @@ int stk_agent_request_digit(struct stk_agent *agent, const char *text,return 0 ; } +int stk_agent_request_quick_digit (struct stk_agent *agent,const char *text, +const struct stk_icon_id *icon, +stk_agent_string_cb cb,void *user_data, +ofono_destroy_func destroy,int timeout) +{ +DBusConnection *conn =ofono_dbus_get_connection (); + + agent->msg =dbus_message_new_method_call (agent->bus, agent->path, +OFONO_SIM_APP_INTERFACE , +"RequestQuickDigit" ); +if (agent->msg ==NULL ) +return -ENOMEM ; + +dbus_message_append_args (agent->msg, +DBUS_TYPE_STRING , &text, +DBUS_TYPE_BYTE , &icon->id, +DBUS_TYPE_INVALID ); + +if (dbus_connection_send_with_reply (conn, agent->msg, &agent->call, + timeout) == FALSE || + agent->call ==NULL ) +return -EIO ; + + agent->user_cb = cb; + agent->user_data = user_data; + agent->user_destroy = destroy; + +dbus_pending_call_set_notify (agent->call, get_digit_cb, agent,NULL ); + +return 0 ; +} +static void get_key_cb (DBusPendingCall *call,void *data) {struct stk_agent *agent = data;
src/stkagent.h +5 -0
@@ -102,6 +102,11 @@ int stk_agent_request_digit(struct stk_agent *agent, const char *text, stk_agent_string_cb cb, void *user_data, ofono_destroy_func destroy, int timeout); +int stk_agent_request_quick_digit (struct stk_agent *agent,const char *text, +const struct stk_icon_id *icon, +stk_agent_string_cb cb,void *user_data, +ofono_destroy_func destroy,int timeout); + int stk_agent_request_key(struct stk_agent *agent, const char *text, const struct stk_icon_id *icon, ofono_bool_t unicode_charset,
Signature · 1 line
1.7.9.5
Re: [PATCH v2 2/4] stkagent: Add new API to get digit response on single key press
Hi Philippe,
Quoted 5 lines · Philippe Nunes
--- src/stkagent.c | 32 ++++++++++++++++++++++++++++++++ src/stkagent.h | 5 +++++ 2 files changed, 37 insertions(+)
Patch has been applied, however...
src/stkagent.c int stk_agent_request_digit(struct stk_agent *agent, const char *text, · line 590
Quoted 12 lines
src/stkagent.c +4
-0@@ -584,6 +584,38 @@ int stk_agent_request_digit(struct stk_agent *agent, const char *text,return 0 ; } +int stk_agent_request_quick_digit (struct stk_agent *agent,const char *text, +const struct stk_icon_id *icon, +stk_agent_string_cb cb,void *user_data, +ofono_destroy_func destroy,int timeout)
The indentation is not in line with the coding standard item M4. I amended this patch manually here and...
Quoted 36 lines
src/stkagent.c +28
-0+{ +DBusConnection *conn =ofono_dbus_get_connection (); + + agent->msg =dbus_message_new_method_call (agent->bus, agent->path, +OFONO_SIM_APP_INTERFACE , +"RequestQuickDigit" ); +if (agent->msg ==NULL ) +return -ENOMEM ; + +dbus_message_append_args (agent->msg, +DBUS_TYPE_STRING ,&text, +DBUS_TYPE_BYTE ,&icon->id, +DBUS_TYPE_INVALID ); + +if (dbus_connection_send_with_reply (conn, agent->msg,&agent->call, + timeout) == FALSE || + agent->call ==NULL ) +return -EIO ; + + agent->user_cb = cb; + agent->user_data = user_data; + agent->user_destroy = destroy; + +dbus_pending_call_set_notify (agent->call, get_digit_cb, agent,NULL ); + +return 0 ; +} +static void get_key_cb (DBusPendingCall *call,void *data) {struct stk_agent *agent = data;src/stkagent.h +0
-0
src/stkagent.h int stk_agent_request_digit(struct stk_agent *agent, const char *text, · line 109
Quoted 8 lines
src/stkagent.h +5
-0@@ -102,6 +102,11 @@ int stk_agent_request_digit(struct stk_agent *agent, const char *text, stk_agent_string_cb cb, void *user_data, ofono_destroy_func destroy, int timeout); +int stk_agent_request_quick_digit (struct stk_agent *agent,const char *text, +const struct stk_icon_id *icon, +stk_agent_string_cb cb,void *user_data, +ofono_destroy_func destroy,int timeout); +
here
src/stkagent.h int stk_agent_request_digit(struct stk_agent *agent, const char *text, · line 112
Quoted 3 lines
src/stkagent.h +0
-0int stk_agent_request_key(struct stk_agent *agent, const char *text, const struct stk_icon_id *icon, ofono_bool_t unicode_charset,
Regards,
-Denis
PATCH v2 3/4 stk: Ask for immediate digit response if specified by command qualifier
In reply to Philippe Nunes--- src/stk.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
src/stk.c +7 -2
@@ -1519,9 +1519,9 @@ static gboolean handle_command_get_inkey(const struct stk_command *cmd,gboolean alphabet = (qualifier & (1 <<0 )) !=0 ;gboolean ucs2 = (qualifier & (1 <<1 )) !=0 ;gboolean yesno = (qualifier & (1 <<2 )) !=0 ; +gboolean immediate = (qualifier & (1 <<3 )) !=0 ;/* -* Note: immediate response and help parameter values are not -* provided by current api. +* Note: help parameter value is not provided by current api. */ int err;
@@ -1545,6 +1545,11 @@ static gboolean handle_command_get_inkey(const struct stk_command *cmd, &gi->icon_id, ucs2, request_key_cb, stk,NULL , timeout); + else if (immediate) + err =stk_agent_request_quick_digit (stk->current_agent, + text, &gi->icon_id, + request_key_cb, stk, +NULL , timeout); else err = stk_agent_request_digit(stk->current_agent, text, &gi->icon_id, request_key_cb,
Signature · 1 line
1.7.9.5
Re: [PATCH v2 3/4] stk: Ask for immediate digit response if specified by command qualifier
Hi Philippe,
Quoted 4 lines · Philippe Nunes
--- src/stk.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
Patch has been applied, thanks.
Regards,
-Denis
PATCH v2 4/4 test: Update with RequestQuickDigit API
In reply to Philippe Nunes--- test/test-stk-menu | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
test/test-stk-menu +37 -0
@@ -7,6 +7,27 @@ import dbus import dbus.service import dbus.mainloop.glib + + +class _GetchUnix: + def __init__(self): + import tty, sys + + def __call__(self): + import sys, tty, termios + fd = sys.stdin.fileno() + old_settings = termios.tcgetattr(fd) + try: + tty.setraw(sys.stdin.fileno()) + ch = sys.stdin.read(1) + finally: + termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) + return ch + + +getch = _GetchUnix() + + class GoBack(dbus.DBusException): _dbus_error_name = "org.ofono.Error.GoBack"
@@ -127,6 +148,22 @@ class StkAgent(dbus.service.Object): return key @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="sy", out_signature="s") + def RequestQuickDigit(self, title, icon): + print "Title: (%s)" % (title) + print "Icon: (%d)" % (icon) + print "Single key press (t, b, 0-9,*,#)" + key = getch(); + + if key == 'b': + raise GoBack("User wishes to go back"); + elif key == 't': + raise EndSession("User wishes to terminate session"); + else: + print "." + return key + + @dbus.service.method("org.ofono.SimToolkitAgent", in_signature="sy", out_signature="b") def RequestConfirmation(self, title, icon): print "Title: (%s)" % (title)
Signature · 1 line
1.7.9.5
Re: [PATCH v2 4/4] test: Update with RequestQuickDigit API
Hi Philippe,
Quoted 4 lines · Philippe Nunes
--- test/test-stk-menu | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
Applying: test: Update with RequestQuickDigit API /home/denkenz/ofono-master/.git/rebase-apply/patch:45: trailing whitespace.
print "Single key press (t, b, 0-9,*,#)" /home/denkenz/ofono-master/.git/rebase-apply/patch:53: trailing whitespace. print "."
fatal: 2 lines add whitespace errors.
Patch failed at 0001 test: Update with RequestQuickDigit API
test/test-stk-menu import dbus · line 11
Quoted 10 lines
test/test-stk-menu +2
-0@@ -7,6 +7,27 @@ import dbus import dbus.service import dbus.mainloop.glib + +
Why double empty line?
Quoted 9 lines
test/test-stk-menu +9
-0+class _GetchUnix: + def __init__(self): + import tty, sys + + def __call__(self): + import sys, tty, termios + fd = sys.stdin.fileno() + old_settings = termios.tcgetattr(fd) + try:
test/test-stk-menu import dbus · line 30
Quoted 10 lines
test/test-stk-menu +10
-0+ tty.setraw(sys.stdin.fileno()) + ch = sys.stdin.read(1) + finally: + termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) + return ch + + +getch = _GetchUnix() + +
And again?
Also, are you sure we need to go this complicated. We already ignore 'hide_typing' elsewhere...
Quoted 16 lines
test/test-stk-menu +9
-0class GoBack(dbus.DBusException): _dbus_error_name = "org.ofono.Error.GoBack"@@ -127,6 +148,22 @@ class StkAgent(dbus.service.Object): return key @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="sy", out_signature="s") + def RequestQuickDigit(self, title, icon): + print "Title: (%s)" % (title) + print "Icon: (%d)" % (icon) + print "Single key press (t, b, 0-9,*,#)" + key = getch(); + + if key == 'b': + raise GoBack("User wishes to go back");
test/test-stk-menu class StkAgent(dbus.service.Object): · line 169
Quoted 10 lines
test/test-stk-menu +7
-0+ elif key == 't': + raise EndSession("User wishes to terminate session"); + else: + print "." + return key + + @dbus.service.method("org.ofono.SimToolkitAgent", in_signature="sy", out_signature="b") def RequestConfirmation(self, title, icon): print "Title: (%s)" % (title)
Regards,
-Denis