gnome-scan r792 - in trunk: . modules/gsane
- From: bersace svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-scan r792 - in trunk: . modules/gsane
- Date: Thu, 15 Jan 2009 19:18:09 +0000 (UTC)
Author: bersace
Date: Thu Jan 15 19:18:09 2009
New Revision: 792
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=792&view=rev
Log:
Translate SANE_Status to GnomeScanStatus.
Modified:
trunk/ChangeLog
trunk/modules/gsane/gsane-common.c
trunk/modules/gsane/gsane-common.h
Modified: trunk/modules/gsane/gsane-common.c
==============================================================================
--- trunk/modules/gsane/gsane-common.c (original)
+++ trunk/modules/gsane/gsane-common.c Thu Jan 15 19:18:09 2009
@@ -33,13 +33,58 @@
return g_quark_from_static_string("gsane-sane-error");
}
+guint
+gsane_status_to_error_code(SANE_Status status)
+{
+
+ switch(status) {
+ case SANE_STATUS_UNSUPPORTED:
+ return GSANE_ERROR_UNSUPPORTED;
+ break;
+ case SANE_STATUS_CANCELLED:
+ return GSANE_ERROR_CANCELLED;
+ break;
+ case SANE_STATUS_DEVICE_BUSY:
+ return GSANE_ERROR_BUSY;
+ break;
+ case SANE_STATUS_INVAL:
+ return GSANE_ERROR_INVALID_VALUE;
+ break;
+ case SANE_STATUS_JAMMED:
+ return GSANE_ERROR_JAMMED;
+ break;
+ case SANE_STATUS_NO_DOCS:
+ return GSANE_ERROR_NO_DOCS;
+ break;
+ case SANE_STATUS_COVER_OPEN:
+ return GSANE_ERROR_COVER_OPEN;
+ break;
+ case SANE_STATUS_IO_ERROR:
+ return GSANE_ERROR_IO_ERROR;
+ break;
+ case SANE_STATUS_NO_MEM:
+ return GSANE_ERROR_NO_MEM;
+ break;
+ case SANE_STATUS_ACCESS_DENIED:
+ return GSANE_ERROR_DENIED;
+ break;
+ default:
+ return GNOME_SCAN_STATUS_UNKNOWN;
+ break;
+ }
+}
+
GError*
gsane_error_new_from_status(SANE_Status status)
{
+ guint code;
+
if (status == SANE_STATUS_GOOD)
return NULL;
- return g_error_new_literal(GSANE_ERROR, status, S_(sane_strstatus(status)));
+ code = gsane_status_to_error_code(status);
+
+ return g_error_new_literal(GSANE_ERROR, code, S_(sane_strstatus(status)));
}
void
Modified: trunk/modules/gsane/gsane-common.h
==============================================================================
--- trunk/modules/gsane/gsane-common.h (original)
+++ trunk/modules/gsane/gsane-common.h Thu Jan 15 19:18:09 2009
@@ -30,6 +30,7 @@
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <sane/sane.h>
+#include <gnome-scan-common.h>
G_BEGIN_DECLS
@@ -48,21 +49,22 @@
#define GSANE_ERROR gsane_sane_error_quark()
typedef enum {
- GSANE_ERROR_UNSUPPORTED = SANE_STATUS_UNSUPPORTED,
- GSANE_ERROR_CANCELLED = SANE_STATUS_CANCELLED,
- GSANE_ERROR_BUSY = SANE_STATUS_DEVICE_BUSY,
- GSANE_ERROR_INVALID_VALUE = SANE_STATUS_INVAL,
- GSANE_ERROR_JAMMED = SANE_STATUS_JAMMED,
- GSANE_ERROR_NO_DOCS = SANE_STATUS_NO_DOCS,
- GSANE_ERROR_COVER_OPEN = SANE_STATUS_COVER_OPEN,
- GSANE_ERROR_IO_ERROR = SANE_STATUS_IO_ERROR,
- GSANE_ERROR_NO_MEM = SANE_STATUS_NO_MEM,
- GSANE_ERROR_DENIED = SANE_STATUS_ACCESS_DENIED,
+ GSANE_ERROR_UNSUPPORTED = GNOME_SCAN_STATUS_FAILED + 1,
+ GSANE_ERROR_INVALID_VALUE = GNOME_SCAN_STATUS_FAILED + 2,
+ GSANE_ERROR_JAMMED = GNOME_SCAN_STATUS_FAILED + 3,
+ GSANE_ERROR_NO_DOCS = GNOME_SCAN_STATUS_FAILED + 4,
+ GSANE_ERROR_COVER_OPEN = GNOME_SCAN_STATUS_FAILED + 5,
+ GSANE_ERROR_IO_ERROR = GNOME_SCAN_STATUS_FAILED + 6,
+ GSANE_ERROR_NO_MEM = GNOME_SCAN_STATUS_FAILED + 7,
+ GSANE_ERROR_DENIED = GNOME_SCAN_STATUS_FAILED + 8,
+ GSANE_ERROR_CANCELLED = GNOME_SCAN_STATUS_DONE + 1,
+ GSANE_ERROR_BUSY = GNOME_SCAN_STATUS_BUSY + 1,
GSANE_ERROR_OPTION_INACTIVE,
GSANE_ERROR_OPTION_READONLY,
} GSaneError;
GQuark gsane_sane_error_quark(void) G_GNUC_CONST;
+guint gsane_status_to_error_code(SANE_Status status);
GError* gsane_error_new_from_status(SANE_Status status);
void gsane_propagate_status(GError **dest, SANE_Status status);
void gsane_propagate_prefixed_status(GError **dest, SANE_Status status, const gchar* format, ...);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]