1 /*
2 SANE EPSON backend
3 Copyright (C) 2001 SEIKO EPSON Corporation
4
5 Date Author Reason
6 06/01/2001 N.Sasaki New
7
8 This file is part of the `iscan' program.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 As a special exception, the copyright holders give permission
25 to link the code of this program with the esmod library and
26 distribute linked combinations including the two. You must obey
27 the GNU General Public License in all respects for all of the
28 code used other then esmod.
29 */
30
31 #include <config.h>
32
33 #include "gettext.h"
34 #define _(msg_id) gettext (msg_id)
35
36 /*------------------------------------------------------------*/
37 #include "pisa_error.h"
38
39
pisa_error(pisa_error_id status)40 pisa_error::pisa_error( pisa_error_id status )
41 : m_id( status )
42 {
43 }
44
pisa_error(SANE_Status status)45 pisa_error::pisa_error( SANE_Status status )
46 : m_id( pisa_error_id( status | 0xff00 ) )
47 {
48 }
49
get_error_string(void) const50 const char * pisa_error::get_error_string ( void ) const
51 {
52 switch (remap())
53 {
54 // Let's get the SANE status IDs out of the way first.
55 case PISA_STATUS_GOOD:
56 return _("Operation completed succesfully.");
57 case PISA_STATUS_UNSUPPORTED:
58 return _("Operation is not supported.");
59 case PISA_STATUS_CANCELLED:
60 return _("Operation was cancelled.");
61 case PISA_STATUS_DEVICE_BUSY:
62 return _("Device is busy---retry later.");
63 case PISA_STATUS_INVAL:
64 return _("Data or argument is invalid.");
65 case PISA_STATUS_EOF:
66 return _("No more data available (end-of-file).");
67 case PISA_STATUS_JAMMED:
68 return _("A paper jam occured. "
69 "Open the Automatic Document Feeder and remove any paper.");
70 case PISA_STATUS_NO_DOCS:
71 return _("Please load the document(s) into the Automatic Document "
72 "Feeder.");
73 case PISA_STATUS_COVER_OPEN:
74 return _("The automatic document feeder or scanner unit is open.\n"
75 "Please close it.");
76 case PISA_STATUS_IO_ERROR:
77 return _("Error during device I/O.");
78 case PISA_STATUS_NO_MEM:
79 return _("Out of memory.");
80 case PISA_STATUS_ACCESS_DENIED:
81 return _("Access to resource has been denied.");
82 // Now we add our own.
83 case PISA_ERR_OUTOFMEMORY:
84 return _( "There is not enough disk space for operation" );
85
86 case PISA_ERR_CONNECT:
87 return _( "Could not send command to scanner.\n"
88 "Check the scanner's status." );
89
90 case PISA_ERR_UNSUPPORT:
91 return _( "Scanner model not supported" );
92
93 case PISA_ERR_AREALARGE:
94 return _( "Selected area is too large for this resolution.\n"
95 "Reduce the selected area or resolution." );
96
97 case PISA_ERR_FILENAME:
98 return _( "Could not create file" );
99
100 case PISA_ERR_FILEOPEN:
101 return _( "Could not create file" );
102
103 case PISA_ERR_OVERWRITE:
104 return _( "Overwrite?" );
105
106 case PISA_ERR_MRRESTOOHIGH:
107 return _( "The Image Type setting you selected cannot be used "
108 "with this resolution.\n"
109 "Reduce the Resolution or Scale setting." );
110
111 default:
112 break;
113 }
114
115 return _( "Unexpected error occurred" );
116 }
117
118 pisa_error_id
remap() const119 pisa_error::remap() const
120 {
121 switch (m_id)
122 {
123 // do what pase_sane_scan.cc used (yuck!) to do, except for
124 // statuses that we really need to special case
125 case PISA_STATUS_UNSUPPORTED:
126 case PISA_STATUS_CANCELLED:
127 case PISA_STATUS_DEVICE_BUSY:
128 case PISA_STATUS_INVAL:
129 case PISA_STATUS_EOF:
130 case PISA_STATUS_IO_ERROR:
131 case PISA_STATUS_NO_MEM:
132 case PISA_STATUS_ACCESS_DENIED:
133 return PISA_ERR_CONNECT;
134 default:
135 return m_id;
136 }
137 return PISA_ERR_INVALID_ERROR_ID;
138 }
139