cupsdconf.h

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #ifndef CUPSDCONF_H
00021 #define CUPSDCONF_H
00022 
00023 #include <qstring.h>
00024 #include <qstringlist.h>
00025 #include <qptrlist.h>
00026 #include <qtextstream.h>
00027 #include <qpair.h>
00028 
00029 #include "cupsdcomment.h"
00030 
00031 enum LogLevelType { LOGLEVEL_DEBUG2 = 0, LOGLEVEL_DEBUG, LOGLEVEL_INFO, LOGLEVEL_WARN, LOGLEVEL_ERROR, LOGLEVEL_NONE };
00032 enum OrderType { ORDER_ALLOW_DENY = 0, ORDER_DENY_ALLOW };
00033 enum AuthTypeType { AUTHTYPE_NONE = 0, AUTHTYPE_BASIC, AUTHTYPE_DIGEST };
00034 enum AuthClassType { AUTHCLASS_ANONYMOUS = 0, AUTHCLASS_USER, AUTHCLASS_SYSTEM, AUTHCLASS_GROUP };
00035 enum EncryptionType { ENCRYPT_ALWAYS = 0, ENCRYPT_NEVER, ENCRYPT_REQUIRED, ENCRYPT_IFREQUESTED };
00036 enum BrowseProtocolType { BROWSE_ALL = 0, BROWSE_CUPS, BROWSE_SLP };
00037 enum PrintcapFormatType { PRINTCAP_BSD = 0, PRINTCAP_SOLARIS };
00038 enum HostnameLookupType { HOSTNAME_OFF = 0, HOSTNAME_ON, HOSTNAME_DOUBLE };
00039 enum ClassificationType { CLASS_NONE = 0, CLASS_CLASSIFIED, CLASS_CONFIDENTIAL, CLASS_SECRET, CLASS_TOPSECRET, CLASS_UNCLASSIFIED, CLASS_OTHER };
00040 enum SatisfyType { SATISFY_ALL = 0, SATISFY_ANY };
00041 enum UnitType { UNIT_KB = 0, UNIT_MB, UNIT_GB, UNIT_TILE };
00042 
00043 struct CupsLocation;
00044 struct CupsResource;
00045 enum ResourceType { RESOURCE_GLOBAL, RESOURCE_PRINTER, RESOURCE_CLASS, RESOURCE_ADMIN };
00046 
00047 struct CupsdConf
00048 {
00049 // functions member
00050     CupsdConf();
00051     ~CupsdConf();
00052 
00053     bool loadFromFile(const QString& filename);
00054     bool saveToFile(const QString& filename);
00055     bool parseOption(const QString& line);
00056     bool parseLocation(CupsLocation *location, QTextStream& file);
00057 
00058     bool loadAvailableResources();
00059 
00060     static CupsdConf* get();
00061     static void release();
00062 
00063 // data members
00064     static CupsdConf    *unique_;
00065 
00066     // Server
00067     QString servername_;
00068     QString serveradmin_;
00069     int classification_;
00070     QString otherclassname_;
00071     bool classoverride_;
00072     QString charset_;
00073     QString language_;
00074     QString printcap_;
00075     int printcapformat_;
00076 
00077     // Security
00078     QString remoteroot_;
00079     QString systemgroup_;
00080     QString encryptcert_;
00081     QString encryptkey_;
00082     QPtrList<CupsLocation> locations_;
00083     QPtrList<CupsResource> resources_;
00084 
00085     // Network
00086     int hostnamelookup_;
00087     bool keepalive_;
00088     int keepalivetimeout_;
00089     int maxclients_;
00090     QString maxrequestsize_;
00091     int clienttimeout_;
00092     QStringList listenaddresses_;
00093 
00094     // Log
00095     QString accesslog_;
00096     QString errorlog_;
00097     QString pagelog_;
00098     QString maxlogsize_;
00099     int loglevel_;
00100 
00101     // Jobs
00102     bool keepjobhistory_;
00103     bool keepjobfiles_;
00104     bool autopurgejobs_;
00105     int maxjobs_;
00106     int maxjobsperprinter_;
00107     int maxjobsperuser_;
00108 
00109     // Filter
00110     QString user_;
00111     QString group_;
00112     QString ripcache_;
00113     int filterlimit_;
00114 
00115     // Directories
00116     QString datadir_;
00117     QString documentdir_;
00118     QStringList fontpath_;
00119     QString requestdir_;
00120     QString serverbin_;
00121     QString serverfiles_;
00122     QString tmpfiles_;
00123 
00124     // Browsing
00125     bool browsing_;
00126     QStringList browseprotocols_;
00127     int browseport_;
00128     int browseinterval_;
00129     int browsetimeout_;
00130     QStringList browseaddresses_;
00131     int browseorder_;
00132     bool useimplicitclasses_;
00133     bool hideimplicitmembers_;
00134     bool useshortnames_;
00135     bool useanyclasses_;
00136     
00137     // cupsd.conf file comments
00138     CupsdComment    comments_;
00139     
00140     // unrecognized options
00141     QValueList< QPair<QString,QString> >    unknown_;
00142 };
00143 
00144 struct CupsLocation
00145 {
00146     CupsLocation();
00147     CupsLocation(const CupsLocation& loc);
00148 
00149     bool parseOption(const QString& line);
00150     bool parseResource(const QString& line);
00151 
00152     CupsResource    *resource_;
00153     QString resourcename_;
00154     int authtype_;
00155     int authclass_;
00156     QString authname_;
00157     int encryption_;
00158     int satisfy_;
00159     int order_;
00160     QStringList addresses_;
00161 };
00162 
00163 struct CupsResource
00164 {
00165     CupsResource();
00166     CupsResource(const QString& path);
00167 
00168     void setPath(const QString& path);
00169 
00170     int type_;
00171     QString path_;
00172     QString text_;
00173 
00174     static QString textToPath(const QString& text);
00175     static QString pathToText(const QString& path);
00176     static int typeFromPath(const QString& path);
00177     static int typeFromText(const QString& text);
00178     static QString typeToIconName(int type);
00179 };
00180 
00181 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys