diff options
author | Pekka Pessi <Pekka.Pessi@nokia.com> | 2010-09-16 20:32:47 +0300 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-09-16 13:46:47 -0500 |
commit | 0d9473d8c8a35584de6e86854681082c5ba06fca (patch) | |
tree | aa544ec41b6ec8fb8cc26a701fff19ec253b985a /test | |
parent | 217c161cf5cdcbcdbd92542bbbe2a705ba35bf23 (diff) | |
download | ofono-0d9473d8c8a35584de6e86854681082c5ba06fca.tar.bz2 |
test-ussd: read stdin for Response()s
Diffstat (limited to 'test')
-rwxr-xr-x | test/test-ussd | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test-ussd b/test/test-ussd index 6e24de8e..d4c1e279 100755 --- a/test/test-ussd +++ b/test/test-ussd @@ -2,10 +2,13 @@ import sys import gobject +import os import dbus import dbus.mainloop.glib +state = None + def ussd_notification_received(content): print("Network sent a Notification: " + content) @@ -14,9 +17,23 @@ def ussd_request_received(content): ss.Cancel() def ussd_property_changed(name, value): + global state if name != "State": return print("USSD session state is " + value) + state = str(value) + +def stdin_handler(fd, condition): + s = os.read(fd.fileno(), 160).rstrip() + if not s: + ss.Cancel() + elif state == "user-response": + print ss.Respond(s, timeout = 100) + elif state == "idle": + print ss.Initiate(s, timeout = 100) + else: + print "Invalid state", state + return True if __name__ == "__main__": if (len(sys.argv) < 2): @@ -44,5 +61,7 @@ if __name__ == "__main__": print ss.Initiate(sys.argv[1], timeout=100) + gobject.io_add_watch(sys.stdin, gobject.IO_IN, stdin_handler) + mainloop = gobject.MainLoop() mainloop.run() |