qgpgme
dataprovider.h
00001 /* dataprovider.h 00002 Copyright (C) 2004 Klarälvdalens Datakonsult AB 00003 00004 This file is part of QGPGME. 00005 00006 QGPGME is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU Library General Public License as published 00008 by the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 QGPGME is distributed in the hope that it will be useful, but 00012 WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with QGPGME; see the file COPYING.LIB. If not, write to the 00018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. */ 00020 00021 // -*- c++ -*- 00022 #ifndef __QGPGME_DATAPROVIDER_H__ 00023 #define __QGPGME_DATAPROVIDER_H__ 00024 00025 #include "qgpgme_export.h" 00026 #include <gpgme++/interfaces/dataprovider.h> 00027 00028 #include <QtCore/QByteArray> 00029 00030 #include <boost/shared_ptr.hpp> 00031 00032 class QIODevice; 00033 00034 namespace QGpgME { 00035 00036 class QGPGME_EXPORT QByteArrayDataProvider : public GpgME::DataProvider { 00037 public: 00038 QByteArrayDataProvider(); 00039 explicit QByteArrayDataProvider( const QByteArray & initialData ); 00040 ~QByteArrayDataProvider(); 00041 00042 const QByteArray & data() const { return mArray; } 00043 00044 private: 00045 // these shall only be accessed through the dataprovider 00046 // interface, where they're public: 00048 bool isSupported( Operation ) const { return true; } 00050 ssize_t read( void * buffer, size_t bufSize ); 00052 ssize_t write( const void * buffer, size_t bufSize ); 00054 off_t seek( off_t offset, int whence ); 00056 void release(); 00057 00058 private: 00059 QByteArray mArray; 00060 off_t mOff; 00061 }; 00062 00063 class QGPGME_EXPORT QIODeviceDataProvider : public GpgME::DataProvider { 00064 public: 00065 explicit QIODeviceDataProvider( const boost::shared_ptr<QIODevice> & initialData ); 00066 ~QIODeviceDataProvider(); 00067 00068 const boost::shared_ptr<QIODevice> & ioDevice() const { return mIO; } 00069 00070 private: 00071 // these shall only be accessed through the dataprovider 00072 // interface, where they're public: 00074 bool isSupported( Operation ) const; 00076 ssize_t read( void * buffer, size_t bufSize ); 00078 ssize_t write( const void * buffer, size_t bufSize ); 00080 off_t seek( off_t offset, int whence ); 00082 void release(); 00083 00084 private: 00085 const boost::shared_ptr<QIODevice> mIO; 00086 bool mErrorOccurred : 1; 00087 bool mHaveQProcess : 1; 00088 }; 00089 00090 } // namespace QGpgME 00091 00092 #endif // __QGPGME_EVENTLOOPINTERACTOR_H__ 00093 00094
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:08:58 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:08:58 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.