From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 6/8] Add __ofono_ussd_initiate internal api for Sending USSD
Date: Tue, 14 Sep 2010 12:45:12 -0500 [thread overview]
Message-ID: <4C8FB4A8.9050303@gmail.com> (raw)
In-Reply-To: <1284418817-28575-7-git-send-email-jeevaka.badrappan@elektrobit.com>
[-- Attachment #1: Type: text/plain, Size: 5708 bytes --]
Hi Jeevaka,
On 09/13/2010 06:00 PM, Jeevaka Badrappan wrote:
> ---
> src/ofono.h | 7 +++++
> src/ussd.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 92 insertions(+), 1 deletions(-)
>
> diff --git a/src/ofono.h b/src/ofono.h
> index f1c0973..8ab6a2e 100644
> --- a/src/ofono.h
> +++ b/src/ofono.h
> @@ -258,6 +258,9 @@ typedef gboolean (*ofono_ussd_passwd_cb_t)(const char *sc,
> const char *old, const char *new,
> DBusMessage *msg, void *data);
>
> +typedef void (*ofono_ussd_request_cb_t)(int error, int dcs,
> + const unsigned char *pdu, int len, void *data);
> +
> gboolean __ofono_ussd_ssc_register(struct ofono_ussd *ussd, const char *sc,
> ofono_ussd_ssc_cb_t cb, void *data,
> ofono_destroy_func destroy);
> @@ -269,6 +272,10 @@ gboolean __ofono_ussd_passwd_register(struct ofono_ussd *ussd, const char *sc,
> void __ofono_ussd_passwd_unregister(struct ofono_ussd *ussd, const char *sc);
> gboolean __ofono_ussd_is_busy(struct ofono_ussd *ussd);
>
> +int __ofono_ussd_initiate(struct ofono_ussd *ussd, int dcs,
> + const unsigned char *pdu, int len,
> + ofono_ussd_request_cb_t cb, void *user_data);
> +
Do we need a cancel here as well? In case the SIM cancels the session.
> #include <ofono/netreg.h>
>
> typedef void (*ofono_netreg_status_notify_cb_t)(int status, int lac, int ci,
> diff --git a/src/ussd.c b/src/ussd.c
> index 8d9c98d..af0aae1 100644
> --- a/src/ussd.c
> +++ b/src/ussd.c
> @@ -49,6 +49,15 @@ enum ussd_state {
> USSD_STATE_RESPONSE_SENT,
> };
>
> +struct ussd_request {
> + struct ofono_ussd *ussd;
> + int dcs;
> + unsigned char *pdu;
> + int len;
> + ofono_ussd_request_cb_t cb;
> + void *user_data;
> +};
> +
> struct ofono_ussd {
> int state;
> DBusMessage *pending;
> @@ -59,6 +68,7 @@ struct ofono_ussd {
> const struct ofono_ussd_driver *driver;
> void *driver_data;
> struct ofono_atom *atom;
> + struct ussd_request *req;
> };
>
> struct ssc_entry {
> @@ -73,7 +83,7 @@ gboolean __ofono_ussd_is_busy(struct ofono_ussd *ussd)
> if (!ussd)
> return FALSE;
>
> - if (ussd->pending || ussd->state != USSD_STATE_IDLE)
> + if (ussd->pending || ussd->state != USSD_STATE_IDLE || ussd->req)
> return TRUE;
You might also want to make sure that initiate / respond / cancel cannot
interfere with the SIM request.
>
> return FALSE;
> @@ -320,6 +330,31 @@ static void ussd_change_state(struct ofono_ussd *ussd, int state)
> "State", DBUS_TYPE_STRING, &value);
> }
>
> +static void ussd_request_finish(struct ofono_ussd *ussd, int error, int dcs,
> + const unsigned char *pdu, int len)
> +{
> + struct ussd_request *req = ussd->req;
> +
> + if (req && req->cb) {
> + req->cb(error, dcs, pdu, len, req->user_data);
> + g_free(req->pdu);
> + g_free(req);
> + ussd->req = NULL;
What if req->cb is NULL?
> + }
> +}
> +
> +static int ussd_status_to_failure_code(int status)
> +{
> + switch (status) {
> + case OFONO_USSD_STATUS_TIMED_OUT:
> + return -ETIMEDOUT;
> + case OFONO_USSD_STATUS_NOT_SUPPORTED:
> + return -ENOSYS;
> + }
> +
> + return 0;
> +}
> +
> void ofono_ussd_notify(struct ofono_ussd *ussd, int status, int dcs,
> const unsigned char *data, int data_len)
> {
> @@ -332,6 +367,19 @@ void ofono_ussd_notify(struct ofono_ussd *ussd, int status, int dcs,
> DBusMessageIter iter;
> DBusMessageIter variant;
>
> + if (ussd->req &&
> + (status == OFONO_USSD_STATUS_NOTIFY ||
> + status == OFONO_USSD_STATUS_TERMINATED ||
> + status == OFONO_USSD_STATUS_TIMED_OUT ||
> + status == OFONO_USSD_STATUS_NOT_SUPPORTED)) {
> +
Please check coding style section M4
So what happens if the network sends a ACTION_REQUIRED as a response to
the STK ussd?
> + ussd_request_finish(ussd, ussd_status_to_failure_code(status),
> + dcs, data, data_len);
> +
> + ussd_change_state(ussd, USSD_STATE_IDLE);
> + return;
> + }
> +
> if (status == OFONO_USSD_STATUS_NOT_SUPPORTED) {
> ussd_change_state(ussd, USSD_STATE_IDLE);
>
> @@ -577,6 +625,9 @@ static void ussd_cancel_callback(const struct ofono_error *error, void *data)
> reply = dbus_message_new_method_return(ussd->cancel);
> __ofono_dbus_pending_reply(&ussd->cancel, reply);
>
> + if (ussd->req)
> + ussd_request_finish(ussd, -1, -ECANCELED, NULL, -1);
> +
> ussd_change_state(ussd, USSD_STATE_IDLE);
> }
>
> @@ -775,3 +826,36 @@ void *ofono_ussd_get_data(struct ofono_ussd *ussd)
> {
> return ussd->driver_data;
> }
> +
> +static void ussd_request_callback(const struct ofono_error *error, void *data)
> +{
> + struct ofono_ussd *ussd = data;
> +
> + if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
> + ussd_request_finish(ussd, error->error, -1, NULL, -1);
> + else
> + ussd_change_state(ussd,USSD_STATE_ACTIVE);
Missing space after the comma
> +}
> +
> +int __ofono_ussd_initiate(struct ofono_ussd *ussd, int dcs,
> + const unsigned char *pdu, int len,
> + ofono_ussd_request_cb_t cb, void *user_data)
> +{
> + struct ussd_request *req;
> +
You might want to check the busy condition here as well, just to be
pedantic. This is what voicecall_dial does...
> + if (!ussd->driver->request)
> + return -ENOSYS;
> +
> + req = g_try_new0(struct ussd_request, 1);
> + req->dcs = dcs;
> + req->pdu = g_memdup(pdu, len);
> + req->len = len;
> + req->cb = cb;
> + req->user_data = user_data;
> +
> + ussd->req = req;
> +
> + ussd->driver->request(ussd, dcs, pdu, len, ussd_request_callback, ussd);
> +
> + return 0;
> +}
Regards,
-Denis
next prev parent reply other threads:[~2010-09-14 17:45 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-09 12:31 Add support for Send USSD proactive command handling Jeevaka Badrappan
2010-09-09 12:31 ` [PATCH 01/12] atutil changes for parsing cscs query and cscs support Jeevaka Badrappan
2010-09-09 14:45 ` Denis Kenzior
2010-09-09 18:56 ` Jeevaka Badrappan
2010-09-09 18:56 ` [PATCH 01/13] " Jeevaka Badrappan
2010-09-10 17:27 ` Denis Kenzior
2010-09-09 12:31 ` [PATCH 02/12] atgen changes for setting TE character set Jeevaka Badrappan
2010-09-09 14:50 ` Denis Kenzior
2010-09-09 19:00 ` [PATCH 02/13] " Jeevaka Badrappan
2010-09-09 12:31 ` [PATCH 03/12] phonesim " Jeevaka Badrappan
2010-09-09 19:01 ` [PATCH 03/13] " Jeevaka Badrappan
2010-09-10 17:07 ` Denis Kenzior
2010-09-10 20:29 ` [PATCH 2/7] " Jeevaka Badrappan
2010-09-09 12:31 ` [PATCH 04/12] USSD atom driver changes to read current character setting Jeevaka Badrappan
2010-09-09 19:02 ` [PATCH 04/13] " Jeevaka Badrappan
2010-09-09 12:31 ` [PATCH 05/12] Add internal api __ofono_call_barring_is_busy Jeevaka Badrappan
2010-09-09 15:06 ` Denis Kenzior
2010-09-09 12:31 ` [PATCH 06/12] Add internal api __ofono_call_forwarding_is_busy Jeevaka Badrappan
2010-09-09 15:07 ` Denis Kenzior
2010-09-09 12:31 ` [PATCH 07/12] Add internal api __ofono_call_settings_is_busy Jeevaka Badrappan
2010-09-09 15:07 ` Denis Kenzior
2010-09-09 12:31 ` [PATCH 08/12] Add Send USSD command specific result codes Jeevaka Badrappan
2010-09-09 15:09 ` Denis Kenzior
2010-09-09 12:31 ` [PATCH 09/12] Add Send USSD terminal response data structures Jeevaka Badrappan
2010-09-09 15:20 ` Denis Kenzior
2010-09-09 12:31 ` [PATCH 10/12] Add build_dataobj_ussd_text for ussd specific text string handling Jeevaka Badrappan
2010-09-09 15:31 ` Denis Kenzior
2010-09-09 19:06 ` [PATCH 10/13] " Jeevaka Badrappan
2010-09-10 17:29 ` Denis Kenzior
2010-09-10 20:19 ` [PATCH 4/7] " Jeevaka Badrappan
2010-09-10 20:22 ` Denis Kenzior
2010-09-09 12:31 ` [PATCH 11/12] Internal and Driver api changes for Send USSD proactive command Jeevaka Badrappan
2010-09-09 15:59 ` Denis Kenzior
2010-09-09 20:25 ` [PATCH 6/8] " Jeevaka Badrappan
2010-09-09 20:25 ` [PATCH 7/8] Add __ofono_ussd_initiate internal api for Sending USSD Jeevaka Badrappan
2010-09-09 12:31 ` [PATCH 12/12] Handling of Send USSD proactive command Jeevaka Badrappan
2010-09-09 15:37 ` Denis Kenzior
2010-09-09 19:42 ` [PATCH 8/8] " Jeevaka Badrappan
2010-09-13 23:00 ` Added UCS2 handling and review comments incorporated Jeevaka Badrappan
2010-09-13 23:00 ` [PATCH 1/8] smsutil: Add USSD encoding function Jeevaka Badrappan
2010-09-13 23:00 ` [PATCH 2/8] util: Add UCS2 to GSM 7bit converion function Jeevaka Badrappan
2010-09-13 23:00 ` [PATCH 3/8] test-util: Add function for validating UCS2 to GSM bit conversion Jeevaka Badrappan
2010-09-13 23:00 ` [PATCH 4/8] USSD atom driver changes to read current character setting Jeevaka Badrappan
2010-09-13 23:00 ` [PATCH 5/8] Internal and Driver API changes for Send USSD Jeevaka Badrappan
2010-09-13 23:00 ` [PATCH 6/8] Add __ofono_ussd_initiate internal api for Sending USSD Jeevaka Badrappan
2010-09-13 23:00 ` [PATCH 7/8] stk: Handling of Send USSD proactive command Jeevaka Badrappan
2010-09-13 23:00 ` [PATCH 8/8] stkutil: Add handling of error case scenario in build USSD data object Jeevaka Badrappan
2010-09-14 21:49 ` [PATCH 3/4] stk: Handling of Send USSD proactive command Jeevaka Badrappan
2010-09-15 17:15 ` Denis Kenzior
2010-09-14 17:45 ` Denis Kenzior [this message]
2010-09-14 21:31 ` [PATCH 2/4] Add __ofono_ussd_initiate internal api for Sending USSD Jeevaka Badrappan
2010-09-15 17:13 ` Denis Kenzior
2010-09-14 17:24 ` [PATCH 5/8] Internal and Driver API changes for Send USSD Denis Kenzior
2010-09-14 21:23 ` [PATCH 1/4] " Jeevaka Badrappan
2010-09-15 17:13 ` Denis Kenzior
2010-09-14 17:01 ` [PATCH 4/8] USSD atom driver changes to read current character setting Denis Kenzior
2010-09-14 17:01 ` [PATCH 3/8] test-util: Add function for validating UCS2 to GSM bit conversion Denis Kenzior
2010-09-14 17:01 ` [PATCH 2/8] util: Add UCS2 to GSM 7bit converion function Denis Kenzior
2010-09-14 16:58 ` [PATCH 1/8] smsutil: Add USSD encoding function Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C8FB4A8.9050303@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox