kdeprint Library API Documentation

ipprequest.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., 59 Temple Place - Suite 330, 00017 * Boston, MA 02111-1307, USA. 00018 **/ 00019 00020 #ifndef IPPREQUEST_H 00021 #define IPPREQUEST_H 00022 00023 #include <qstring.h> 00024 #include <qstringlist.h> 00025 #include <qtextstream.h> 00026 #include <qmap.h> 00027 00028 #include <cups/ipp.h> 00029 00030 class IppRequest 00031 { 00032 public: 00033 IppRequest(); 00034 ~IppRequest(); 00035 00036 void init(); // re-initializes the request 00037 00038 // request building functions 00039 void addMime(int group, const QString& name, const QString& mime); 00040 void addKeyword(int group, const QString& name, const QString& key); 00041 void addKeyword(int group, const QString& name, const QStringList& keys); 00042 void addURI(int group, const QString& name, const QString& uri); 00043 void addURI(int group, const QString& name, const QStringList& uris); 00044 void addText(int group, const QString& name, const QString& txt); 00045 void addText(int group, const QString& name, const QStringList& txts); 00046 void addName(int group, const QString& name, const QString& nm); 00047 void addName(int group, const QString& name, const QStringList& nms); 00048 void addInteger(int group, const QString& name, int value); 00049 void addInteger(int group, const QString& name, const QValueList<int>& values); 00050 void addEnum(int group, const QString& name, int value); 00051 void addEnum(int group, const QString& name, const QValueList<int>& values); 00052 void addBoolean(int group, const QString& name, bool value); 00053 void addBoolean(int group, const QString& name, const QValueList<bool>& values); 00054 00055 void setOperation(int op); 00056 void setHost(const QString& host); 00057 void setPort(int p); 00058 00059 // request answer functions 00060 int status(); 00061 QString statusMessage(); 00062 bool integer(const QString& name, int& value); 00063 bool boolean(const QString& name, bool& value); 00064 bool enumvalue(const QString& name, int& value); 00065 bool name(const QString& name, QString& value); 00066 bool name(const QString& name, QStringList& value); 00067 bool text(const QString& name, QString& value); 00068 bool text(const QString& name, QStringList& value); 00069 bool uri(const QString& name, QString& value); 00070 bool uri(const QString& name, QStringList& value); 00071 bool keyword(const QString& name, QString& value); 00072 bool keyword(const QString& name, QStringList& value); 00073 bool mime(const QString& name, QString& value); 00074 ipp_attribute_t* first(); 00075 ipp_attribute_t* last(); 00076 QMap<QString,QString> toMap(int group = -1); 00077 void setMap(const QMap<QString,QString>& opts); 00078 00079 // processing functions 00080 bool doRequest(const QString& res); 00081 bool doFileRequest(const QString& res, const QString& filename = QString::null); 00082 00083 // report functions 00084 bool htmlReport(int group, QTextStream& output); 00085 00086 // debug function 00087 void dump(int state); 00088 00089 protected: 00090 void addString_p(int group, int type, const QString& name, const QString& value); 00091 void addStringList_p(int group, int type, const QString& name, const QStringList& values); 00092 void addInteger_p(int group, int type, const QString& name, int value); 00093 void addIntegerList_p(int group, int type, const QString& name, const QValueList<int>& values); 00094 bool stringValue_p(const QString& name, QString& value, int type); 00095 bool stringListValue_p(const QString& name, QStringList& values, int type); 00096 bool integerValue_p(const QString& name, int& value, int type); 00097 00098 private: 00099 ipp_t *request_; 00100 QString host_; 00101 int port_; 00102 bool connect_; 00103 int dump_; 00104 }; 00105 00106 inline void IppRequest::addMime(int group, const QString& name, const QString& mime) 00107 { addString_p(group, IPP_TAG_MIMETYPE, name, mime); } 00108 00109 inline void IppRequest::addKeyword(int group, const QString& name, const QString& key) 00110 { addString_p(group, IPP_TAG_KEYWORD, name, key); } 00111 00112 inline void IppRequest::addKeyword(int group, const QString& name, const QStringList& keys) 00113 { addStringList_p(group, IPP_TAG_KEYWORD, name, keys); } 00114 00115 inline void IppRequest::addURI(int group, const QString& name, const QString& uri) 00116 { addString_p(group, IPP_TAG_URI, name, uri); } 00117 00118 inline void IppRequest::addURI(int group, const QString& name, const QStringList& uris) 00119 { addStringList_p(group, IPP_TAG_URI, name, uris); } 00120 00121 inline void IppRequest::addText(int group, const QString& name, const QString& txt) 00122 { addString_p(group, IPP_TAG_TEXT, name, txt); } 00123 00124 inline void IppRequest::addText(int group, const QString& name, const QStringList& txts) 00125 { addStringList_p(group, IPP_TAG_TEXT, name, txts); } 00126 00127 inline void IppRequest::addName(int group, const QString& name, const QString& nm) 00128 { addString_p(group, IPP_TAG_NAME, name, nm); } 00129 00130 inline void IppRequest::addName(int group, const QString& name, const QStringList& nms) 00131 { addStringList_p(group, IPP_TAG_NAME, name, nms); } 00132 00133 inline void IppRequest::addInteger(int group, const QString& name, int value) 00134 { addInteger_p(group, IPP_TAG_INTEGER, name, value); } 00135 00136 inline void IppRequest::addInteger(int group, const QString& name, const QValueList<int>& values) 00137 { addIntegerList_p(group, IPP_TAG_INTEGER, name, values); } 00138 00139 inline void IppRequest::addEnum(int group, const QString& name, int value) 00140 { addInteger_p(group, IPP_TAG_ENUM, name, value); } 00141 00142 inline void IppRequest::addEnum(int group, const QString& name, const QValueList<int>& values) 00143 { addIntegerList_p(group, IPP_TAG_ENUM, name, values); } 00144 00145 inline bool IppRequest::integer(const QString& name, int& value) 00146 { return integerValue_p(name, value, IPP_TAG_INTEGER); } 00147 00148 inline bool IppRequest::enumvalue(const QString& name, int& value) 00149 { return integerValue_p(name, value, IPP_TAG_ENUM); } 00150 00151 inline bool IppRequest::name(const QString& name, QString& value) 00152 { return stringValue_p(name, value, IPP_TAG_NAME); } 00153 00154 inline bool IppRequest::name(const QString& name, QStringList& values) 00155 { return stringListValue_p(name, values, IPP_TAG_NAME); } 00156 00157 inline bool IppRequest::text(const QString& name, QString& value) 00158 { return stringValue_p(name, value, IPP_TAG_TEXT); } 00159 00160 inline bool IppRequest::text(const QString& name, QStringList& values) 00161 { return stringListValue_p(name, values, IPP_TAG_TEXT); } 00162 00163 inline bool IppRequest::uri(const QString& name, QString& value) 00164 { return stringValue_p(name, value, IPP_TAG_URI); } 00165 00166 inline bool IppRequest::uri(const QString& name, QStringList& values) 00167 { return stringListValue_p(name, values, IPP_TAG_URI); } 00168 00169 inline bool IppRequest::keyword(const QString& name, QString& value) 00170 { return stringValue_p(name, value, IPP_TAG_KEYWORD); } 00171 00172 inline bool IppRequest::keyword(const QString& name, QStringList& values) 00173 { return stringListValue_p(name, values, IPP_TAG_KEYWORD); } 00174 00175 inline bool IppRequest::mime(const QString& name, QString& value) 00176 { return stringValue_p(name, value, IPP_TAG_MIMETYPE); } 00177 00178 inline bool IppRequest::doRequest(const QString& res) 00179 { return doFileRequest(res); } 00180 00181 inline ipp_attribute_t* IppRequest::first() 00182 { return (request_ ? request_->attrs : NULL); } 00183 00184 inline ipp_attribute_t* IppRequest::last() 00185 { return (request_ ? request_->last : NULL); } 00186 00187 inline void IppRequest::setHost(const QString& host) 00188 { host_ = host; } 00189 00190 inline void IppRequest::setPort(int p) 00191 { port_ = p; } 00192 00193 inline void IppRequest::dump(int state) 00194 { dump_ = state; } 00195 00196 #endif
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:41:50 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003