All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] dbus: Add __ofono_error_from_error utility function
@ 2012-05-30 13:53 Philippe Nunes
  2012-05-30 13:53 ` [PATCH v2 2/2] SS: Return specific ofono errors after SS failure Philippe Nunes
  2012-05-30 14:06 ` [PATCH v2 1/2] dbus: Add __ofono_error_from_error utility function Denis Kenzior
  0 siblings, 2 replies; 4+ messages in thread
From: Philippe Nunes @ 2012-05-30 13:53 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2370 bytes --]

---
 src/dbus.c  |   42 ++++++++++++++++++++++++++++++++++++++++++
 src/ofono.h |    3 +++
 2 files changed, 45 insertions(+)

diff --git a/src/dbus.c b/src/dbus.c
index 5cccc32..4ae6969 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -32,6 +32,21 @@
 
 static DBusConnection *g_connection;
 
+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 },
+};
+
 static void append_variant(DBusMessageIter *iter,
 				int type, void *value)
 {
@@ -388,6 +403,33 @@ DBusMessage *__ofono_error_not_allowed(DBusMessage *msg)
 					"Operation is not allowed");
 }
 
+DBusMessage *__ofono_error_from_error(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);
+}
+
 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply)
 {
 	DBusConnection *conn = ofono_dbus_get_connection();
diff --git a/src/ofono.h b/src/ofono.h
index 81d5f71..f0e1072 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -66,6 +66,9 @@ DBusMessage *__ofono_error_emergency_active(DBusMessage *msg);
 DBusMessage *__ofono_error_incorrect_password(DBusMessage *msg);
 DBusMessage *__ofono_error_not_allowed(DBusMessage *msg);
 
+DBusMessage *__ofono_error_from_error(const struct ofono_error *error,
+						DBusMessage *msg);
+
 void __ofono_dbus_pending_reply(DBusMessage **msg, DBusMessage *reply);
 
 gboolean __ofono_dbus_valid_object_path(const char *path);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] SS: Return specific ofono errors after SS failure
  2012-05-30 13:53 [PATCH v2 1/2] dbus: Add __ofono_error_from_error utility function Philippe Nunes
@ 2012-05-30 13:53 ` Philippe Nunes
  2012-05-30 14:07   ` Denis Kenzior
  2012-05-30 14:06 ` [PATCH v2 1/2] dbus: Add __ofono_error_from_error utility function Denis Kenzior
  1 sibling, 1 reply; 4+ messages in thread
From: Philippe Nunes @ 2012-05-30 13:53 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 3687 bytes --]

---
 src/call-barring.c    |   10 ++++++----
 src/call-forwarding.c |    5 +++--
 src/call-settings.c   |   15 +++++++++------
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/call-barring.c b/src/call-barring.c
index ddf4c73..53847fb 100644
--- a/src/call-barring.c
+++ b/src/call-barring.c
@@ -323,9 +323,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));
+			__ofono_error_from_error(error, cb->pending));
 		return;
 	}
 
@@ -485,8 +486,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 = __ofono_error_from_error(error, cb->pending);
 	}
 
 	__ofono_dbus_pending_reply(&cb->pending, reply);
diff --git a/src/call-forwarding.c b/src/call-forwarding.c
index 3d9c5c1..5acbd67 100644
--- a/src/call-forwarding.c
+++ b/src/call-forwarding.c
@@ -1020,10 +1020,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));
+				__ofono_error_from_error(error, cf->pending));
 		g_free(cf->ss_req);
 		cf->ss_req = NULL;
 		return;
diff --git a/src/call-settings.c b/src/call-settings.c
index 6bc9658..4bfb561 100644
--- a/src/call-settings.c
+++ b/src/call-settings.c
@@ -477,9 +477,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));
+			__ofono_error_from_error(error, cs->pending));
 
 		return;
 	}
@@ -614,9 +615,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));
+			__ofono_error_from_error(error, cs->pending));
 
 		return;
 	}
@@ -772,9 +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));
+			__ofono_error_from_error(error, cs->pending));
 
 		return;
 	}
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] dbus: Add __ofono_error_from_error utility function
  2012-05-30 13:53 [PATCH v2 1/2] dbus: Add __ofono_error_from_error utility function Philippe Nunes
  2012-05-30 13:53 ` [PATCH v2 2/2] SS: Return specific ofono errors after SS failure Philippe Nunes
@ 2012-05-30 14:06 ` Denis Kenzior
  1 sibling, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2012-05-30 14:06 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 264 bytes --]

Hi Philippe,

On 05/30/2012 08:53 AM, Philippe Nunes wrote:
> ---
>   src/dbus.c  |   42 ++++++++++++++++++++++++++++++++++++++++++
>   src/ofono.h |    3 +++
>   2 files changed, 45 insertions(+)
>

Patch has been applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] SS: Return specific ofono errors after SS failure
  2012-05-30 13:53 ` [PATCH v2 2/2] SS: Return specific ofono errors after SS failure Philippe Nunes
@ 2012-05-30 14:07   ` Denis Kenzior
  0 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2012-05-30 14:07 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

Hi Philippe,

On 05/30/2012 08:53 AM, Philippe Nunes wrote:
> ---
>   src/call-barring.c    |   10 ++++++----
>   src/call-forwarding.c |    5 +++--
>   src/call-settings.c   |   15 +++++++++------
>   3 files changed, 18 insertions(+), 12 deletions(-)

I broke this patch into three, one for each file, and applied them.  I 
tweaked the commit message slightly.

Thanks,
-Denis


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-30 14:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-30 13:53 [PATCH v2 1/2] dbus: Add __ofono_error_from_error utility function Philippe Nunes
2012-05-30 13:53 ` [PATCH v2 2/2] SS: Return specific ofono errors after SS failure Philippe Nunes
2012-05-30 14:07   ` Denis Kenzior
2012-05-30 14:06 ` [PATCH v2 1/2] dbus: Add __ofono_error_from_error utility function Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.