• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

kfilterbase.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2000-2005 David Faure <faure@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include "kfilterbase.h"
00020 #include <config.h>
00021 
00022 #include <kdebug.h>
00023 #include <QtCore/QIODevice>
00024 #include <kmimetype.h>
00025 #include "kgzipfilter.h"
00026 #ifdef HAVE_BZIP2_SUPPORT
00027 #include "kbzip2filter.h"
00028 #endif
00029 
00030 KFilterBase::KFilterBase()
00031     : m_dev( 0L ), m_bAutoDel( false ), d(0)
00032 {
00033 }
00034 
00035 KFilterBase::~KFilterBase()
00036 {
00037     if ( m_bAutoDel )
00038         delete m_dev;
00039 }
00040 
00041 void KFilterBase::setDevice( QIODevice * dev, bool autodelete )
00042 {
00043     m_dev = dev;
00044     m_bAutoDel = autodelete;
00045 }
00046 
00047 QIODevice * KFilterBase::device()
00048 {
00049     return m_dev;
00050 }
00051 
00052 bool KFilterBase::inBufferEmpty() const
00053 {
00054     return inBufferAvailable() == 0;
00055 }
00056 
00057 bool KFilterBase::outBufferFull() const
00058 {
00059     return outBufferAvailable() == 0;
00060 }
00061 
00062 KFilterBase * KFilterBase::findFilterByFileName( const QString & fileName )
00063 {
00064     if ( fileName.endsWith( ".gz", Qt::CaseInsensitive ) )
00065     {
00066         return new KGzipFilter;
00067     }
00068 #ifdef HAVE_BZIP2_SUPPORT
00069     if ( fileName.endsWith( ".bz2", Qt::CaseInsensitive ) )
00070     {
00071         return new KBzip2Filter;
00072     }
00073 #endif
00074     else
00075     {
00076         // not a warning, since this is called often with other mimetypes (see #88574)...
00077         // maybe we can avoid that though?
00078         kDebug(7005) << "KFilterBase::findFilterByFileName : no filter found for " << fileName;
00079     }
00080 
00081     return 0;
00082 }
00083 
00084 KFilterBase * KFilterBase::findFilterByMimeType( const QString & mimeType )
00085 {
00086     KMimeType::Ptr mime = KMimeType::mimeType(mimeType);
00087     if ( mimeType == QLatin1String( "application/x-gzip" ) || (mime && mime->is("application/x-gzip")) )
00088     {
00089         return new KGzipFilter;
00090     }
00091 #ifdef HAVE_BZIP2_SUPPORT
00092     else if ( mimeType == QLatin1String( "application/x-bzip" )
00093               || mimeType == QLatin1String( "application/x-bzip2" ) // old name, kept for compatibility
00094               || (mime && mime->is("application/x-bzip")) )
00095     {
00096         return new KBzip2Filter;
00097     }
00098 #endif
00099     else
00100     {
00101         // not a warning, since this is called often with other mimetypes (see #88574)...
00102         // maybe we can avoid that though?
00103         kDebug(7005) << "KFilterBase::findFilterByMimeType : no filter found for " << mimeType;
00104     }
00105 
00106     return 0;
00107 }
00108 
00109 void KFilterBase::terminate()
00110 {
00111 }
00112 
00113 void KFilterBase::reset()
00114 {
00115 }
00116 
00117 void KFilterBase::virtual_hook( int, void* )
00118 { /*BASE::virtual_hook( id, data );*/ }
00119 

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal