• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

  • tdeio
  • tdeio
kfilterbase.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000 David Faure <faure@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #include "kfilterbase.h"
20 #include <klibloader.h>
21 #include <kmimetype.h>
22 #include <ktrader.h>
23 #include <kdebug.h>
24 
25 KFilterBase::KFilterBase()
26  : m_dev( 0L ), m_bAutoDel( false )
27 {
28 }
29 
30 KFilterBase::~KFilterBase()
31 {
32  if ( m_bAutoDel )
33  delete m_dev;
34 }
35 
36 void KFilterBase::setDevice( TQIODevice * dev, bool autodelete )
37 {
38  m_dev = dev;
39  m_bAutoDel = autodelete;
40 }
41 
42 KFilterBase * KFilterBase::findFilterByFileName( const TQString & fileName )
43 {
44  KMimeType::Ptr mime = KMimeType::findByPath( fileName );
45  kdDebug(7005) << "KFilterBase::findFilterByFileName mime=" << mime->name() << endl;
46  return findFilterByMimeType(mime->name());
47 }
48 
49 KFilterBase * KFilterBase::findFilterByMimeType( const TQString & mimeType )
50 {
51  TDETrader::OfferList offers = TDETrader::self()->query( "TDECompressionFilter",
52  TQString("'") + mimeType + "' in ServiceTypes" );
53  TDETrader::OfferList::ConstIterator it = offers.begin();
54  TDETrader::OfferList::ConstIterator end = offers.end();
55 
56  kdDebug(7005) << "KFilterBase::findFilterByMimeType(" << mimeType << ") got " << offers.count() << " offers" << endl;
57  for (; it != end; ++it )
58  {
59  if ((*it)->library().isEmpty()) { continue; }
60  KLibFactory *factory = KLibLoader::self()->factory((*it)->library().latin1());
61  if (!factory) { continue; }
62  KFilterBase *filter = static_cast<KFilterBase*>( factory->create(0, (*it)->desktopEntryName().latin1() ) );
63  if ( filter )
64  return filter;
65  }
66 
67  if ( mimeType == "application/x-bzip2" || mimeType == "application/x-gzip" ) // #88574
68  kdWarning(7005) << "KFilterBase::findFilterByMimeType : no filter found for " << mimeType << endl;
69 
70  return 0L;
71 }
72 
73 void KFilterBase::virtual_hook( int, void* )
74 { /*BASE::virtual_hook( id, data );*/ }
75 
76 #include "kfilterbase.moc"
TDETrader::self
static TDETrader * self()
This is a static pointer to a TDETrader instance.
Definition: ktrader.cpp:90
KFilterBase::findFilterByFileName
static KFilterBase * findFilterByFileName(const TQString &fileName)
Call this to create the appropriate filter for the file named fileName.
Definition: kfilterbase.cpp:42
KFilterBase::findFilterByMimeType
static KFilterBase * findFilterByMimeType(const TQString &mimeType)
Call this to create the appropriate filter for the mimetype mimeType.
Definition: kfilterbase.cpp:49
KFilterBase::setDevice
void setDevice(TQIODevice *dev, bool autodelete=false)
Sets the device on which the filter will work.
Definition: kfilterbase.cpp:36
KMimeType::findByPath
static Ptr findByPath(const TQString &path, mode_t mode=0, bool fast_mode=false)
Finds a KMimeType with the given _url.
Definition: kmimetype.cpp:308
TDETrader::query
virtual OfferList query(const TQString &servicetype, const TQString &constraint=TQString::null, const TQString &preferences=TQString::null) const
The main function in the TDETrader class.
Definition: ktrader.cpp:106
KFilterBase
This is the base class for compression filters such as gzip and bzip2.
Definition: kfilterbase.h:38
TDETrader::OfferList
TQValueList< KService::Ptr > OfferList
A list of services.
Definition: ktrader.h:92

tdeio/tdeio

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

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.8.8
This website is maintained by Timothy Pearson.