Currently when sending a supplementary service control string via D-Bus, a
From Yang Gu <[email protected]> # This line is ignored.
From: Yang Gu <[email protected]>
Subject:
In-Reply-To:
PATCH 1/1 stk: Handle send ss proactive command
--- src/call-barring.c | 168 ++++++++++++++++++++++--------------- src/call-forwarding.c | 155 +++++++++++++++++++++------------- src/call-settings.c | 220 +++++++++++++++++++++++++++---------------------- src/ofono.h | 15 +++- src/stk.c | 98 ++++++++++++++++++++++ src/stkutil.c | 2 + src/stkutil.h | 23 +++++ src/ussd.c | 78 ++++++++++++------ 8 files changed, 504 insertions(+), 255 deletions(-)
src/call-barring.c +100 -68
@@ -48,6 +48,7 @@ static void set_query_next_lock(struct ofono_call_barring *cb);struct ofono_call_barring {int flags;DBusMessage *pending; +ofono_bool_t stk_pending;int cur_locks[NUM_OF_BARRINGS ];int new_locks[NUM_OF_BARRINGS ];int query_start;
@@ -58,10 +59,12 @@ struct ofono_call_barring {int ss_req_lock;struct ofono_ssn *ssn;struct ofono_ussd *ussd; +struct ofono_stk *stk;unsigned int incoming_bar_watch;unsigned int outgoing_bar_watch;unsigned int ssn_watch;unsigned int ussd_watch; +unsigned int stk_watch;const struct ofono_call_barring_driver *driver;void *driver_data;struct ofono_atom *atom;
@@ -95,6 +98,36 @@ static struct call_barring_lock cb_locks[] = {#define CB_ALL_OUTGOING 6#define CB_ALL_INCOMING 7 +gboolean __ofono_call_barring_is_busy (struct ofono_call_barring *cb) +{ +if (!cb) +return FALSE; + +if (cb->pending || cb->stk_pending) +return TRUE; + +return FALSE; +} + +static void reply_error (struct ofono_call_barring *cb, +const struct ofono_error *error) +{ +if (cb->pending) +__ofono_dbus_pending_reply (&cb->pending, +__ofono_error_failed (cb->pending)); +else +__ofono_stk_send_ss_response (cb->stk, &cb->stk_pending, error); +} + +static void set_pending (struct ofono_call_barring *cb, +struct ofono_ss_req *osr) +{ +if (osr->msg) + cb->pending =dbus_message_ref (osr->msg); +else + cb->stk_pending = TRUE; +} +static inline void emit_barring_changed (struct ofono_call_barring *cb,int start,int end,const char *type,int cls)
@@ -293,9 +326,8 @@ static void cb_ss_query_next_lock_callback(const struct ofono_error *error, "successful, but query was not"); cb->flags &= ~CALL_BARRING_FLAG_CACHED ; +reply_error (cb, error); -__ofono_dbus_pending_reply (&cb->pending, -__ofono_error_failed (cb->pending));return ; }
@@ -307,7 +339,11 @@ static void cb_ss_query_next_lock_callback(const struct ofono_error *error,return ; } -generate_ss_query_reply (cb); +if (cb->pending) +generate_ss_query_reply (cb); +else +__ofono_stk_send_ss_response (cb->stk, &cb->stk_pending, error); +update_barrings (cb,BEARER_CLASS_VOICE ); }
@@ -328,8 +364,7 @@ static void cb_ss_set_lock_callback(const struct ofono_error *error,if (error->type !=OFONO_ERROR_TYPE_NO_ERROR ) {DBG ("Enabling/disabling Call Barring via SS failed" ); -__ofono_dbus_pending_reply (&cb->pending, -__ofono_error_failed (cb->pending)); +reply_error (cb, error);return ; }
@@ -359,25 +394,19 @@ static const char *cb_ss_service_to_fac(const char *svc)return NULL ; } -static gboolean cb_ss_control (int type,const char *sc, +static int cb_ss_control (int type,const char *sc,const char *sia,const char *sib,const char *sic,const char *dn, -DBusMessage *msg,void *data) +struct ofono_ss_req *osr,void *data) {struct ofono_call_barring *cb = data; -DBusConnection *conn =ofono_dbus_get_connection ();int cls =BEARER_CLASS_DEFAULT ;const char *fac; -DBusMessage *reply;void *operation =NULL ;int i; -if (cb->pending) { - reply =__ofono_error_busy (msg); -g_dbus_send_message (conn, reply); - -return TRUE; - } +if (__ofono_call_barring_is_busy (cb)) +return EBUSY ;DBG ("Received call barring ss control request" );
@@ -386,7 +415,7 @@ static gboolean cb_ss_control(int type, const char *sc, fac =cb_ss_service_to_fac (sc);if (!fac) -return FALSE; +return -ENOENT ;cb_set_query_bounds (cb, fac, type ==SS_CONTROL_TYPE_QUERY );
@@ -397,13 +426,13 @@ static gboolean cb_ss_control(int type, const char *sc, cb->ss_req_lock = i;if (strlen (sic) >0 ) - goto bad_format; +return EINVAL ;if (strlen (dn) >0 ) - goto bad_format; +return EINVAL ;if (type !=SS_CONTROL_TYPE_QUERY && !is_valid_pin (sia,PIN_TYPE_NET )) - goto bad_format; +return EINVAL ;switch (type) {case SS_CONTROL_TYPE_ACTIVATION :
@@ -419,12 +448,8 @@ static gboolean cb_ss_control(int type, const char *sc,break ; } -if (!operation) { - reply =__ofono_error_not_implemented (msg); -g_dbus_send_message (conn, reply); - -return TRUE; - } +if (!operation) +return ENOSYS ;/* According to 27.007, AG, AC and AB only work with mode = 0 * We support query by querying all relevant types, since we must
@@ -433,7 +458,7 @@ static gboolean cb_ss_control(int type, const char *sc,if ((!strcmp (fac,"AG" ) || !strcmp (fac,"AC" ) || !strcmp (fac,"AB" )) && (type ==SS_CONTROL_TYPE_ACTIVATION || type ==SS_CONTROL_TYPE_REGISTRATION )) - goto bad_format; +return EINVAL ;if (strlen (sib) >0 ) {long service_code;
@@ -442,16 +467,16 @@ static gboolean cb_ss_control(int type, const char *sc, service_code =strtoul (sib, &end,10 );if (end == sib || *end !='\0' ) - goto bad_format; +return EINVAL ; cls =mmi_service_code_to_bearer_class (service_code);if (cls ==0 ) - goto bad_format; +return EINVAL ; } cb->ss_req_cls = cls; - cb->pending =dbus_message_ref (msg); +set_pending (cb, osr);switch (type) {case SS_CONTROL_TYPE_ACTIVATION :
@@ -472,44 +497,35 @@ static gboolean cb_ss_control(int type, const char *sc,break ; } -return TRUE; - -bad_format: - reply =__ofono_error_invalid_format (msg); -g_dbus_send_message (conn, reply); -return TRUE; +return 0 ; }static void cb_set_passwd_callback (const struct ofono_error *error,void *data) {struct ofono_call_barring *cb = data; -DBusMessage *reply; -if (error->type ==OFONO_ERROR_TYPE_NO_ERROR ) - reply =dbus_message_new_method_return (cb->pending); -else { - reply =__ofono_error_failed (cb->pending); +if (error->type !=OFONO_ERROR_TYPE_NO_ERROR ) {DBG ("Changing Call Barring password via SS failed" ); +reply_error (cb, error); +return ; } -__ofono_dbus_pending_reply (&cb->pending, reply); +if (cb->pending) +__ofono_dbus_pending_reply (&cb->pending, +dbus_message_new_method_return (cb->pending)); +else +__ofono_stk_send_ss_response (cb->stk, &cb->stk_pending, error); } -static gboolean cb_ss_passwd (const char *sc, +static int cb_ss_passwd (const char *sc,const char *old,const char *new, -DBusMessage *msg,void *data) +struct ofono_ss_req *osr,void *data) {struct ofono_call_barring *cb = data; -DBusConnection *conn =ofono_dbus_get_connection (); -DBusMessage *reply;const char *fac; -if (cb->pending) { - reply =__ofono_error_busy (msg); -g_dbus_send_message (conn, reply); - -return TRUE; - } +if (__ofono_call_barring_is_busy (cb)) +return EBUSY ;DBG ("Received call barring ss password change request" );
@@ -521,19 +537,16 @@ static gboolean cb_ss_passwd(const char *sc, fac =cb_ss_service_to_fac (sc);if (!fac) -return FALSE; +return -ENOENT ;if (!is_valid_pin (old,PIN_TYPE_NET ) || !is_valid_pin (new,PIN_TYPE_NET )) - goto bad_format; +return EINVAL ; + +set_pending (cb, osr); - cb->pending =dbus_message_ref (msg); cb->driver->set_passwd (cb, fac, old, new, cb_set_passwd_callback, cb); -return TRUE; -bad_format: - reply =__ofono_error_invalid_format (msg); -g_dbus_send_message (conn, reply); -return TRUE; +return 0 ; }static void cb_register_ss_controls (struct ofono_call_barring *cb)
@@ -580,11 +593,6 @@ static void cb_unregister_ss_controls(struct ofono_call_barring *cb)__ofono_ussd_passwd_unregister (cb->ussd,"353" ); } -gboolean __ofono_call_barring_is_busy (struct ofono_call_barring *cb) -{ -return cb->pending ? TRUE : FALSE; -} -static inline void cb_append_property (struct ofono_call_barring *cb,DBusMessageIter *dict,int start,int end,int cls,const char *property)
@@ -674,7 +682,7 @@ static DBusMessage *cb_get_properties(DBusConnection *conn, DBusMessage *msg, {struct ofono_call_barring *cb = data; -if (cb->pending ||__ofono_ussd_is_busy (cb->ussd)) +if (__ofono_call_barring_is_busy (cb) ||__ofono_ussd_is_busy (cb->ussd))return __ofono_error_busy (msg);if (!cb->driver->query)
@@ -827,7 +835,7 @@ static DBusMessage *cb_set_property(DBusConnection *conn, DBusMessage *msg,int cls;int mode; -if (cb->pending ||__ofono_ussd_is_busy (cb->ussd)) +if (__ofono_call_barring_is_busy (cb) ||__ofono_ussd_is_busy (cb->ussd))return __ofono_error_busy (msg);if (!dbus_message_iter_init (msg, &iter))
@@ -899,7 +907,7 @@ static DBusMessage *cb_disable_all(DBusConnection *conn, DBusMessage *msg,if (!cb->driver->set)return __ofono_error_not_implemented (msg); -if (cb->pending ||__ofono_ussd_is_busy (cb->ussd)) +if (__ofono_call_barring_is_busy (cb) ||__ofono_ussd_is_busy (cb->ussd))return __ofono_error_busy (msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &passwd,
@@ -946,7 +954,7 @@ static DBusMessage *cb_set_passwd(DBusConnection *conn, DBusMessage *msg,if (!cb->driver->set_passwd)return __ofono_error_not_implemented (msg); -if (cb->pending ||__ofono_ussd_is_busy (cb->ussd)) +if (__ofono_call_barring_is_busy (cb) ||__ofono_ussd_is_busy (cb->ussd))return __ofono_error_busy (msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &old_passwd,
@@ -1150,6 +1158,19 @@ static void ussd_watch(struct ofono_atom *atom,cb_register_ss_controls (cb); } +static void stk_watch (struct ofono_atom *atom, +enum ofono_atom_watch_condition cond,void *data) +{ +struct ofono_call_barring *cb = data; + +if (cond ==OFONO_ATOM_WATCH_CONDITION_UNREGISTERED ) { + cb->stk =NULL ; +return ; + } + + cb->stk =__ofono_atom_get_data (atom); +} +void ofono_call_barring_register (struct ofono_call_barring *cb) {DBusConnection *conn =ofono_dbus_get_connection ();
@@ -1157,6 +1178,7 @@ void ofono_call_barring_register(struct ofono_call_barring *cb)struct ofono_modem *modem =__ofono_atom_get_modem (cb->atom);struct ofono_atom *ssn_atom;struct ofono_atom *ussd_atom; +struct ofono_atom *stk_atom; if (!g_dbus_register_interface(conn, path, OFONO_CALL_BARRING_INTERFACE,
@@ -1188,6 +1210,16 @@ void ofono_call_barring_register(struct ofono_call_barring *cb)ussd_watch (ussd_atom,OFONO_ATOM_WATCH_CONDITION_REGISTERED , cb); + cb->stk_watch =__ofono_modem_add_atom_watch (modem, +OFONO_ATOM_TYPE_STK , + stk_watch, cb,NULL ); + + stk_atom =__ofono_modem_find_atom (modem,OFONO_ATOM_TYPE_STK ); + +if (stk_atom &&__ofono_atom_get_registered (stk_atom)) +stk_watch (stk_atom,OFONO_ATOM_WATCH_CONDITION_REGISTERED , + cb); +__ofono_atom_register (cb->atom, call_barring_unregister); }
src/call-forwarding.c +96 -59
315 lines not on this page · raw message
src/call-settings.c +120 -100
411 lines not on this page · raw message
src/ofono.h +13 -2
@@ -166,6 +166,12 @@ gboolean __ofono_modem_remove_atom_watch(struct ofono_modem *modem,void __ofono_atom_free (struct ofono_atom *atom); +#include <gdbus.h> +struct ofono_ss_req { +DBusMessage *msg; +gboolean stk; +}; +#include <ofono/call-barring.h> gboolean __ofono_call_barring_is_busy (struct ofono_call_barring *cb);
@@ -228,6 +234,8 @@ unsigned int __ofono_sms_txq_submit(struct ofono_sms *sms, GSList *list,struct cbs ;void __ofono_cbs_sim_download (struct ofono_stk *stk,const struct cbs *msg); +void __ofono_stk_send_ss_response (struct ofono_stk *stk,gboolean *stk_pending, +const struct ofono_error *error);#include <ofono/ssn.h>
@@ -252,11 +260,11 @@ typedef gboolean (*ofono_ussd_ssc_cb_t)(int type,const char *sc, const char *sia, const char *sib, const char *sic, const char *dn, - DBusMessage *msg, void *data); + struct ofono_ss_req *osr, void *data);typedef gboolean (*ofono_ussd_passwd_cb_t )(const char *sc,const char *old,const char *new, -DBusMessage *msg,void *data); +struct ofono_ss_req *osr,void *data); gboolean __ofono_ussd_ssc_register(struct ofono_ussd *ussd, const char *sc, ofono_ussd_ssc_cb_t cb, void *data,
@@ -268,6 +276,9 @@ gboolean __ofono_ussd_passwd_register(struct ofono_ussd *ussd, const char *sc, ofono_destroy_func destroy);void __ofono_ussd_passwd_unregister (struct ofono_ussd *ussd,const char *sc);gboolean __ofono_ussd_is_busy (struct ofono_ussd *ussd); +int __ofono_ussd_recognized_control_string (struct ofono_ussd *ussd, +const char *ss_str, +struct ofono_ss_req *osr);#include <ofono/netreg.h>
src/stk.c +98 -0
116 lines not on this page · raw message
src/stkutil.c +2 -0
@@ -5441,6 +5441,8 @@ const unsigned char *stk_pdu_from_response(const struct stk_response *response, &response->select_item.item_id, NULL);break ; +case STK_COMMAND_TYPE_SEND_SS : +break ;case STK_COMMAND_TYPE_SETUP_CALL : ok =build_setup_call (&builder, response);break ;
src/stkutil.h +23 -0
@@ -254,6 +254,8 @@ enum stk_result_type {STK_RESULT_TYPE_COMMAND_NOT_UNDERSTOOD =0x31 ,STK_RESULT_TYPE_DATA_NOT_UNDERSTOOD =0x32 ,STK_RESULT_TYPE_COMMAND_ID_UNKNOWN =0x33 , +STK_RESULT_TYPE_SS_RETURN_ERROR =0x34 , +STK_RESULT_TYPE_SMS_RP_ERROR =0x35 ,STK_RESULT_TYPE_MINIMUM_NOT_MET =0x36 ,STK_RESULT_TYPE_USSD_RETURN_ERROR =0x37 , STK_RESULT_TYPE_CALL_CONTROL_PERMANENT = 0x39,
@@ -263,6 +265,27 @@ enum stk_result_type { STK_RESULT_TYPE_MMS_ERROR = 0x3D, }; +enum stk_result_addnl_me_pb_fb { +STK_RESULT_ADDNL_ME_PB_NO_SPECIFIC_CAUSE =0x00 , +STK_RESULT_ADDNL_ME_PB_SCREEN_BUSY =0x01 , +STK_RESULT_ADDNL_ME_PB_BUSY_ON_CALL =0x02 , +STK_RESULT_ADDNL_ME_PB_NO_SERVICE =0x04 , +STK_RESULT_ADDNL_ME_PB_NO_ACCESS =0x05 , +STK_RESULT_ADDNL_ME_PB_NO_RADIO_RESOURCE =0x06 , +STK_RESULT_ADDNL_ME_PB_NOT_IN_SPEECH_CALL =0x07 , +STK_RESULT_ADDNL_ME_PB_BUSY_ON_SEND_DTMF =0x09 , +STK_RESULT_ADDNL_ME_PB_NO_NAA_ACTIVE =0x0A +}; + +enum stk_result_addnl_me_pb_ob { +STK_RESULT_ADDNL_ME_PB_SS_BUSY =0x03 , +STK_RESULT_ADDNL_ME_PB_USSD_BUSY =0x08 +}; + +enum stk_result_addnl_ss_pb_ob { +STK_RESULT_ADDNL_SS_PB_NO_SPECIFIC_CAUSE =0x00 +}; +enum stk_tone_type {STK_TONE_TYPE_DIAL_TONE =0x01 ,STK_TONE_TYPE_BUSY_TONE =0x02 ,
src/ussd.c +52 -26
136 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Gu
cover stk: Handle send ss proactive command
In reply to Yang GuHi,
Quoted 8 lines
-----Original Message-----
From: ofono-bounces(a)ofono.org [mailto:ofono-bounces(a)ofono.org] On Behalf Of Yang Gu
Sent: Monday, September 13, 2010 4:36 PM
To: ofono(a)ofono.org
Subject: Currently when sending a supplementary service control string via D-Bus, a
From Yang Gu <[email protected]> # This line is ignored.
Quoted 8 lines
From: Yang Gu <[email protected]>
Subject:
In-Reply-To:_______________________________________________
ofono mailing list
ofono(a)ofono.org
http://lists.ofono.org/listinfo/ofono
I intended to send a description for the patch I sent just now, but seems it failed. Sorry for the inconvenience :(
Below is the description:
This patch is to handle send ss proactive command from SIM.
Currently when sending a supplementary service control string via D-Bus, a series of functions would be called. For example, if we want to send a call barring activatioin string via D-Bus, these functions would be called: ussd_initiate()->recognized_control_string()->cb_ss_control()->cb_ss_set_lock_callback()->cb_ss_query_next_lock()->cb_ss_query_next_lock_callback(). To handle send ss command from SIM needs to follow the same way as D-Bus, so my target is to try the best to reuse these functions. However, currently these functions take the assumption that the calling is from D-Bus. My solution is to introduce a data structure named "ofono_ss_req" to replace original "DBusMessage *" parameter. Other main changes are to unify the return code of these functions and handle them centrally.
Comments are welcome!
Regards,
-Yang
RE: [PATCH 0/1] stk: Handle send ss proactive command
Hi Yang,
Quoted 3 lines
Below is the description:
This patch is to handle send ss proactive command from SIM. Currently when sending a supplementary service control string via
D-Bus, a series of functions would be called. For example, if we want to send a call barring activatioin string via D-Bus, these
Quoted 1 line
functions would be called:
ussd_initiate()->recognized_control_string()->cb_ss_control()->cb_ss_set _lock_callback()->cb_ss_query_next_lock()->cb_ss_query_next_lock_callbac k(). To handle send ss command > from SIM needs to follow the same way as D-Bus, so my target is to try the best to reuse these functions. However, currently these functions take the assumption that the calling is from D-Bus. My
Quoted 1 line
solution is to introduce a data structure named "
ofono_ss_req" to
replace original "DBusMessage *" parameter.
Quoted 1 line
Other main changes are to unify the return code of these functions and
handle them centrally.
Quoted 1 line
Comments are welcome!
Following the same control flow as normal case, requires rewriting some of the existing functions to deal with both the cases like what you have done now. Isn't it better to keep it separate? So that we won't end up in introducing SAT specific handling in the normal use case also.
Proposed solution:
SS(eg: call forwarding, call barring) registers to the USSD by calling __ofono_ussd_ssc_register with the service code, call back function(normal_callback) and few other parameters. SS can also register to the STK by calling __ofono_ussd_ssc_register with the service code, call back function(stk_callback). normal_callback and stk_callback can handle normal and stk use case respectively. More generic handling can be moved to a separate function which normal_callback and stk_callback functions can make use of. Also parsing/matching of the service strings can be moved to utility. STK, USSD or anyother atoms can make use of the parsing/matching(of service string) utility function.
Let me know your views on this.
Thanks and Regards,
jeevaka
Gu
RE: [PATCH 0/1] stk: Handle send ss proactive command
Hi jeevaka,
Quoted 47 lines
-----Original Message-----
From: ofono-bounces(a)ofono.org [mailto:ofono-bounces(a)ofono.org] On Behalf Of Jeevaka.Badrappan(a)elektrobit.com
Sent: Wednesday, September 15, 2010 8:12 PM
To: ofono(a)ofono.org
Subject: RE: [PATCH 0/1] stk: Handle send ss proactive commandHi Yang,
Quoted 3 lines
Below is the description:
This patch is to handle send ss proactive command from SIM. Currently when sending a supplementary service control string viaD-Bus, a series of functions would be called. For example, if we want to send a call barring activatioin string via D-Bus, these
Quoted 1 line
functions would be called:
ussd_initiate()->recognized_control_string()->cb_ss_control()->cb_ss_set _lock_callback()->cb_ss_query_next_lock()->cb_ss_query_next_lock_callbac
k(). To handle send ss command > from SIM needs to follow the same way as D-Bus, so my target is to try the best to reuse these functions. However, currently these functions take the assumption that the calling is from D-Bus. MyQuoted 1 line
solution is to introduce a data structure named "
ofono_ss_req" toreplace original "DBusMessage *" parameter.
Quoted 1 line
Other main changes are to unify the return code of these functions and
handle them centrally.
Quoted 1 line
Comments are welcome!
Following the same control flow as normal case, requires rewriting some of the existing functions to deal with both the cases like what you have done now. Isn't it better to keep it separate? So that we won't end up in introducing SAT specific handling in the normal use case also.
Proposed solution:
SS(eg: call forwarding, call barring)registers to the USSD by calling__ofono_ussd_ssc_registerwith the service code, call backfunction(normal_callback)and few other parameters. SS can also register to the STK by calling__ofono_ussd_ssc_registerwith the service code, call backfunction(stk_callback).normal_callbackandstk_callbackcan handle normal and stk use case respectively. More generic handling can be moved to a separate function whichnormal_callbackandstk_callbackfunctions can make use of. Also parsing/matching of the service strings can be moved to utility. STK, USSD or anyother atoms can make use of the parsing/matching(of service string) utility function.
Quoted 1 line
Let me know your views on this.
Thank you for the comments!
But if we handle stk logic in separate functions, we would have to duplicate:
In ussd.c,
recognized_control_string() recognized_passwd_change_string() ussd->ss_control_list
in <ss>.c:
<ss>_ss_control() and other registered functions // We may extract most of logic as a utility function, but we have to set the pending or the indication for stk request Various call back functions
I don't want to duplicate all these functions for stk, especially the two functions in ussd.c. Thinking about the case we may support at server (oFono has the ability to parse incoming at command, talk with modem in its specific language, at command or proprietary protocol, and send back the response) someday, you may need to duplicate all these functions again for it. In my opinion, the request from D-Bus isn't so "normal". Each atom provides a set of functions (services) that can be requested by others, either the request from D-Bus, or request from other atoms, such as stk and at server. Current functions take the assumption that all the requests are all from D-Bus. What I want to do is just to break this assumption, and my current solution is easy to be extended to support the at server case. What do you think about?
Regards,
-Yang