1 /* This file is part of the KDE Project         -*- mode:c++; -*-
2    Copyright (C) 1999 Klaas Freitag <freitag@suse.de>
3    Copyright (C) 2009 Jonathan Marten <jjm@keelhaul.me.uk>
4 
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public
7    License as published by the Free Software Foundation; either
8    version 2 of the License, or (at your option) any later version.
9 
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14 
15    You should have received a copy of the GNU Library General Public License
16    along with this library; see the file COPYING.LIB.  If not, write to
17    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18    Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef SCANDEVICES_H
22 #define SCANDEVICES_H
23 
24 #include "kookascan_export.h"
25 
26 #include <qbytearray.h>
27 #include <qlist.h>
28 #include <qhash.h>
29 
30 extern "C" {
31 #include <sane/sane.h>                  // to define SANE_Device
32 }
33 
34 class KOOKASCAN_EXPORT ScanDevices
35 {
36 public:
37     static ScanDevices *self();
38 
39     /**
40      *  returns the names of all existing Scan Devices in the system.
41      */
allDevices()42     const QList<QByteArray> &allDevices() const
43     {
44         return (mScannerNames);
45     }
46 
47     /**
48      *  returns the SANE device information for a Scan Device.
49      */
50     const SANE_Device *deviceInfo(const QByteArray &backend) const;
51 
52     /**
53      *  returns a readable device description for a Scan Device.
54      */
55     QString deviceDescription(const QByteArray &backend) const;
56 
57     /**
58      *  Add an explicitly specified device to the list of known ones.
59      *   @param backend the device name+parameters of the backend to add
60      *   @param description a readable description for it
61      *   @param dontSave if @c true, don't save the new device in the permanent configuration
62      */
63     void addUserSpecifiedDevice(const QByteArray &backend,
64                                 const QString &description,
65                                 const QByteArray &type = "",
66                                 bool dontSave = false);
67 
68 private:
69     explicit ScanDevices();
70     ~ScanDevices();
71 
72 private:
73     QList<QByteArray> mScannerNames;
74     QHash<QByteArray, const SANE_Device *> mScannerDevices;
75 
76     class ScanDevicesPrivate;
77     ScanDevicesPrivate *d;
78 };
79 
80 #endif                          // SCANDEVICES_H
81