Return specific ofono errors after SS transaction
cover Return specific ofono errors after SS transaction
As pointed by the first GCF tests, the user indication does not distinguish the type of error occured after an SS request. Actually, the ofono error type .Failed is returned whatever is the telephony error.
In order to return more specific ofono error types, I introduced an utility function to map the telephony errors into ofono errors. I extended also the ofono error types to match more closely with the telephony errors.
Philippe Nunes (6):
common: Fix typos in error strings
dbus: Add new error types
error-mapping: Add function to map telephony errors into ofono error
types
build: Add error-mapping utility to build
Return specific ofono errors according telephony errors Extend the list of ofono error types returned by the method initiate
Makefile.am | 1 + doc/supplementaryservices-api.txt | 6 +++ src/call-barring.c | 11 ++++-- src/call-forwarding.c | 6 ++- src/call-settings.c | 18 +++++---- src/common.c | 19 ++++----- src/dbus.c | 13 +++++++ src/error-mapping.c | 77 +++++++++++++++++++++++++++++++++++++ src/error-mapping.h | 25 ++++++++++++ src/ofono.h | 2 + 10 files changed, 155 insertions(+), 23 deletions(-) create mode 100644 src/error-mapping.c create mode 100644 src/error-mapping.h
Signature · 1 line
1.7.9.5
PATCH 1/6 common: Fix typos in error strings
--- src/common.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
src/common.c +10 -9
@@ -49,13 +49,13 @@ struct error_entry cms_errors[] = { { 10, "Call barred" }, { 21, "Short message transfer rejected" }, { 27, "Destination out of service" }, - { 28, "Unindentified subscriber" }, + { 28, "Unidentified subscriber" }, { 29, "Facility rejected" }, { 30, "Unknown subscriber" }, { 38, "Network out of order" }, { 41, "Temporary failure" }, { 42, "Congestion" }, - { 47, "Recources unavailable" }, + { 47, "Resources unavailable" }, { 50, "Requested facility not subscribed" }, { 69, "Requested facility not implemented" }, { 81, "Invalid short message transfer reference value" },
@@ -65,8 +65,8 @@ struct error_entry cms_errors[] = { { 98, "Message not compatible with short message protocol state" }, { 99, "Information element non-existent or not implemented" }, { 111, "Protocol error, unspecified" }, - { 127, "Internetworking error, unspecified" }, - { 128, "Telematic internetworking not supported" }, + { 127, "Interworking error, unspecified" }, + { 128, "Telematic interworking not supported" }, { 129, "Short message type 0 not supported" }, { 130, "Cannot replace short message" }, { 143, "Unspecified TP-PID error" },
@@ -89,7 +89,7 @@ struct error_entry cms_errors[] = { { 209, "No SMS Storage capability in SIM" }, { 210, "Error in MS" }, { 211, "Memory capacity exceeded" }, - { 212, "Sim application toolkit busy" }, + { 212, "SIM application toolkit busy" }, { 213, "SIM data download error" }, { 255, "Unspecified error cause" }, { 300, "ME Failure" },
@@ -121,7 +121,7 @@ struct error_entry cms_errors[] = {struct error_entry cme_errors[] = { {0 ,"Phone failure" }, {1 ,"No connection to phone" }, - {2 ,"Phone adapter link reserved" }, + {2 ,"Phone adaptor link reserved" }, {3 ,"Operation not allowed" }, {4 ,"Operation not supported" }, {5 ,"PH_SIM PIN required" },
@@ -156,6 +156,7 @@ struct error_entry cme_errors[] = { { 46, "Corporate personalization PIN required" }, { 47, "Corporate personalization PUK required" }, { 48, "PH-SIM PUK required" }, + { 50, "Incorrect parameters" }, { 100, "Unknown error" }, { 103, "Illegal MS" }, { 106, "Illegal ME" },
@@ -204,14 +205,14 @@ struct error_entry ceer_errors[] = { { 38, "Network out of order" }, { 41, "Temporary failure" }, { 42, "Switching equipment congestion" }, - { 43, "Access information discared" }, + { 43, "Access information discarded" }, { 44, "Requested circuit/channel not available" }, { 47, "Resource unavailable (unspecified)" }, { 49, "Quality of service unavailable" }, { 50, "Requested facility not subscribed" }, { 55, "Incoming calls barred within the CUG" }, { 57, "Bearer capability not authorized" }, - { 58, "Bearar capability not presently available" }, + { 58, "Bearer capability not presently available" }, { 63, "Service or option not available, unspecified" }, { 65, "Bearer service not implemented" }, { 68, "ACM equal to or greater than ACMmax" },
@@ -229,7 +230,7 @@ struct error_entry ceer_errors[] = { { 99, "Information element non-existent or not implemented" }, { 100, "Conditional IE error" }, { 101, "Message not compatible with protocol state" }, - { 102, "Recovery on timer expirty" }, + { 102, "Recovery on timer expiry" }, { 111, "Protocol error, unspecified" }, { 127, "Interworking, unspecified" }, };
Signature · 1 line
1.7.9.5
Re: [PATCH 1/6] common: Fix typos in error strings
Hi Philippe,
Quoted 4 lines · Philippe Nunes
--- src/common.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
Patch has been applied, thanks.
Regards,
-Denis
PATCH 2/6 dbus: Add new error types
In reply to Philippe Nunes--- src/dbus.c | 13 +++++++++++++ src/ofono.h | 2 ++ 2 files changed, 15 insertions(+)
src/dbus.c +13 -0
@@ -375,6 +375,19 @@ DBusMessage *__ofono_error_emergency_active(DBusMessage *msg) "Emergency mode active"); } +DBusMessage *__ofono_error_incorrect_password (DBusMessage *msg) +{ +return g_dbus_create_error (msg, +OFONO_ERROR_INTERFACE ".IncorrectPassword" , +"Password is incorrect" ); +} + +DBusMessage *__ofono_error_not_allowed (DBusMessage *msg) +{ +return g_dbus_create_error (msg,OFONO_ERROR_INTERFACE ".NotAllowed" , +"Operation is not allowed" ); +} +void __ofono_dbus_pending_reply (DBusMessage **msg,DBusMessage *reply) {DBusConnection *conn =ofono_dbus_get_connection ();
src/ofono.h +2 -0
@@ -63,6 +63,8 @@ DBusMessage *__ofono_error_not_registered(DBusMessage *msg);DBusMessage *__ofono_error_canceled (DBusMessage *msg);DBusMessage *__ofono_error_access_denied (DBusMessage *msg);DBusMessage *__ofono_error_emergency_active (DBusMessage *msg); +DBusMessage *__ofono_error_incorrect_password (DBusMessage *msg); +DBusMessage *__ofono_error_not_allowed (DBusMessage *msg);void __ofono_dbus_pending_reply (DBusMessage **msg,DBusMessage *reply);
Signature · 1 line
1.7.9.5
Re: [PATCH 2/6] dbus: Add new error types
Hi Philippe,
Quoted 5 lines · Philippe Nunes
--- src/dbus.c | 13 +++++++++++++ src/ofono.h | 2 ++ 2 files changed, 15 insertions(+)
Patch has been applied, thanks.
Regards,
-Denis
PATCH 3/6 error-mapping: Add function to map telephony errors into ofono error types
In reply to Philippe Nunes--- src/error-mapping.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/error-mapping.h | 25 +++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 src/error-mapping.c create mode 100644 src/error-mapping.h
src/error-mapping.c new file +77 -0
@@ -0,0 +1,77 @@ +/* +* +* oFono - Open Source Telephony +* +* Copyright (C) 2008-2012 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +* +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#define _GNU_SOURCE +#include <string.h> +#include <errno.h> + +#include <glib.h> + +#include <ofono/types.h> +#include <gdbus.h> +#include "ofono.h" +#include "error-mapping.h" + +struct error_mapping_entry { +int error; +DBusMessage *(*ofono_error_func)(DBusMessage *); +}; + +struct error_mapping_entry cme_errors_mapping[] = { + {3 , __ofono_error_not_allowed }, + {4 , __ofono_error_not_supported }, + {16 , __ofono_error_incorrect_password }, + {30 , __ofono_error_not_registered }, + {31 , __ofono_error_timed_out }, + {32 , __ofono_error_access_denied }, + {50 , __ofono_error_invalid_args }, +}; + +DBusMessage *telephony_error_to_ofono_err (const struct ofono_error *error, +DBusMessage *msg) +{ +struct error_mapping_entry *e; +int maxentries; +int i; + +switch (error->type) { +case OFONO_ERROR_TYPE_CME : + e = cme_errors_mapping; + maxentries =sizeof (cme_errors_mapping) / +sizeof (struct error_mapping_entry ); +for (i =0 ; i < maxentries; i++) +if (e[i].error == error->error) +return e[i].ofono_error_func (msg); +break ; +case OFONO_ERROR_TYPE_CMS : +return __ofono_error_failed (msg); +case OFONO_ERROR_TYPE_CEER : +return __ofono_error_failed (msg); +default : +return __ofono_error_failed (msg); + } + +return __ofono_error_failed (msg); +}
src/error-mapping.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* +* oFono - Open Source Telephony +* +* Copyright (C) 2008-2012 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +* +*/ + +#include <gdbus.h> + +DBusMessage *telephony_error_to_ofono_err (const struct ofono_error *error, +DBusMessage *msg);
Signature · 1 line
1.7.9.5
Re: [PATCH 3/6] error-mapping: Add function to map telephony errors into ofono error types
Hi Philippe,
Quoted 36 lines · Philippe Nunes
--- src/error-mapping.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/error-mapping.h | 25 +++++++++++++++++ 2 files changed, 102 insertions(+)create mode 100644
src/error-mapping.c
create mode 100644src/error-mapping.hsrc/error-mapping.c new file +23
-0@@ -0,0 +1,77 @@ +/* +* +* oFono - Open Source Telephony +* +* Copyright (C) 2008-2012 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +* +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h>
src/error-mapping.c line 33
Quoted 10 lines
src/error-mapping.c new file +10
-0+#endif + +#define _GNU_SOURCE +#include <string.h> +#include <errno.h> + +#include <glib.h> + +#include <ofono/types.h> +#include <gdbus.h>
Is gdbus really necessary? If it is, then it should be above ofono/types
Quoted 34 lines
src/error-mapping.c new file +34
-0+#include "ofono.h" +#include "error-mapping.h" + +struct error_mapping_entry { +int error; +DBusMessage *(*ofono_error_func)(DBusMessage *); +}; + +struct error_mapping_entry cme_errors_mapping[] = { + {3 , __ofono_error_not_allowed }, + {4 , __ofono_error_not_supported }, + {16 , __ofono_error_incorrect_password }, + {30 , __ofono_error_not_registered }, + {31 , __ofono_error_timed_out }, + {32 , __ofono_error_access_denied }, + {50 , __ofono_error_invalid_args }, +}; + +DBusMessage *telephony_error_to_ofono_err (const struct ofono_error *error, +DBusMessage *msg) +{ +struct error_mapping_entry *e; +int maxentries; +int i; + +switch (error->type) { +case OFONO_ERROR_TYPE_CME : + e = cme_errors_mapping; + maxentries =sizeof (cme_errors_mapping) / +sizeof (struct error_mapping_entry ); +for (i =0 ; i< maxentries; i++) +if (e[i].error == error->error) +return e[i].ofono_error_func (msg); +break ;
src/error-mapping.c line 77
Quoted 10 lines
src/error-mapping.c new file +10
-0+case OFONO_ERROR_TYPE_CMS : +return __ofono_error_failed (msg); +case OFONO_ERROR_TYPE_CEER : +return __ofono_error_failed (msg); +default : +return __ofono_error_failed (msg); + } + +return __ofono_error_failed (msg); +}
Please move this to dbus.c, it isn't worth creating a brand new file for this.
Quoted 21 lines
src/error-mapping.h new file +15
-0@@ -0,0 +1,25 @@ +/* +* +* oFono - Open Source Telephony +* +* Copyright (C) 2008-2012 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*
src/error-mapping.h line 25
Quoted 10 lines
src/error-mapping.h new file +10
-0+* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +* +*/ + +#include <gdbus.h> + +DBusMessage *telephony_error_to_ofono_err (const struct ofono_error *error, +DBusMessage *msg);
I don't like the name of this function, it should be prefixed with __ofono_error to be in line with the rest of the __ofono_error family. Lets go with __ofono_error_from_error. Syntactically it does appear rather unfortunate, but I can't think of anything better right now.
Declare it inside ofono.h as well, there's no need for a header file...
Quoted 1 line
\ No newline at end of file
Regards,
-Denis
PATCH 4/6 build: Add error-mapping utility to build
In reply to Philippe Nunes--- Makefile.am | 1 + 1 file changed, 1 insertion(+)
Makefile.am +1 -0
@@ -445,6 +445,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) src/ofono.ver \ src/modem.c src/common.h src/common.c \ src/manager.c src/dbus.c src/util.h src/util.c \ src/network.c src/voicecall.c src/ussd.c src/sms.c \ + src/error-mapping.h src/error-mapping.c \ src/call-settings.c src/call-forwarding.c \ src/call-meter.c src/smsutil.h src/smsutil.c \ src/call-barring.c src/sim.c src/stk.c \
Signature · 1 line
1.7.9.5
PATCH 5/6 Return specific ofono errors according telephony errors
In reply to Philippe Nunes--- src/call-barring.c | 11 +++++++---- src/call-forwarding.c | 6 ++++-- src/call-settings.c | 18 ++++++++++-------- 3 files changed, 21 insertions(+), 14 deletions(-)
src/call-barring.c +7 -4
@@ -35,6 +35,7 @@#include "ofono.h" #include "common.h" +#include "error-mapping.h" #define CALL_BARRING_FLAG_CACHED 0x1#define NUM_OF_BARRINGS 5
@@ -323,9 +324,10 @@ static void cb_ss_set_lock_callback(const struct ofono_error *error,struct ofono_call_barring *cb = data;if (error->type !=OFONO_ERROR_TYPE_NO_ERROR ) { -DBG ("Enabling/disabling Call Barring via SS failed" ); +DBG ("Enabling/disabling Call Barring via SS failed with err:%s" , +telephony_error_to_str (error));__ofono_dbus_pending_reply (&cb->pending, -__ofono_error_failed (cb->pending)); +telephony_error_to_ofono_err (error, cb->pending));return ; }
@@ -485,8 +487,9 @@ static void cb_set_passwd_callback(const struct ofono_error *error, void *data)if (error->type ==OFONO_ERROR_TYPE_NO_ERROR ) reply =dbus_message_new_method_return (cb->pending);else { - reply =__ofono_error_failed (cb->pending); -DBG ("Changing Call Barring password via SS failed" ); +DBG ("Changing Call Barring password via SS failed with err: %s" , +telephony_error_to_str (error)); + reply =telephony_error_to_ofono_err (error, cb->pending); }__ofono_dbus_pending_reply (&cb->pending, reply);
src/call-forwarding.c +4 -2
@@ -35,6 +35,7 @@#include "common.h" #include "simutil.h" +#include "error-mapping.h" #define CALL_FORWARDING_FLAG_CACHED 0x1#define CALL_FORWARDING_FLAG_CPHS_CFF 0x2
@@ -1020,10 +1021,11 @@ static void cf_ss_control_callback(const struct ofono_error *error, void *data)struct ofono_call_forwarding *cf = data;if (error->type !=OFONO_ERROR_TYPE_NO_ERROR ) { -DBG ("Error occurred during cf ss control set/erasure" ); +DBG ("CF ss control set/erasure failed with error: %s" , +telephony_error_to_str (error));__ofono_dbus_pending_reply (&cf->pending, -__ofono_error_failed (cf->pending)); +telephony_error_to_ofono_err (error, cf->pending));g_free (cf->ss_req); cf->ss_req =NULL ;return ;
src/call-settings.c +10 -8
@@ -34,6 +34,7 @@#include "ofono.h" #include "common.h" +#include "error-mapping.h" #define CALL_SETTINGS_FLAG_CACHED 0x1
@@ -477,9 +478,10 @@ static void cw_ss_set_callback(const struct ofono_error *error, void *data)struct ofono_call_settings *cs = data;if (error->type !=OFONO_ERROR_TYPE_NO_ERROR ) { -DBG ("setting CW via SS failed" ); +DBG ("setting CW via SS failed with error: %s" , +telephony_error_to_str (error));__ofono_dbus_pending_reply (&cs->pending, -__ofono_error_failed (cs->pending)); +telephony_error_to_ofono_err (error, cs->pending));return ; }
@@ -614,10 +616,10 @@ static void clip_cnap_colp_colr_ss_query_cb(const struct ofono_error *error,const char *value;if (error->type !=OFONO_ERROR_TYPE_NO_ERROR ) { -DBG ("Error occurred during ss control query" ); +DBG ("SS control query failed with error: %s" , +telephony_error_to_str (error));__ofono_dbus_pending_reply (&cs->pending, -__ofono_error_failed (cs->pending)); - +telephony_error_to_ofono_err (error, cs->pending));return ; }
@@ -772,10 +774,10 @@ static void clir_ss_set_callback(const struct ofono_error *error, void *data)struct ofono_call_settings *cs = data;if (error->type !=OFONO_ERROR_TYPE_NO_ERROR ) { -DBG ("setting clir via SS failed" ); +DBG ("setting clir via SS failed with error: %s" , +telephony_error_to_str (error));__ofono_dbus_pending_reply (&cs->pending, -__ofono_error_failed (cs->pending)); - +telephony_error_to_ofono_err (error, cs->pending));return ; }
Signature · 1 line
1.7.9.5
PATCH 6/6 Extend the list of ofono error types returned by the method initiate
In reply to Philippe Nunes--- doc/supplementaryservices-api.txt | 6 ++++++ 1 file changed, 6 insertions(+)
doc/supplementaryservices-api.txt +6 -0
@@ -27,6 +27,12 @@ Methods string, variant Initiate(string command) [service].Error.NotImplemented [service].Error.InvalidArguments [service].Error.InvalidFormat + [service].Error.NotSupported + [service].Error.NotAllowed + [service].Error.IncorrectPassword + [service].Error.NotRegistered + [service].Error.Timedout + [service].Error.AccessDenied [service].Error.Failed string Respond(string reply)
Signature · 1 line
1.7.9.5
Re: [PATCH 6/6] Extend the list of ofono error types returned by the method initiate
Hi Philippe,
Quoted 4 lines · Philippe Nunes
--- doc/supplementaryservices-api.txt | 6 ++++++ 1 file changed, 6 insertions(+)
Patch has been applied with a slightly reworded commit message so it would be in-line with our coding style guidlines (see item M5).
Regards,
-Denis