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

tdeio/tdeio

  • tdeio
  • tdeio
kmimetype.cpp
1 /* This file is part of the KDE libraries
2  * Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
3  * David Faure <faure@kde.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License version 2 as published by the Free Software Foundation;
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  **/
19 // $Id$
20 
21 #include <config.h>
22 
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 
26 #include <assert.h>
27 #include <dirent.h>
28 #include <errno.h>
29 #include <stddef.h>
30 #include <unistd.h>
31 #include <stdlib.h>
32 
33 #include <kprotocolinfo.h>
34 #include <tdeio/global.h>
35 #include "kmimetype.h"
36 #include "kservicetypefactory.h"
37 #include "kmimemagic.h"
38 #include "kservice.h"
39 #include "krun.h"
40 #include "kautomount.h"
41 #include <kdirnotify_stub.h>
42 
43 #include <tqstring.h>
44 #include <tqfile.h>
45 #include <kmessageboxwrapper.h>
46 
47 #include <dcopclient.h>
48 #include <dcopref.h>
49 #include <tdeapplication.h>
50 #include <kprocess.h>
51 #include <kdebug.h>
52 #include <kdesktopfile.h>
53 #include <kdirwatch.h>
54 #include <kiconloader.h>
55 #include <tdelocale.h>
56 #include <ksimpleconfig.h>
57 #include <kstandarddirs.h>
58 #include <kurl.h>
59 #include <tdesycoca.h>
60 #include <kde_file.h>
61 
62 template class TDESharedPtr<KMimeType>;
63 template class TQValueList<KMimeType::Ptr>;
64 
65 KMimeType::Ptr KMimeType::s_pDefaultType = 0L;
66 bool KMimeType::s_bChecked = false;
67 
68 void KMimeType::buildDefaultType()
69 {
70  assert ( !s_pDefaultType );
71  // Try to find the default type
72  KServiceType * mime = KServiceTypeFactory::self()->
73  findServiceTypeByName( defaultMimeType() );
74 
75  if (mime && mime->isType( KST_KMimeType ))
76  {
77  s_pDefaultType = KMimeType::Ptr((KMimeType *) mime);
78  }
79  else
80  {
81  errorMissingMimeType( defaultMimeType() );
82  TDEStandardDirs stdDirs;
83  TQString sDefaultMimeType = stdDirs.resourceDirs("mime").first()+defaultMimeType()+".desktop";
84  s_pDefaultType = new KMimeType( sDefaultMimeType, defaultMimeType(),
85  "unknown", "mime", TQStringList() );
86  }
87 }
88 
89 KMimeType::Ptr KMimeType::defaultMimeTypePtr()
90 {
91  if ( !s_pDefaultType ) // we need a default type first
92  buildDefaultType();
93  return s_pDefaultType;
94 }
95 
96 // Check for essential mimetypes
97 void KMimeType::checkEssentialMimeTypes()
98 {
99  if ( s_bChecked ) // already done
100  return;
101  if ( !s_pDefaultType ) // we need a default type first
102  buildDefaultType();
103 
104  s_bChecked = true; // must be done before building mimetypes
105 
106  // No Mime-Types installed ?
107  // Lets do some rescue here.
108  if ( !KServiceTypeFactory::self()->checkMimeTypes() )
109  {
110  KMessageBoxWrapper::error( 0L, i18n( "No mime types installed." ) );
111  return; // no point in going any further
112  }
113 
114  if ( KMimeType::mimeType( "inode/directory" ) == s_pDefaultType )
115  errorMissingMimeType( "inode/directory" );
116  if ( KMimeType::mimeType( "inode/directory-locked" ) == s_pDefaultType )
117  errorMissingMimeType( "inode/directory-locked" );
118  if ( KMimeType::mimeType( "inode/blockdevice" ) == s_pDefaultType )
119  errorMissingMimeType( "inode/blockdevice" );
120  if ( KMimeType::mimeType( "inode/chardevice" ) == s_pDefaultType )
121  errorMissingMimeType( "inode/chardevice" );
122  if ( KMimeType::mimeType( "inode/socket" ) == s_pDefaultType )
123  errorMissingMimeType( "inode/socket" );
124  if ( KMimeType::mimeType( "inode/fifo" ) == s_pDefaultType )
125  errorMissingMimeType( "inode/fifo" );
126  if ( KMimeType::mimeType( "application/x-shellscript" ) == s_pDefaultType )
127  errorMissingMimeType( "application/x-shellscript" );
128  if ( KMimeType::mimeType( "application/x-executable" ) == s_pDefaultType )
129  errorMissingMimeType( "application/x-executable" );
130  if ( KMimeType::mimeType( "application/x-desktop" ) == s_pDefaultType )
131  errorMissingMimeType( "application/x-desktop" );
132 }
133 
134 void KMimeType::errorMissingMimeType( const TQString& _type )
135 {
136  TQString tmp = i18n( "Could not find mime type\n%1" ).arg( _type );
137 
138  KMessageBoxWrapper::sorry( 0, tmp );
139 }
140 
141 KMimeType::Ptr KMimeType::mimeType( const TQString& _name )
142 {
143  KServiceType * mime = KServiceTypeFactory::self()->findServiceTypeByName( _name );
144 
145  if ( !mime || !mime->isType( KST_KMimeType ) )
146  {
147  // When building tdesycoca, findServiceTypeByName doesn't create an object
148  // but returns one from a dict.
149  if ( !KSycoca::self()->isBuilding() )
150  delete mime;
151  if ( !s_pDefaultType )
152  buildDefaultType();
153  return s_pDefaultType;
154  }
155 
156  // We got a mimetype
157  return KMimeType::Ptr((KMimeType *) mime);
158 }
159 
160 KMimeType::List KMimeType::allMimeTypes()
161 {
162  return KServiceTypeFactory::self()->allMimeTypes();
163 }
164 
165 KMimeType::Ptr KMimeType::findByURL( const KURL& _url, mode_t _mode,
166  bool _is_local_file, bool _fast_mode )
167 {
168  checkEssentialMimeTypes();
169  TQString path = _url.path();
170 
171  if ( !_fast_mode && !_is_local_file && _url.isLocalFile() )
172  _is_local_file = true;
173 
174  if ( !_fast_mode && _is_local_file && (_mode == 0 || _mode == (mode_t)-1) )
175  {
176  KDE_struct_stat buff;
177  if ( KDE_stat( TQFile::encodeName(path), &buff ) != -1 )
178  _mode = buff.st_mode;
179  }
180 
181  // Look at mode_t first
182  if ( S_ISDIR( _mode ) )
183  {
184  // Special hack for local files. We want to see whether we
185  // are allowed to enter the directory
186  if ( _is_local_file )
187  {
188  if ( access( TQFile::encodeName(path), R_OK ) == -1 )
189  return mimeType( "inode/directory-locked" );
190  }
191  return mimeType( "inode/directory" );
192  }
193  if ( S_ISCHR( _mode ) )
194  return mimeType( "inode/chardevice" );
195  if ( S_ISBLK( _mode ) )
196  return mimeType( "inode/blockdevice" );
197  if ( S_ISFIFO( _mode ) )
198  return mimeType( "inode/fifo" );
199  if ( S_ISSOCK( _mode ) )
200  return mimeType( "inode/socket" );
201  // KMimeMagic can do that better for local files
202  if ( !_is_local_file && S_ISREG( _mode ) && ( _mode & ( S_IXUSR | S_IXGRP | S_IXOTH ) ) )
203  return mimeType( "application/x-executable" );
204 
205  TQString fileName ( _url.fileName() );
206 
207  static const TQString& slash = TDEGlobal::staticQString("/");
208  if ( ! fileName.isNull() && !path.endsWith( slash ) )
209  {
210  // Try to find it out by looking at the filename
211  KMimeType::Ptr mime = KServiceTypeFactory::self()->findFromPattern( fileName );
212  if ( mime )
213  {
214  // Found something - can we trust it ? (e.g. don't trust *.pl over HTTP, could be anything)
215  if ( _is_local_file || _url.hasSubURL() || // Explicitly trust suburls
216  KProtocolInfo::determineMimetypeFromExtension( _url.protocol() ) )
217  {
218  if ( _is_local_file && !_fast_mode ) {
219  if ( mime->patternsAccuracy()<100 )
220  {
221  KMimeMagicResult* result =
222  KMimeMagic::self()->findFileType( path );
223 
224  if ( result && result->isValid() && result->accuracy() > 0 ) {
225  KMimeType::Ptr resultMime = mimeType( result->mimeType() );
226  if (resultMime->patternsAccuracy() > 0) {
227  return resultMime;
228  }
229  }
230  }
231  }
232 
233  return mime;
234  }
235  }
236 
237  static const TQString& dotdesktop = TDEGlobal::staticQString(".desktop");
238  static const TQString& dotkdelnk = TDEGlobal::staticQString(".kdelnk");
239  static const TQString& dotdirectory = TDEGlobal::staticQString(".directory");
240 
241  // Another filename binding, hardcoded, is .desktop:
242  if ( fileName.endsWith( dotdesktop ) )
243  return mimeType( "application/x-desktop" );
244  // Another filename binding, hardcoded, is .kdelnk;
245  // this is preserved for backwards compatibility
246  if ( fileName.endsWith( dotkdelnk ) )
247  return mimeType( "application/x-desktop" );
248  // .directory files are detected as x-desktop by mimemagic
249  // but don't have a Type= entry. Better cheat and say they are text files
250  if ( fileName == dotdirectory )
251  return mimeType( "text/plain" );
252  }
253 
254  if ( !_is_local_file || _fast_mode )
255  {
256  TQString def = KProtocolInfo::defaultMimetype( _url );
257  if ( !def.isEmpty() && def != defaultMimeType() )
258  {
259  // The protocol says it always returns a given mimetype (e.g. text/html for "man:")
260  return mimeType( def );
261  }
262  if ( path.endsWith( slash ) || path.isEmpty() )
263  {
264  // We have no filename at all. Maybe the protocol has a setting for
265  // which mimetype this means (e.g. directory).
266  // For HTTP (def==defaultMimeType()) we don't assume anything,
267  // because of redirections (e.g. freshmeat downloads).
268  if ( def.isEmpty() )
269  {
270  // Assume inode/directory, if the protocol supports listing.
271  if ( KProtocolInfo::supportsListing( _url ) )
272  return mimeType( TQString::fromLatin1("inode/directory") );
273  else
274  return defaultMimeTypePtr(); // == 'no idea', e.g. for "data:,foo/"
275  }
276  }
277 
278  // No more chances for non local URLs
279  return defaultMimeTypePtr();
280  }
281 
282  // Do some magic for local files
283  //kdDebug(7009) << TQString("Mime Type finding for '%1'").arg(path) << endl;
284  KMimeMagicResult* result = KMimeMagic::self()->findFileType( path );
285 
286  // If we still did not find it, we must assume the default mime type
287  if ( !result || !result->isValid() )
288  return defaultMimeTypePtr();
289 
290  // The mimemagic stuff was successful
291  return mimeType( result->mimeType() );
292 }
293 
294 KMimeType::Ptr KMimeType::findByURL( const KURL& _url, mode_t _mode,
295  bool _is_local_file, bool _fast_mode,
296  bool *accurate)
297 {
298  KMimeType::Ptr mime = findByURL(_url, _mode, _is_local_file, _fast_mode);
299  if (accurate) *accurate = !(_fast_mode) || ((mime->patternsAccuracy() == 100) && mime != defaultMimeTypePtr());
300  return mime;
301 }
302 
303 KMimeType::Ptr KMimeType::diagnoseFileName(const TQString &fileName, TQString &pattern)
304 {
305  return KServiceTypeFactory::self()->findFromPattern( fileName, &pattern );
306 }
307 
308 KMimeType::Ptr KMimeType::findByPath( const TQString& path, mode_t mode, bool fast_mode )
309 {
310  KURL u;
311  u.setPath(path);
312  return findByURL( u, mode, true, fast_mode );
313 }
314 
315 KMimeType::Ptr KMimeType::findByContent( const TQByteArray &data, int *accuracy )
316 {
317  KMimeMagicResult *result = KMimeMagic::self()->findBufferType(data);
318  if (accuracy)
319  *accuracy = result->accuracy();
320  return mimeType( result->mimeType() );
321 }
322 
323 KMimeType::Ptr KMimeType::findByFileContent( const TQString &fileName, int *accuracy )
324 {
325  KMimeMagicResult *result = KMimeMagic::self()->findFileType(fileName);
326  if (accuracy)
327  *accuracy = result->accuracy();
328  return mimeType( result->mimeType() );
329 }
330 
331 #define GZIP_MAGIC1 0x1f
332 #define GZIP_MAGIC2 0x8b
333 
334 KMimeType::Format KMimeType::findFormatByFileContent( const TQString &fileName )
335 {
336  KMimeType::Format result;
337  result.compression = Format::NoCompression;
338  KMimeType::Ptr mime = findByPath(fileName);
339 
340  result.text = mime->name().startsWith("text/");
341  TQVariant v = mime->property("X-TDE-text");
342  if (v.isValid())
343  result.text = v.toBool();
344 
345  if (mime->name().startsWith("inode/"))
346  return result;
347 
348  TQFile f(fileName);
349  if (f.open(IO_ReadOnly))
350  {
351  unsigned char buf[10+1];
352  int l = f.readBlock((char *)buf, 10);
353  if ((l > 2) && (buf[0] == GZIP_MAGIC1) && (buf[1] == GZIP_MAGIC2))
354  result.compression = Format::GZipCompression;
355  }
356  return result;
357 }
358 
359 KMimeType::KMimeType( const TQString & _fullpath, const TQString& _type, const TQString& _icon,
360  const TQString& _comment, const TQStringList& _patterns )
361  : KServiceType( _fullpath, _type, _icon, _comment )
362 {
363  m_lstPatterns = _patterns;
364 }
365 
366 KMimeType::KMimeType( const TQString & _fullpath ) : KServiceType( _fullpath )
367 {
368  KDesktopFile _cfg( _fullpath, true );
369  init ( &_cfg );
370 
371  if ( !isValid() )
372  kdWarning(7009) << "mimetype not valid '" << m_strName << "' (missing entry in the file ?)" << endl;
373 }
374 
375 KMimeType::KMimeType( KDesktopFile *config ) : KServiceType( config )
376 {
377  init( config );
378 
379  if ( !isValid() )
380  kdWarning(7009) << "mimetype not valid '" << m_strName << "' (missing entry in the file ?)" << endl;
381 }
382 
383 void KMimeType::init( KDesktopFile * config )
384 {
385  config->setDesktopGroup();
386  m_lstPatterns = config->readListEntry( "Patterns", ';' );
387 
388  // Read the X-TDE-AutoEmbed setting and store it in the properties map
389  TQString XKDEAutoEmbed = TQString::fromLatin1("X-TDE-AutoEmbed");
390  if ( config->hasKey( XKDEAutoEmbed ) )
391  m_mapProps.insert( XKDEAutoEmbed, TQVariant( config->readBoolEntry( XKDEAutoEmbed ), 0 ) );
392 
393  TQString XKDEText = TQString::fromLatin1("X-TDE-text");
394  if ( config->hasKey( XKDEText ) )
395  m_mapProps.insert( XKDEText, config->readBoolEntry( XKDEText ) );
396 
397  TQString XKDEIsAlso = TQString::fromLatin1("X-TDE-IsAlso");
398  if ( config->hasKey( XKDEIsAlso ) ) {
399  TQString inherits = config->readEntry( XKDEIsAlso );
400  if ( inherits != name() )
401  m_mapProps.insert( XKDEIsAlso, inherits );
402  else
403  kdWarning(7009) << "Error: " << inherits << " inherits from itself!!!!" << endl;
404  }
405 
406  TQString XKDEPatternsAccuracy = TQString::fromLatin1("X-TDE-PatternsAccuracy");
407  if ( config->hasKey( XKDEPatternsAccuracy ) )
408  m_mapProps.insert( XKDEPatternsAccuracy, config->readEntry( XKDEPatternsAccuracy ) );
409 
410 }
411 
412 KMimeType::KMimeType( TQDataStream& _str, int offset ) : KServiceType( _str, offset )
413 {
414  loadInternal( _str ); // load our specific stuff
415 }
416 
417 void KMimeType::load( TQDataStream& _str )
418 {
419  KServiceType::load( _str );
420  loadInternal( _str );
421 }
422 
423 void KMimeType::loadInternal( TQDataStream& _str )
424 {
425  // kdDebug(7009) << "KMimeType::load( TQDataStream& ) : loading list of patterns" << endl;
426  _str >> m_lstPatterns;
427 }
428 
429 void KMimeType::save( TQDataStream& _str )
430 {
431  KServiceType::save( _str );
432  // Warning adding/removing fields here involves a binary incompatible change - update version
433  // number in tdesycoca.h
434  _str << m_lstPatterns;
435 }
436 
437 TQVariant KMimeType::property( const TQString& _name ) const
438 {
439  if ( _name == "Patterns" )
440  return TQVariant( m_lstPatterns );
441 
442  return KServiceType::property( _name );
443 }
444 
445 TQStringList KMimeType::propertyNames() const
446 {
447  TQStringList res = KServiceType::propertyNames();
448  res.append( "Patterns" );
449 
450  return res;
451 }
452 
453 KMimeType::~KMimeType()
454 {
455 }
456 
457 TQPixmap KMimeType::pixmap( TDEIcon::Group _group, int _force_size, int _state,
458  TQString * _path ) const
459 {
460  TDEIconLoader *iconLoader=TDEGlobal::iconLoader();
461  TQString iconName=icon( TQString::null, false );
462  if (!iconLoader->extraDesktopThemesAdded())
463  {
464  TQPixmap pixmap=iconLoader->loadIcon( iconName, _group, _force_size, _state, _path, true );
465  if (!pixmap.isNull() ) return pixmap;
466 
467  iconLoader->addExtraDesktopThemes();
468  }
469 
470  return iconLoader->loadIcon( iconName , _group, _force_size, _state, _path, false );
471 }
472 
473 TQPixmap KMimeType::pixmap( const KURL& _url, TDEIcon::Group _group, int _force_size,
474  int _state, TQString * _path ) const
475 {
476  TDEIconLoader *iconLoader=TDEGlobal::iconLoader();
477  TQString iconName=icon( _url, _url.isLocalFile() );
478  if (!iconLoader->extraDesktopThemesAdded())
479  {
480  TQPixmap pixmap=iconLoader->loadIcon( iconName, _group, _force_size, _state, _path, true );
481  if (!pixmap.isNull() ) return pixmap;
482 
483  iconLoader->addExtraDesktopThemes();
484  }
485 
486  return iconLoader->loadIcon( iconName , _group, _force_size, _state, _path, false );
487 }
488 
489 TQPixmap KMimeType::pixmapForURL( const KURL & _url, mode_t _mode, TDEIcon::Group _group,
490  int _force_size, int _state, TQString * _path )
491 {
492  TDEIconLoader *iconLoader=TDEGlobal::iconLoader();
493  TQString iconName = iconForURL( _url, _mode );
494 
495  if (!iconLoader->extraDesktopThemesAdded())
496  {
497  TQPixmap pixmap=iconLoader->loadIcon( iconName, _group, _force_size, _state, _path, true );
498  if (!pixmap.isNull() ) return pixmap;
499 
500  iconLoader->addExtraDesktopThemes();
501  }
502 
503  return iconLoader->loadIcon( iconName , _group, _force_size, _state, _path, false );
504 
505 }
506 
507 TQString KMimeType::iconForURL( const KURL & _url, mode_t _mode )
508 {
509  const KMimeType::Ptr mt = findByURL( _url, _mode, _url.isLocalFile(),
510  false /*HACK*/);
511  static const TQString& unknown = TDEGlobal::staticQString("unknown");
512  const TQString mimeTypeIcon = mt->icon( _url, _url.isLocalFile() );
513  TQString i = mimeTypeIcon;
514 
515  // if we don't find an icon, maybe we can use the one for the protocol
516  if ( i == unknown || i.isEmpty() || mt == defaultMimeTypePtr()
517  // and for the root of the protocol (e.g. trash:/) the protocol icon has priority over the mimetype icon
518  || _url.path().length() <= 1 )
519  {
520  i = favIconForURL( _url ); // maybe there is a favicon?
521 
522  if ( i.isEmpty() )
523  i = KProtocolInfo::icon( _url.protocol() );
524 
525  // root of protocol: if we found nothing, revert to mimeTypeIcon (which is usually "folder")
526  if ( _url.path().length() <= 1 && ( i == unknown || i.isEmpty() ) )
527  i = mimeTypeIcon;
528  }
529  return i;
530 }
531 
532 TQString KMimeType::favIconForURL( const KURL& url )
533 {
534  // this method will be called quite often, so better not read the config
535  // again and again.
536  static bool useFavIcons = true;
537  static bool check = true;
538  if ( check ) {
539  check = false;
540  TDEConfig *config = TDEGlobal::config();
541  TDEConfigGroupSaver cs( config, "HTML Settings" );
542  useFavIcons = config->readBoolEntry( "EnableFavicon", true );
543  }
544 
545  if ( url.isLocalFile() || !url.protocol().startsWith("http")
546  || !useFavIcons )
547  return TQString::null;
548 
549  DCOPRef kded( "kded", "favicons" );
550  DCOPReply result = kded.call( "iconForURL(KURL)", url );
551  if ( result.isValid() )
552  return result;
553 
554  return TQString::null;
555 }
556 
557 TQString KMimeType::parentMimeType() const
558 {
559  TQVariant v = property("X-TDE-IsAlso");
560  return v.toString();
561 }
562 
563 bool KMimeType::is( const TQString& mimeTypeName ) const
564 {
565  if ( name() == mimeTypeName )
566  return true;
567  TQString st = parentMimeType();
568  //if (st.isEmpty()) kdDebug(7009)<<"Parent mimetype is empty"<<endl;
569  while ( !st.isEmpty() )
570  {
571  //kdDebug(7009)<<"Checking parent mime type: "<<st<<endl;
572  KMimeType::Ptr ptr = KMimeType::mimeType( st );
573  if (!ptr) return false; //error
574  if ( ptr->name() == mimeTypeName )
575  return true;
576  st = ptr->parentMimeType();
577  }
578  return false;
579 }
580 
581 int KMimeType::patternsAccuracy() const {
582  TQVariant v = property("X-TDE-PatternsAccuracy");
583  if (!v.isValid()) return 100;
584  else
585  return v.toInt();
586 }
587 
588 
589 /*******************************************************
590  *
591  * KFolderType
592  *
593  ******************************************************/
594 
595 TQString KFolderType::icon( const TQString& _url, bool _is_local ) const
596 {
597  if ( !_is_local || _url.isEmpty() )
598  return KMimeType::icon( _url, _is_local );
599 
600  return KFolderType::icon( KURL(_url), _is_local );
601 }
602 
603 TQString KFolderType::icon( const KURL& _url, bool _is_local ) const
604 {
605  if ( !_is_local )
606  return KMimeType::icon( _url, _is_local );
607 
608  KURL u( _url );
609  u.addPath( ".directory" );
610 
611  TQString icon;
612  // using TDEStandardDirs as this one checks for path being
613  // a file instead of a directory
614  if ( TDEStandardDirs::exists( u.path() ) )
615  {
616  KSimpleConfig cfg( u.path(), true );
617  cfg.setDesktopGroup();
618  icon = cfg.readEntry( "Icon" );
619  TQString empty_icon = cfg.readEntry( "EmptyIcon" );
620 
621  if ( !empty_icon.isEmpty() )
622  {
623  bool isempty = false;
624  DIR *dp = 0L;
625  struct dirent *ep;
626  dp = opendir( TQFile::encodeName(_url.path()) );
627  if ( dp )
628  {
629  TQValueList<TQCString> entries;
630  // Note that readdir isn't guaranteed to return "." and ".." first (#79826)
631  ep=readdir( dp ); if ( ep ) entries.append( ep->d_name );
632  ep=readdir( dp ); if ( ep ) entries.append( ep->d_name );
633  if ( (ep=readdir( dp )) == 0L ) // third file is NULL entry -> empty directory
634  isempty = true;
635  else {
636  entries.append( ep->d_name );
637  if ( readdir( dp ) == 0 ) { // only three
638  // check if we got "." ".." and ".directory"
639  isempty = entries.find( "." ) != entries.end() &&
640  entries.find( ".." ) != entries.end() &&
641  entries.find( ".directory" ) != entries.end();
642  }
643  }
644  if (!isempty && !strcmp(ep->d_name, ".directory"))
645  isempty = (readdir(dp) == 0L);
646  closedir( dp );
647  }
648 
649  if ( isempty )
650  return empty_icon;
651  }
652  }
653 
654  if ( icon.isEmpty() )
655  return KMimeType::icon( _url, _is_local );
656 
657  if ( icon.startsWith( "./" ) ) {
658  // path is relative with respect to the location
659  // of the .directory file (#73463)
660  KURL v( _url );
661  v.addPath( icon.mid( 2 ) );
662  icon = v.path();
663  }
664 
665  return icon;
666 }
667 
668 TQString KFolderType::comment( const TQString& _url, bool _is_local ) const
669 {
670  if ( !_is_local || _url.isEmpty() )
671  return KMimeType::comment( _url, _is_local );
672 
673  return KFolderType::comment( KURL(_url), _is_local );
674 }
675 
676 TQString KFolderType::comment( const KURL& _url, bool _is_local ) const
677 {
678  if ( !_is_local )
679  return KMimeType::comment( _url, _is_local );
680 
681  KURL u( _url );
682  u.addPath( ".directory" );
683 
684  KDesktopFile cfg( u.path(), true );
685  TQString comment = cfg.readComment();
686  if ( comment.isEmpty() )
687  return KMimeType::comment( _url, _is_local );
688 
689  return comment;
690 }
691 
692 /*******************************************************
693  *
694  * KDEDesktopMimeType
695  *
696  ******************************************************/
697 
698 TQString KDEDesktopMimeType::icon( const TQString& _url, bool _is_local ) const
699 {
700  if ( !_is_local || _url.isEmpty() )
701  return KMimeType::icon( _url, _is_local );
702 
703  KURL u( _url );
704  return icon( u, _is_local );
705 }
706 
707 TQString KDEDesktopMimeType::icon( const KURL& _url, bool _is_local ) const
708 {
709  if ( !_is_local )
710  return KMimeType::icon( _url, _is_local );
711 
712  KSimpleConfig cfg( _url.path(), true );
713  cfg.setDesktopGroup();
714  TQString icon = cfg.readEntry( "Icon" );
715  TQString type = cfg.readEntry( "Type" );
716 
717  if ( type == "FSDevice" || type == "FSDev") // need to provide FSDev for
718  // backwards compatibility
719  {
720  TQString unmount_icon = cfg.readEntry( "UnmountIcon" );
721  TQString dev = cfg.readEntry( "Dev" );
722  if ( !icon.isEmpty() && !unmount_icon.isEmpty() && !dev.isEmpty() )
723  {
724  TQString mp = TDEIO::findDeviceMountPoint( dev );
725  // Is the device not mounted ?
726  if ( mp.isNull() )
727  return unmount_icon;
728  }
729  } else if ( type == "Link" ) {
730  const TQString emptyIcon = cfg.readEntry( "EmptyIcon" );
731  if ( !emptyIcon.isEmpty() ) {
732  const TQString u = cfg.readPathEntry( "URL" );
733  const KURL url( u );
734  if ( url.protocol() == "trash" ) {
735  // We need to find if the trash is empty, preferrably without using a TDEIO job.
736  // So instead tdeio_trash leaves an entry in its config file for us.
737  KSimpleConfig trashConfig( "trashrc", true );
738  trashConfig.setGroup( "Status" );
739  if ( trashConfig.readBoolEntry( "Empty", true ) ) {
740  return emptyIcon;
741  }
742  }
743  }
744  }
745 
746  if ( icon.isEmpty() )
747  return KMimeType::icon( _url, _is_local );
748 
749  return icon;
750 }
751 
752 TQPixmap KDEDesktopMimeType::pixmap( const KURL& _url, TDEIcon::Group _group, int _force_size,
753  int _state, TQString * _path ) const
754 {
755  TQString _icon = icon( _url, _url.isLocalFile() );
756  TQPixmap pix = TDEGlobal::iconLoader()->loadIcon( _icon, _group,
757  _force_size, _state, _path, false );
758  if ( pix.isNull() )
759  pix = TDEGlobal::iconLoader()->loadIcon( "unknown", _group,
760  _force_size, _state, _path, false );
761  return pix;
762 }
763 
764 TQString KDEDesktopMimeType::comment( const TQString& _url, bool _is_local ) const
765 {
766  if ( !_is_local || _url.isEmpty() )
767  return KMimeType::comment( _url, _is_local );
768 
769  KURL u( _url );
770  return comment( u, _is_local );
771 }
772 
773 TQString KDEDesktopMimeType::comment( const KURL& _url, bool _is_local ) const
774 {
775  if ( !_is_local )
776  return KMimeType::comment( _url, _is_local );
777 
778  KDesktopFile cfg( _url.path(), true );
779  TQString comment = cfg.readComment();
780  if ( comment.isEmpty() )
781  return KMimeType::comment( _url, _is_local );
782 
783  return comment;
784 }
785 
786 pid_t KDEDesktopMimeType::run( const KURL& u, bool _is_local )
787 {
788  // It might be a security problem to run external untrusted desktop
789  // entry files
790  if ( !_is_local )
791  return 0;
792 
793  KSimpleConfig cfg( u.path(), true );
794  cfg.setDesktopGroup();
795  TQString type = cfg.readEntry( "Type" );
796  if ( type.isEmpty() )
797  {
798  TQString tmp = i18n("The desktop entry file %1 "
799  "has no Type=... entry.").arg(u.path() );
800  KMessageBoxWrapper::error( 0, tmp);
801  return 0;
802  }
803 
804  //kdDebug(7009) << "TYPE = " << type.data() << endl;
805 
806  if ( type == "FSDevice" )
807  return runFSDevice( u, cfg );
808  else if ( type == "Application" )
809  return runApplication( u, u.path() );
810  else if ( type == "Link" )
811  {
812  cfg.setDollarExpansion( true ); // for URL=file:$HOME (Simon)
813  return runLink( u, cfg );
814  }
815  else if ( type == "MimeType" )
816  return runMimeType( u, cfg );
817 
818 
819  TQString tmp = i18n("The desktop entry of type\n%1\nis unknown.").arg( type );
820  KMessageBoxWrapper::error( 0, tmp);
821 
822  return 0;
823 }
824 
825 pid_t KDEDesktopMimeType::runFSDevice( const KURL& _url, const KSimpleConfig &cfg )
826 {
827  pid_t retval = 0;
828 
829  TQString dev = cfg.readEntry( "Dev" );
830 
831  if ( dev.isEmpty() )
832  {
833  TQString tmp = i18n("The desktop entry file\n%1\nis of type FSDevice but has no Dev=... entry.").arg( _url.path() );
834  KMessageBoxWrapper::error( 0, tmp);
835  return retval;
836  }
837 
838  TQString mp = TDEIO::findDeviceMountPoint( dev );
839  // Is the device already mounted ?
840  if ( !mp.isNull() )
841  {
842  KURL mpURL;
843  mpURL.setPath( mp );
844  // Open a new window
845  retval = KRun::runURL( mpURL, TQString::fromLatin1("inode/directory") );
846  }
847  else
848  {
849  bool ro = cfg.readBoolEntry( "ReadOnly", false );
850  TQString fstype = cfg.readEntry( "FSType" );
851  if ( fstype == "Default" ) // KDE-1 thing
852  fstype = TQString::null;
853  TQString point = cfg.readEntry( "MountPoint" );
854 #ifndef Q_WS_WIN
855  (void) new KAutoMount( ro, fstype, dev, point, _url.path() );
856 #endif
857  retval = -1; // we don't want to return 0, but we don't want to return a pid
858  }
859 
860  return retval;
861 }
862 
863 pid_t KDEDesktopMimeType::runApplication( const KURL& , const TQString & _serviceFile )
864 {
865  KService s( _serviceFile );
866  if ( !s.isValid() )
867  // The error message was already displayed, so we can just quit here
868  return 0;
869 
870  KURL::List lst;
871  return KRun::run( s, lst );
872 }
873 
874 pid_t KDEDesktopMimeType::runLink( const KURL& _url, const KSimpleConfig &cfg )
875 {
876  TQString u = cfg.readPathEntry( "URL" );
877  if ( u.isEmpty() )
878  {
879  TQString tmp = i18n("The desktop entry file\n%1\nis of type Link but has no URL=... entry.").arg( _url.prettyURL() );
880  KMessageBoxWrapper::error( 0, tmp );
881  return 0;
882  }
883 
884  KURL url ( u );
885  KRun* run = new KRun(url);
886 
887  // X-TDE-LastOpenedWith holds the service desktop entry name that
888  // was should be preferred for opening this URL if possible.
889  // This is used by the Recent Documents menu for instance.
890  TQString lastOpenedWidth = cfg.readEntry( "X-TDE-LastOpenedWith" );
891  if ( !lastOpenedWidth.isEmpty() )
892  run->setPreferredService( lastOpenedWidth );
893 
894  return -1; // we don't want to return 0, but we don't want to return a pid
895 }
896 
897 pid_t KDEDesktopMimeType::runMimeType( const KURL& url , const KSimpleConfig & )
898 {
899  // Hmm, can't really use keditfiletype since we might be looking
900  // at the global file, or at a file not in share/mimelnk...
901 
902  TQStringList args;
903  args << "openProperties";
904  args << url.path();
905 
906  int pid;
907  if ( !TDEApplication::tdeinitExec("kfmclient", args, 0, &pid) )
908  return pid;
909 
910  TDEProcess p;
911  p << "kfmclient" << args;
912  p.start(TDEProcess::DontCare);
913  return p.pid();
914 }
915 
916 TQValueList<KDEDesktopMimeType::Service> KDEDesktopMimeType::builtinServices( const KURL& _url )
917 {
918  TQValueList<Service> result;
919 
920  if ( !_url.isLocalFile() )
921  return result;
922 
923  KSimpleConfig cfg( _url.path(), true );
924  cfg.setDesktopGroup();
925  TQString type = cfg.readEntry( "Type" );
926 
927  if ( type.isEmpty() )
928  return result;
929 
930  if ( type == "FSDevice" )
931  {
932  TQString dev = cfg.readEntry( "Dev" );
933  if ( dev.isEmpty() )
934  {
935  TQString tmp = i18n("The desktop entry file\n%1\nis of type FSDevice but has no Dev=... entry.").arg( _url.path() );
936  KMessageBoxWrapper::error( 0, tmp);
937  }
938  else
939  {
940  TQString mp = TDEIO::findDeviceMountPoint( dev );
941  // not mounted ?
942  if ( mp.isEmpty() )
943  {
944  Service mount;
945  mount.m_strName = i18n("Mount");
946  mount.m_type = ST_MOUNT;
947  result.append( mount );
948  }
949  else
950  {
951  Service unmount;
952 #ifdef HAVE_VOLMGT
953  /*
954  * Solaris' volume management can only umount+eject
955  */
956  unmount.m_strName = i18n("Eject");
957 #else
958  unmount.m_strName = i18n("Unmount");
959 #endif
960  unmount.m_type = ST_UNMOUNT;
961  result.append( unmount );
962  }
963  }
964  }
965 
966  return result;
967 }
968 
969 TQValueList<KDEDesktopMimeType::Service> KDEDesktopMimeType::userDefinedServices( const TQString& path, bool bLocalFiles )
970 {
971  KSimpleConfig cfg( path, true );
972  return userDefinedServices( path, cfg, bLocalFiles );
973 }
974 
975 TQValueList<KDEDesktopMimeType::Service> KDEDesktopMimeType::userDefinedServices( const TQString& path, TDEConfig& cfg, bool bLocalFiles )
976 {
977  return userDefinedServices( path, cfg, bLocalFiles, KURL::List() );
978 }
979 
980 TQValueList<KDEDesktopMimeType::Service> KDEDesktopMimeType::userDefinedServices( const TQString& path, TDEConfig& cfg, bool bLocalFiles, const KURL::List & file_list )
981 {
982  TQValueList<Service> result;
983 
984  cfg.setDesktopGroup();
985 
986  if ( !cfg.hasKey( "Actions" ) && !cfg.hasKey( "X-TDE-GetActionMenu") )
987  return result;
988 
989  if ( cfg.hasKey( "TryExec" ) )
990  {
991  TQString tryexec = cfg.readPathEntry( "TryExec" );
992  TQString exe = TDEStandardDirs::findExe( tryexec );
993  if (exe.isEmpty()) {
994  return result;
995  }
996  }
997 
998  TQStringList keys;
999 
1000  if( cfg.hasKey( "X-TDE-GetActionMenu" )) {
1001  TQString dcopcall = cfg.readEntry( "X-TDE-GetActionMenu" );
1002  const TQCString app = TQString(dcopcall.section(' ', 0,0)).utf8();
1003 
1004  TQByteArray dataToSend;
1005  TQDataStream dataStream(dataToSend, IO_WriteOnly);
1006  dataStream << file_list;
1007  TQCString replyType;
1008  TQByteArray replyData;
1009  TQCString object = TQString(dcopcall.section(' ', 1,-2)).utf8();
1010  TQString function = dcopcall.section(' ', -1);
1011  if(!function.endsWith("(KURL::List)")) {
1012  kdWarning() << "Desktop file " << path << " contains an invalid X-TDE-ShowIfDcopCall - the function must take the exact parameter (KURL::List) and must be specified." << endl;
1013  } else {
1014  if(kapp->dcopClient()->call( app, object,
1015  function.utf8(),
1016  dataToSend, replyType, replyData, true, -1)
1017  && replyType == "TQStringList" ) {
1018 
1019  TQDataStream dataStreamIn(replyData, IO_ReadOnly);
1020  dataStreamIn >> keys;
1021  }
1022  }
1023  }
1024 
1025  keys += cfg.readListEntry( "Actions", ';' ); //the desktop standard defines ";" as separator!
1026 
1027  if ( keys.count() == 0 )
1028  return result;
1029 
1030  TQStringList::ConstIterator it = keys.begin();
1031  TQStringList::ConstIterator end = keys.end();
1032  for ( ; it != end; ++it )
1033  {
1034  //kdDebug(7009) << "CURRENT KEY = " << (*it) << endl;
1035 
1036  TQString group = *it;
1037 
1038  if (group == "_SEPARATOR_")
1039  {
1040  Service s;
1041  result.append(s);
1042  continue;
1043  }
1044 
1045  group.prepend( "Desktop Action " );
1046 
1047  bool bInvalidMenu = false;
1048 
1049  if ( cfg.hasGroup( group ) )
1050  {
1051  cfg.setGroup( group );
1052 
1053  if ( !cfg.hasKey( "Name" ) || !cfg.hasKey( "Exec" ) )
1054  bInvalidMenu = true;
1055  else
1056  {
1057  TQString exec = cfg.readPathEntry( "Exec" );
1058  if ( bLocalFiles || exec.contains("%U") || exec.contains("%u") )
1059  {
1060  Service s;
1061  s.m_strName = cfg.readEntry( "Name" );
1062  s.m_strIcon = cfg.readEntry( "Icon" );
1063  s.m_strExec = exec;
1064  s.m_type = ST_USER_DEFINED;
1065  s.m_display = !cfg.readBoolEntry( "NoDisplay" );
1066  result.append( s );
1067  }
1068  }
1069  }
1070  else
1071  bInvalidMenu = true;
1072 
1073  if ( bInvalidMenu )
1074  {
1075  TQString tmp = i18n("The desktop entry file\n%1\n has an invalid menu entry\n%2.").arg( path ).arg( *it );
1076  KMessageBoxWrapper::error( 0, tmp );
1077  }
1078  }
1079 
1080  return result;
1081 }
1082 
1083 void KDEDesktopMimeType::executeService( const TQString& _url, KDEDesktopMimeType::Service& _service )
1084 {
1085  KURL u;
1086  u.setPath(_url);
1087  KURL::List lst;
1088  lst.append( u );
1089  executeService( lst, _service );
1090 }
1091 
1092 void KDEDesktopMimeType::executeService( const KURL::List& urls, KDEDesktopMimeType::Service& _service )
1093 {
1094  //kdDebug(7009) << "EXECUTING Service " << _service.m_strName << endl;
1095 
1096  if ( _service.m_type == ST_USER_DEFINED )
1097  {
1098  kdDebug() << "KDEDesktopMimeType::executeService " << _service.m_strName
1099  << " first url's path=" << urls.first().path() << " exec=" << _service.m_strExec << endl;
1100  KRun::run( _service.m_strExec, urls, _service.m_strName, _service.m_strIcon, _service.m_strIcon );
1101  // The action may update the desktop file. Example: eject unmounts (#5129).
1102  KDirNotify_stub allDirNotify("*", "KDirNotify*");
1103  allDirNotify.FilesChanged( urls );
1104  return;
1105  }
1106  else if ( _service.m_type == ST_MOUNT || _service.m_type == ST_UNMOUNT )
1107  {
1108  Q_ASSERT( urls.count() == 1 );
1109  TQString path = urls.first().path();
1110  //kdDebug(7009) << "MOUNT&UNMOUNT" << endl;
1111 
1112  KSimpleConfig cfg( path, true );
1113  cfg.setDesktopGroup();
1114  TQString dev = cfg.readEntry( "Dev" );
1115  if ( dev.isEmpty() )
1116  {
1117  TQString tmp = i18n("The desktop entry file\n%1\nis of type FSDevice but has no Dev=... entry.").arg( path );
1118  KMessageBoxWrapper::error( 0, tmp );
1119  return;
1120  }
1121  TQString mp = TDEIO::findDeviceMountPoint( dev );
1122 
1123  if ( _service.m_type == ST_MOUNT )
1124  {
1125  // Already mounted? Strange, but who knows ...
1126  if ( !mp.isEmpty() )
1127  {
1128  kdDebug(7009) << "ALREADY Mounted" << endl;
1129  return;
1130  }
1131 
1132  bool ro = cfg.readBoolEntry( "ReadOnly", false );
1133  TQString fstype = cfg.readEntry( "FSType" );
1134  if ( fstype == "Default" ) // KDE-1 thing
1135  fstype = TQString::null;
1136  TQString point = cfg.readEntry( "MountPoint" );
1137 #ifndef Q_WS_WIN
1138  (void)new KAutoMount( ro, fstype, dev, point, path, false );
1139 #endif
1140  }
1141  else if ( _service.m_type == ST_UNMOUNT )
1142  {
1143  // Not mounted? Strange, but who knows ...
1144  if ( mp.isEmpty() )
1145  return;
1146 
1147 #ifndef Q_WS_WIN
1148  (void)new KAutoUnmount( mp, path );
1149 #endif
1150  }
1151  }
1152  else
1153  assert( 0 );
1154 }
1155 
1156 const TQString & KMimeType::defaultMimeType()
1157 {
1158  static const TQString & s_strDefaultMimeType =
1159  TDEGlobal::staticQString( "application/octet-stream" );
1160  return s_strDefaultMimeType;
1161 }
1162 
1163 void KMimeType::virtual_hook( int id, void* data )
1164 { KServiceType::virtual_hook( id, data ); }
1165 
1166 void KFolderType::virtual_hook( int id, void* data )
1167 { KMimeType::virtual_hook( id, data ); }
1168 
1169 void KDEDesktopMimeType::virtual_hook( int id, void* data )
1170 { KMimeType::virtual_hook( id, data ); }
1171 
1172 void KExecMimeType::virtual_hook( int id, void* data )
1173 { KMimeType::virtual_hook( id, data ); }
1174 
1175 #include "kmimetyperesolver.moc"
1176 
KMimeType::pixmapForURL
static TQPixmap pixmapForURL(const KURL &_url, mode_t _mode=0, TDEIcon::Group _group=TDEIcon::Desktop, int _force_size=0, int _state=0, TQString *_path=0L)
Convenience method to find the pixmap for a URL.
Definition: kmimetype.cpp:489
KMimeType::iconForURL
static TQString iconForURL(const KURL &_url, mode_t _mode=0)
The same functionality as pixmapForURL(), but this method returns the name of the icon to load...
Definition: kmimetype.cpp:507
KDEDesktopMimeType::userDefinedServices
static TQValueList< Service > userDefinedServices(const TQString &path, bool bLocalFiles)
Returns a list of services defined by the user as possible actions on the given .desktop file...
Definition: kmimetype.cpp:969
KMimeType::checkEssentialMimeTypes
static void checkEssentialMimeTypes()
This function makes sure that vital mime types are installed.
Definition: kmimetype.cpp:97
KMimeType::s_bChecked
static bool s_bChecked
true if check for vital mime types has been done.
Definition: kmimetype.h:459
KMimeType::findByContent
static Ptr findByContent(const TQByteArray &data, int *accuracy=0)
Tries to find out the MIME type of a data chunk by looking for certain magic numbers and characterist...
Definition: kmimetype.cpp:315
KMimeType::save
virtual void save(TQDataStream &qs)
Save the mimetype to a stream.
Definition: kmimetype.cpp:429
KRun::runURL
static pid_t runURL(const KURL &_url, const TQString &_mimetype, bool tempFile, bool runExecutables)
Open the given URL.
Definition: krun.cpp:94
KServiceType::propertyNames
virtual TQStringList propertyNames() const
Returns the list of all properties of this service type.
Definition: kservicetype.cpp:194
KAutoMount
This class implements synchronous mounting of devices, as well as showing a file-manager window after...
Definition: kautomount.h:45
KService
Represent a service, i.e.
Definition: kservice.h:48
KMimeMagic::findFileType
KMimeMagicResult * findFileType(const TQString &_filename)
Try to find a MimeType for the given file.
Definition: kmimemagic.cpp:360
KMimeType
Represent a mime type, like "text/plain", and the data that is associated with it.
Definition: kmimetype.h:47
KMimeType::favIconForURL
static TQString favIconForURL(const KURL &url)
Return the "favicon" (see http://www.favicon.com) for the given url, if available.
Definition: kmimetype.cpp:532
KMimeType::parentMimeType
TQString parentMimeType() const
If this mimetype inherits from ("is also") another mimetype, return the name of the parent...
Definition: kmimetype.cpp:557
KRun::setPreferredService
void setPreferredService(const TQString &desktopEntryName)
Set the preferred service for opening this URL, after its mimetype will have been found by KRun...
Definition: krun.cpp:1448
KProtocolInfo::determineMimetypeFromExtension
static bool determineMimetypeFromExtension(const TQString &protocol)
Returns whether mimetypes can be determined based on extension for this protocol. ...
KServiceType::name
TQString name() const
Returns the name of this service type.
Definition: kservicetype.h:106
KServiceType
A service type is the generic notion for a mimetype, a type of service instead of a type of file...
Definition: kservicetype.h:45
KMimeType::mimeType
static Ptr mimeType(const TQString &_name)
Retrieve a pointer to the mime type _name or a pointer to the default mime type "application/octet-st...
Definition: kmimetype.cpp:141
KServiceType::isValid
bool isValid() const
Checks whether the service type is valid.
Definition: kservicetype.h:158
KService::isValid
bool isValid() const
Checks whether the service is valid.
Definition: kservice.h:379
KMimeType::defaultMimeTypePtr
static KMimeType::Ptr defaultMimeTypePtr()
Returns the default mimetype.
Definition: kmimetype.cpp:89
KMimeType::propertyNames
virtual TQStringList propertyNames() const
Retrieves a list of all properties associated with this KMimeType.
Definition: kmimetype.cpp:445
KRun::run
static pid_t run(const KService &_service, const KURL::List &_urls, TQWidget *window, bool tempFiles=false)
Open a list of URLs with a certain service (application).
Definition: krun.cpp:752
KRun
To open files with their associated applications in KDE, use KRun.
Definition: krun.h:58
KMimeMagic::self
static KMimeMagic * self()
Returns a pointer to the unique KMimeMagic instance in this process.
Definition: kmimemagic.cpp:49
KDEDesktopMimeType::pixmap
virtual TQPixmap pixmap(const KURL &_url, TDEIcon::Group _group, int _force_size=0, int _state=0, TQString *_path=0L) const
Find the pixmap for a given file of this mimetype.
Definition: kmimetype.cpp:752
KMimeType::findByFileContent
static Ptr findByFileContent(const TQString &fileName, int *accuracy=0)
Tries to find out the MIME type of a file by looking for certain magic numbers and characteristic str...
Definition: kmimetype.cpp:323
KMimeType::pixmap
virtual TQPixmap pixmap(TDEIcon::Group group, int force_size=0, int state=0, TQString *path=0L) const
Use this function only if you don&#39;t have a special URL for which you search a pixmap.
Definition: kmimetype.cpp:457
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
KAutoUnmount
This class implements synchronous unmounting of devices, It is a wrapper around the asychronous TDEIO...
Definition: kautomount.h:90
KServiceType::icon
TQString icon() const
Returns the icon associated with this service type.
Definition: kservicetype.h:94
KMimeType::findFormatByFileContent
static Format findFormatByFileContent(const TQString &fileName)
Returns whether a file has an internal format that is human readable, or that would be human readable...
Definition: kmimetype.cpp:334
KMimeType::errorMissingMimeType
static void errorMissingMimeType(const TQString &_type)
Signal a missing mime type.
Definition: kmimetype.cpp:134
KProtocolInfo::supportsListing
static bool supportsListing(const KURL &url)
Returns whether the protocol can list files/objects.
Definition: kprotocolinfo.cpp:121
KMimeType::buildDefaultType
static void buildDefaultType()
This function makes sure that the default mime type exists.
Definition: kmimetype.cpp:68
KMimeType::defaultMimeType
static const TQString & defaultMimeType()
Returns the name of the default mimetype.
Definition: kmimetype.cpp:1156
KMimeType::findByURL
static Ptr findByURL(const KURL &_url, mode_t _mode=0, bool _is_local_file=false, bool _fast_mode=false)
Finds a KMimeType with the given _url.
Definition: kmimetype.cpp:165
KMimeMagicResult::isValid
bool isValid() const
Returns whether the result is valid (i.e.
Definition: kmimemagic.h:63
KDEDesktopMimeType::builtinServices
static TQValueList< Service > builtinServices(const KURL &_url)
Returns a list of services for the given .desktop file that are handled by tdeio itself.
Definition: kmimetype.cpp:916
KMimeMagicResult
Definition: kmimemagic.h:46
KMimeMagicResult::mimeType
TQString mimeType() const
Retrieve the mimetype (e.g.
Definition: kmimemagic.h:55
KMimeMagicResult::accuracy
int accuracy() const
Retrieve the accuracy of the matching.
Definition: kmimemagic.h:59
KDEDesktopMimeType::run
static pid_t run(const KURL &_url, bool _is_local)
Invokes the default action for the desktop entry.
Definition: kmimetype.cpp:786
KMimeType::KMimeType
KMimeType(const TQString &_fullpath, const TQString &_type, const TQString &_icon, const TQString &_comment, const TQStringList &_patterns)
Constructor.
Definition: kmimetype.cpp:359
KMimeType::allMimeTypes
static List allMimeTypes()
Get all the mimetypes.
Definition: kmimetype.cpp:160
KDEDesktopMimeType::executeService
static void executeService(const TQString &path, KDEDesktopMimeType::Service &service) KDE_DEPRECATED
Definition: kmimetype.cpp:1083
KMimeType::load
virtual void load(TQDataStream &qs)
Load the mimetype from a stream.
Definition: kmimetype.cpp:417
KMimeType::is
bool is(const TQString &mimeTypeName) const
Do not use name()=="somename" anymore, to check for a given mimetype.
Definition: kmimetype.cpp:563
KServiceType::property
virtual TQVariant property(const TQString &_name) const
Returns the requested property.
Definition: kservicetype.cpp:174
KMimeMagic::findBufferType
KMimeMagicResult * findBufferType(const TQByteArray &p)
Same functionality as above, except data is not read from a file.
Definition: kmimemagic.cpp:289
TDEIO::findDeviceMountPoint
TDEIO_EXPORT TQString findDeviceMountPoint(const TQString &device)
Returns the mount point where device is mounted right now.
Definition: global.cpp:1388
KServiceType::inherits
bool inherits(const TQString &servTypeName) const
Checks whether this service type is or inherits from servTypeName.
Definition: kservicetype.cpp:157
KProtocolInfo::icon
static TQString icon(const TQString &protocol)
Returns the name of the icon, associated with the specified protocol.
KMimeType::comment
TQString comment() const
Returns the descriptive comment associated with the MIME type.
Definition: kmimetype.h:202
KServiceType::KServiceType
KServiceType(const TQString &_fullpath, const TQString &_name, const TQString &_icon, const TQString &_comment)
Constructor.
Definition: kservicetype.cpp:109
KDEDesktopMimeType::Service
Structure representing a service, in the list of services returned by builtinServices and userDefined...
Definition: kmimetype.h:517
KMimeType::property
virtual TQVariant property(const TQString &_name) const
Returns the property with the given _name.
Definition: kmimetype.cpp:437
KProtocolInfo::defaultMimetype
static TQString defaultMimetype(const KURL &url)
Returns default mimetype for this URL based on the protocol.
Definition: kprotocolinfo.cpp:249

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
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.8.13
This website is maintained by Timothy Pearson.