All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Nunes <philippe.nunes@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 3/6] error-mapping: Add function to map telephony errors into ofono error types
Date: Tue, 29 May 2012 18:38:34 +0200	[thread overview]
Message-ID: <1338309517-14808-4-git-send-email-philippe.nunes@linux.intel.com> (raw)
In-Reply-To: <1338309517-14808-1-git-send-email-philippe.nunes@linux.intel.com>

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

---
 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

diff --git a/src/error-mapping.c b/src/error-mapping.c
new file mode 100644
index 0000000..2012881
--- /dev/null
+++ b/src/error-mapping.c
@@ -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);
+}
diff --git a/src/error-mapping.h b/src/error-mapping.h
new file mode 100644
index 0000000..9909f9b
--- /dev/null
+++ b/src/error-mapping.h
@@ -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);
\ No newline at end of file
-- 
1.7.9.5


  parent reply	other threads:[~2012-05-29 16:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-29 16:38 [PATCH 0/6] Return specific ofono errors after SS transaction Philippe Nunes
2012-05-29 16:38 ` [PATCH 1/6] common: Fix typos in error strings Philippe Nunes
2012-05-30  5:22   ` Denis Kenzior
2012-05-29 16:38 ` [PATCH 2/6] dbus: Add new error types Philippe Nunes
2012-05-30  5:23   ` Denis Kenzior
2012-05-29 16:38 ` Philippe Nunes [this message]
2012-05-30  5:42   ` [PATCH 3/6] error-mapping: Add function to map telephony errors into ofono " Denis Kenzior
2012-05-29 16:38 ` [PATCH 4/6] build: Add error-mapping utility to build Philippe Nunes
2012-05-29 16:38 ` [PATCH 5/6] Return specific ofono errors according telephony errors Philippe Nunes
2012-05-29 16:38 ` [PATCH 6/6] Extend the list of ofono error types returned by the method initiate Philippe Nunes
2012-05-30  5:45   ` 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=1338309517-14808-4-git-send-email-philippe.nunes@linux.intel.com \
    --to=philippe.nunes@linux.intel.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 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.