00001 /* 00002 00003 Copyright (C) 2005-2007 by Peter Dimov. 00004 00005 This file is part of Calitko (http://www.calitko.org). 00006 00007 Calitko is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 Calitko is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Calitko; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 00021 */ 00022 00023 #ifndef HTTP__BODY_WRITER_H 00024 #define HTTP__BODY_WRITER_H 00025 00026 #include "Imports.h" 00027 00028 // Open containing namespaces: 00029 namespace Http { 00031 00033 00036 class BodyWriter : public QObject 00037 { 00038 Q_OBJECT 00039 REFERENCE_OBJECT (BodyWriter) 00040 00041 public: 00042 BodyWriter (Connection *connection); 00043 ~BodyWriter(); 00044 00045 void write (QIODevice *file, qint64 bodySize); 00046 bool canWrite() const; 00047 00048 signals: 00049 void bodyWritten(); 00050 void writeError(); 00051 void readError(); 00052 00053 private slots: 00054 void bytesWritten (qint64); 00055 00056 private: 00057 enum Constants 00058 { 00059 BufferSize = 1024 00060 }; 00061 00062 class Private 00063 { 00064 REFERENCE_OBJECT (Private) 00065 00066 public: 00067 Connection *connection; 00068 QIODevice *file; 00069 qint64 bodySize; 00070 qint64 bytesWritten; 00071 char buffer [BufferSize]; 00072 qint64 bufferRead; 00073 qint64 bufferWritten; 00074 00075 Private() : connection (0), file (0), bodySize (0), bytesWritten (0), 00076 buffer(), bufferRead (0), bufferWritten (0) 00077 {} 00078 } p; 00079 }; 00080 00081 // Close containing namespaces: 00082 } // namespace Http 00084 00085 #endif // HTTP__BODY_WRITER_H