# kio Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kfilterbase.cpp

    00001 /* This file is part of the KDE libraries
    00002    Copyright (C) 2000 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., 59 Temple Place - Suite 330,
    00016    Boston, MA 02111-1307, USA.
    00017 */
    00018
    00019 #include "kfilterbase.h"
    00020 #include <klibloader.h>
    00021 #include <kmimetype.h>
    00022 #include <ktrader.h>
    00023 #include <kdebug.h>
    00024
    00025 KFilterBase::KFilterBase()
    00026     : m_dev( 0L ), m_bAutoDel( false )
    00027 {
    00028 }
    00029
    00030 KFilterBase::~KFilterBase()
    00031 {
    00032     if ( m_bAutoDel )
    00033         delete m_dev;
    00034 }
    00035
    00036 void KFilterBase::setDevice( QIODevice * dev, bool autodelete )
    00037 {
    00038     m_dev = dev;
    00039     m_bAutoDel = autodelete;
    00040 }
    00041
    00042 KFilterBase * KFilterBase::findFilterByFileName( const QString & fileName )
    00043 {
    00044     KMimeType::Ptr mime = KMimeType::findByPath( fileName );
    00045     kdDebug(7005) << "KFilterBase::findFilterByFileName mime=" << mime->name() << endl;
    00046     return findFilterByMimeType(mime->name());
    00047 }
    00048
    00049 KFilterBase * KFilterBase::findFilterByMimeType( const QString & mimeType )
    00050 {
    00051     KTrader::OfferList offers = KTrader::self()->query( "KDECompressionFilter",
    00052                                                         QString("'") + mimeType + "' in ServiceTypes" );
    00053     KTrader::OfferList::ConstIterator it = offers.begin();
    00054     KTrader::OfferList::ConstIterator end = offers.end();
    00055
    00056     kdDebug(7005) << "KFilterBase::findFilterByMimeType got " << offers.count() << " offers" << endl;
    00057     for (; it != end; ++it )
    00058     {
    00059         if ((*it)->library().isEmpty()) { continue; }
    00060         KLibFactory *factory = KLibLoader::self()->factory((*it)->library().latin1());
    00061         if (!factory) { continue; }
    00062         KFilterBase *filter = static_cast<KFilterBase*>( factory->create(0, (*it)->desktopEntryName().latin1() ) );
    00063         if ( filter )
    00064             return filter;
    00065     }
    00066     kdWarning() << "KFilterBase::findFilterByExtension : no filter found for " << mimeType << endl;
    00067
    00068     return 0L;
    00069 }
    00070
    00071 void KFilterBase::virtual_hook( int, void* )
    00072 { /*BASE::virtual_hook( id, data );*/ }
    00073
    00074 #include "kfilterbase.moc"

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:13:36 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001