kioinputstream_impl.h

00001     /*
00002 
00003     Copyright (C) 2001 Nikolas Zimmermann <wildfox@kde.org>
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 as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009   
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 
00020     */
00021 
00022 #ifndef KIOINPUTSTREAM_IMPL
00023 #define KIOINPUTSTREAM_IMPL
00024 
00025 #include <qobject.h>
00026 #include <qcstring.h>
00027 #include <kio/jobclasses.h>
00028 #include <kurl.h>
00029 #include "artskde.h"
00030 #include "stdsynthmodule.h" 
00031 
00032 namespace Arts {
00033 
00034 class KIOInputStream_impl : public QObject, virtual public KIOInputStream_skel, 
00035                         virtual public InputStream_skel,
00036                         virtual public StdSynthModule
00037 {
00038 Q_OBJECT
00039 public:
00040     KIOInputStream_impl();
00041     ~KIOInputStream_impl();
00042     
00043     void streamStart(); 
00044     void streamEnd();
00045 
00046     bool eof();
00047     bool seekOk();
00048     long size();
00049     long seek(long);
00050 
00051     bool openURL(const std::string& url);
00052 
00053     void processQueue();
00054     void request_outdata(DataPacket<mcopbyte> *packet);
00055 
00056     long bufferPackets() { return m_packetBuffer; }
00057     void bufferPackets(long i) { m_packetBuffer = i; }
00058 
00059     long packetSize() { return m_packetSize; }
00060 
00061 signals:
00062     void mimeTypeFound(const QString & mimetype);
00063     
00064 private slots:
00065     void slotData(KIO::Job *, const QByteArray &);
00066     void slotResult(KIO::Job *);
00067     void slotScanMimeType(KIO::Job *, const QString &mimetype);
00068     void slotTotalSize(KIO::Job *, KIO::filesize_t size);
00069 
00070 private:
00071     KURL m_url;
00072     KIO::TransferJob *m_job;
00073     QByteArray m_data;
00074     bool m_finished;
00075     bool m_firstBuffer;
00076     bool m_streamStarted;
00077     bool m_streamSuspended;
00078     bool m_streamPulled;
00079 
00080     unsigned int m_packetBuffer;
00081     const unsigned int m_packetSize;
00082     KIO::filesize_t m_size;
00083     
00084     static const unsigned int PACKET_COUNT;
00085 };
00086 
00087 }
00088 
00089 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys