• 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 <tdeprocess.h>
51#include <kdebug.h>
52#include <tdedesktopfile.h>
53#include <kdirwatch.h>
54#include <kiconloader.h>
55#include <tdelocale.h>
56#include <tdesimpleconfig.h>
57#include <tdestandarddirs.h>
58#include <kurl.h>
59#include <tdesycoca.h>
60#include <kde_file.h>
61
62template class TDESharedPtr<KMimeType>;
63template class TQValueList<KMimeType::Ptr>;
64
65KMimeType::Ptr KMimeType::s_pDefaultType = 0L;
66bool KMimeType::s_bChecked = false;
67
68void 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
89KMimeType::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
97void 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
134void 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
141KMimeType::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
160KMimeType::List KMimeType::allMimeTypes()
161{
162 return KServiceTypeFactory::self()->allMimeTypes();
163}
164
165KMimeType::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
294KMimeType::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
303KMimeType::Ptr KMimeType::diagnoseFileName(const TQString &fileName, TQString &pattern)
304{
305 return KServiceTypeFactory::self()->findFromPattern( fileName, &pattern );
306}
307
308KMimeType::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
315KMimeType::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
323KMimeType::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
334KMimeType::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
359KMimeType::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
366KMimeType::KMimeType( const TQString & _fullpath ) : KServiceType( _fullpath )
367{
368 TDEDesktopFile _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
375KMimeType::KMimeType( TDEDesktopFile *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
383void KMimeType::init( TDEDesktopFile * 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 ) ) );
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
412KMimeType::KMimeType( TQDataStream& _str, int offset ) : KServiceType( _str, offset )
413{
414 loadInternal( _str ); // load our specific stuff
415}
416
417void KMimeType::load( TQDataStream& _str )
418{
419 KServiceType::load( _str );
420 loadInternal( _str );
421}
422
423void KMimeType::loadInternal( TQDataStream& _str )
424{
425 // kdDebug(7009) << "KMimeType::load( TQDataStream& ) : loading list of patterns" << endl;
426 _str >> m_lstPatterns;
427}
428
429void 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
437TQVariant KMimeType::property( const TQString& _name ) const
438{
439 if ( _name == "Patterns" )
440 return TQVariant( m_lstPatterns );
441
442 return KServiceType::property( _name );
443}
444
445TQStringList KMimeType::propertyNames() const
446{
447 TQStringList res = KServiceType::propertyNames();
448 res.append( "Patterns" );
449
450 return res;
451}
452
453KMimeType::~KMimeType()
454{
455}
456
457TQPixmap 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
473TQPixmap 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
489TQPixmap 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
507TQString 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 // special case: root directory (/) -- Gitea issue #128
530 if ( _url == KURL("file:///") )
531 i = "folder_red";
532 }
533 return i;
534}
535
536TQString KMimeType::favIconForURL( const KURL& url )
537{
538 // this method will be called quite often, so better not read the config
539 // again and again.
540 static bool useFavIcons = true;
541 static bool check = true;
542 if ( check ) {
543 check = false;
544 TDEConfig *config = TDEGlobal::config();
545 TDEConfigGroupSaver cs( config, "HTML Settings" );
546 useFavIcons = config->readBoolEntry( "EnableFavicon", true );
547 }
548
549 if ( url.isLocalFile() || !url.protocol().startsWith("http")
550 || !useFavIcons )
551 return TQString::null;
552
553 DCOPRef kded( "kded", "favicons" );
554 DCOPReply result = kded.call( "iconForURL(KURL)", url );
555 if ( result.isValid() )
556 return result;
557
558 return TQString::null;
559}
560
561TQString KMimeType::parentMimeType() const
562{
563 TQVariant v = property("X-TDE-IsAlso");
564 return v.toString();
565}
566
567bool KMimeType::is( const TQString& mimeTypeName ) const
568{
569 if ( name() == mimeTypeName )
570 return true;
571 TQString st = parentMimeType();
572 //if (st.isEmpty()) kdDebug(7009)<<"Parent mimetype is empty"<<endl;
573 while ( !st.isEmpty() )
574 {
575 //kdDebug(7009)<<"Checking parent mime type: "<<st<<endl;
576 KMimeType::Ptr ptr = KMimeType::mimeType( st );
577 if (!ptr) return false; //error
578 if ( ptr->name() == mimeTypeName )
579 return true;
580 st = ptr->parentMimeType();
581 }
582 return false;
583}
584
585int KMimeType::patternsAccuracy() const {
586 TQVariant v = property("X-TDE-PatternsAccuracy");
587 if (!v.isValid()) return 100;
588 else
589 return v.toInt();
590}
591
592
593/*******************************************************
594 *
595 * KFolderType
596 *
597 ******************************************************/
598
599TQString KFolderType::icon( const TQString& _url, bool _is_local ) const
600{
601 if ( !_is_local || _url.isEmpty() )
602 return KMimeType::icon( _url, _is_local );
603
604 return KFolderType::icon( KURL(_url), _is_local );
605}
606
607TQString KFolderType::icon( const KURL& _url, bool _is_local ) const
608{
609 if ( !_is_local )
610 return KMimeType::icon( _url, _is_local );
611
612 KURL u( _url );
613 u.addPath( ".directory" );
614
615 TQString icon;
616 // using TDEStandardDirs as this one checks for path being
617 // a file instead of a directory
618 if ( TDEStandardDirs::exists( u.path() ) )
619 {
620 TDESimpleConfig cfg( u.path(), true );
621 cfg.setDesktopGroup();
622 icon = cfg.readEntry( "Icon" );
623 TQString empty_icon = cfg.readEntry( "EmptyIcon" );
624
625 if ( !empty_icon.isEmpty() )
626 {
627 bool isempty = false;
628 DIR *dp = 0L;
629 struct dirent *ep;
630 dp = opendir( TQFile::encodeName(_url.path()) );
631 if ( dp )
632 {
633 TQValueList<TQCString> entries;
634 // Note that readdir isn't guaranteed to return "." and ".." first (#79826)
635 ep=readdir( dp ); if ( ep ) entries.append( ep->d_name );
636 ep=readdir( dp ); if ( ep ) entries.append( ep->d_name );
637 if ( (ep=readdir( dp )) == 0L ) // third file is NULL entry -> empty directory
638 isempty = true;
639 else {
640 entries.append( ep->d_name );
641 if ( readdir( dp ) == 0 ) { // only three
642 // check if we got "." ".." and ".directory"
643 isempty = entries.find( "." ) != entries.end() &&
644 entries.find( ".." ) != entries.end() &&
645 entries.find( ".directory" ) != entries.end();
646 }
647 }
648 if (!isempty && !strcmp(ep->d_name, ".directory"))
649 isempty = (readdir(dp) == 0L);
650 closedir( dp );
651 }
652
653 if ( isempty )
654 return empty_icon;
655 }
656 }
657
658 if ( icon.isEmpty() )
659 return KMimeType::icon( _url, _is_local );
660
661 if ( icon.startsWith( "./" ) ) {
662 // path is relative with respect to the location
663 // of the .directory file (#73463)
664 KURL v( _url );
665 v.addPath( icon.mid( 2 ) );
666 icon = v.path();
667 }
668
669 return icon;
670}
671
672TQString KFolderType::comment( const TQString& _url, bool _is_local ) const
673{
674 if ( !_is_local || _url.isEmpty() )
675 return KMimeType::comment( _url, _is_local );
676
677 return KFolderType::comment( KURL(_url), _is_local );
678}
679
680TQString KFolderType::comment( const KURL& _url, bool _is_local ) const
681{
682 if ( !_is_local )
683 return KMimeType::comment( _url, _is_local );
684
685 KURL u( _url );
686 u.addPath( ".directory" );
687
688 TDEDesktopFile cfg( u.path(), true );
689 TQString comment = cfg.readComment();
690 if ( comment.isEmpty() )
691 return KMimeType::comment( _url, _is_local );
692
693 return comment;
694}
695
696/*******************************************************
697 *
698 * KDEDesktopMimeType
699 *
700 ******************************************************/
701
702TQString KDEDesktopMimeType::icon( const TQString& _url, bool _is_local ) const
703{
704 if ( !_is_local || _url.isEmpty() )
705 return KMimeType::icon( _url, _is_local );
706
707 KURL u( _url );
708 return icon( u, _is_local );
709}
710
711TQString KDEDesktopMimeType::icon( const KURL& _url, bool _is_local ) const
712{
713 if ( !_is_local )
714 return KMimeType::icon( _url, _is_local );
715
716 TDESimpleConfig cfg( _url.path(), true );
717 cfg.setDesktopGroup();
718 TQString icon = cfg.readEntry( "Icon" );
719 TQString type = cfg.readEntry( "Type" );
720
721 if ( type == "FSDevice" || type == "FSDev") // need to provide FSDev for
722 // backwards compatibility
723 {
724 TQString unmount_icon = cfg.readEntry( "UnmountIcon" );
725 TQString dev = cfg.readEntry( "Dev" );
726 if ( !icon.isEmpty() && !unmount_icon.isEmpty() && !dev.isEmpty() )
727 {
728 TQString mp = TDEIO::findDeviceMountPoint( dev );
729 // Is the device not mounted ?
730 if ( mp.isNull() )
731 return unmount_icon;
732 }
733 } else if ( type == "Link" ) {
734 const TQString emptyIcon = cfg.readEntry( "EmptyIcon" );
735 if ( !emptyIcon.isEmpty() ) {
736 const TQString u = cfg.readPathEntry( "URL" );
737 const KURL url( u );
738 if ( url.protocol() == "trash" ) {
739 // We need to find if the trash is empty, preferrably without using a TDEIO job.
740 // So instead tdeio_trash leaves an entry in its config file for us.
741 TDESimpleConfig trashConfig( "trashrc", true );
742 trashConfig.setGroup( "Status" );
743 if ( trashConfig.readBoolEntry( "Empty", true ) ) {
744 return emptyIcon;
745 }
746 }
747 }
748 }
749
750 if ( icon.isEmpty() )
751 return KMimeType::icon( _url, _is_local );
752
753 return icon;
754}
755
756TQPixmap KDEDesktopMimeType::pixmap( const KURL& _url, TDEIcon::Group _group, int _force_size,
757 int _state, TQString * _path ) const
758{
759 TQString _icon = icon( _url, _url.isLocalFile() );
760 TQPixmap pix = TDEGlobal::iconLoader()->loadIcon( _icon, _group,
761 _force_size, _state, _path, false );
762 if ( pix.isNull() )
763 pix = TDEGlobal::iconLoader()->loadIcon( "unknown", _group,
764 _force_size, _state, _path, false );
765 return pix;
766}
767
768TQString KDEDesktopMimeType::comment( const TQString& _url, bool _is_local ) const
769{
770 if ( !_is_local || _url.isEmpty() )
771 return KMimeType::comment( _url, _is_local );
772
773 KURL u( _url );
774 return comment( u, _is_local );
775}
776
777TQString KDEDesktopMimeType::comment( const KURL& _url, bool _is_local ) const
778{
779 if ( !_is_local )
780 return KMimeType::comment( _url, _is_local );
781
782 TDEDesktopFile cfg( _url.path(), true );
783 TQString comment = cfg.readComment();
784 if ( comment.isEmpty() )
785 return KMimeType::comment( _url, _is_local );
786
787 return comment;
788}
789
790pid_t KDEDesktopMimeType::run( const KURL& u, bool _is_local )
791{
792 // It might be a security problem to run external untrusted desktop
793 // entry files
794 if ( !_is_local )
795 return 0;
796
797 TDESimpleConfig cfg( u.path(), true );
798 cfg.setDesktopGroup();
799 TQString type = cfg.readEntry( "Type" );
800 if ( type.isEmpty() )
801 {
802 TQString tmp = i18n("The desktop entry file %1 "
803 "has no Type=... entry.").arg(u.path() );
804 KMessageBoxWrapper::error( 0, tmp);
805 return 0;
806 }
807
808 //kdDebug(7009) << "TYPE = " << type.data() << endl;
809
810 if ( type == "FSDevice" )
811 return runFSDevice( u, cfg );
812 else if ( type == "Application" )
813 return runApplication( u, u.path() );
814 else if ( type == "Link" )
815 {
816 cfg.setDollarExpansion( true ); // for URL=file:$HOME (Simon)
817 return runLink( u, cfg );
818 }
819 else if ( type == "MimeType" )
820 return runMimeType( u, cfg );
821
822
823 TQString tmp = i18n("The desktop entry of type\n%1\nis unknown.").arg( type );
824 KMessageBoxWrapper::error( 0, tmp);
825
826 return 0;
827}
828
829pid_t KDEDesktopMimeType::runFSDevice( const KURL& _url, const TDESimpleConfig &cfg )
830{
831 pid_t retval = 0;
832
833 TQString dev = cfg.readEntry( "Dev" );
834
835 if ( dev.isEmpty() )
836 {
837 TQString tmp = i18n("The desktop entry file\n%1\nis of type FSDevice but has no Dev=... entry.").arg( _url.path() );
838 KMessageBoxWrapper::error( 0, tmp);
839 return retval;
840 }
841
842 TQString mp = TDEIO::findDeviceMountPoint( dev );
843 // Is the device already mounted ?
844 if ( !mp.isNull() )
845 {
846 KURL mpURL;
847 mpURL.setPath( mp );
848 // Open a new window
849 retval = KRun::runURL( mpURL, TQString::fromLatin1("inode/directory") );
850 }
851 else
852 {
853 bool ro = cfg.readBoolEntry( "ReadOnly", false );
854 TQString fstype = cfg.readEntry( "FSType" );
855 if ( fstype == "Default" ) // KDE-1 thing
856 fstype = TQString::null;
857 TQString point = cfg.readEntry( "MountPoint" );
858#ifndef TQ_WS_WIN
859 (void) new KAutoMount( ro, fstype, dev, point, _url.path() );
860#endif
861 retval = -1; // we don't want to return 0, but we don't want to return a pid
862 }
863
864 return retval;
865}
866
867pid_t KDEDesktopMimeType::runApplication( const KURL& , const TQString & _serviceFile )
868{
869 KService s( _serviceFile );
870 if ( !s.isValid() )
871 // The error message was already displayed, so we can just quit here
872 return 0;
873
874 KURL::List lst;
875 return KRun::run( s, lst );
876}
877
878pid_t KDEDesktopMimeType::runLink( const KURL& _url, const TDESimpleConfig &cfg )
879{
880 TQString u = cfg.readPathEntry( "URL" );
881 if ( u.isEmpty() )
882 {
883 TQString tmp = i18n("The desktop entry file\n%1\nis of type Link but has no URL=... entry.").arg( _url.prettyURL() );
884 KMessageBoxWrapper::error( 0, tmp );
885 return 0;
886 }
887
888 KURL url ( u );
889 KRun* run = new KRun(url);
890
891 // X-TDE-LastOpenedWith holds the service desktop entry name that
892 // was should be preferred for opening this URL if possible.
893 // This is used by the Recent Documents menu for instance.
894 TQString lastOpenedWidth = cfg.readEntry( "X-TDE-LastOpenedWith" );
895 if ( !lastOpenedWidth.isEmpty() )
896 run->setPreferredService( lastOpenedWidth );
897
898 return -1; // we don't want to return 0, but we don't want to return a pid
899}
900
901pid_t KDEDesktopMimeType::runMimeType( const KURL& url , const TDESimpleConfig & )
902{
903 // Hmm, can't really use keditfiletype since we might be looking
904 // at the global file, or at a file not in share/mimelnk...
905
906 TQStringList args;
907 args << "openProperties";
908 args << url.path();
909
910 int pid;
911 if ( !TDEApplication::tdeinitExec("kfmclient", args, 0, &pid) )
912 return pid;
913
914 TDEProcess p;
915 p << "kfmclient" << args;
916 p.start(TDEProcess::DontCare);
917 return p.pid();
918}
919
920TQValueList<KDEDesktopMimeType::Service> KDEDesktopMimeType::builtinServices( const KURL& _url )
921{
922 TQValueList<Service> result;
923
924 if ( !_url.isLocalFile() )
925 return result;
926
927 TDESimpleConfig cfg( _url.path(), true );
928 cfg.setDesktopGroup();
929 TQString type = cfg.readEntry( "Type" );
930
931 if ( type.isEmpty() )
932 return result;
933
934 if ( type == "FSDevice" )
935 {
936 TQString dev = cfg.readEntry( "Dev" );
937 if ( dev.isEmpty() )
938 {
939 TQString tmp = i18n("The desktop entry file\n%1\nis of type FSDevice but has no Dev=... entry.").arg( _url.path() );
940 KMessageBoxWrapper::error( 0, tmp);
941 }
942 else
943 {
944 TQString mp = TDEIO::findDeviceMountPoint( dev );
945 // not mounted ?
946 if ( mp.isEmpty() )
947 {
948 Service mount;
949 mount.m_strName = i18n("Mount");
950 mount.m_type = ST_MOUNT;
951 result.append( mount );
952 }
953 else
954 {
955 Service unmount;
956#ifdef HAVE_VOLMGT
957 /*
958 * Solaris' volume management can only umount+eject
959 */
960 unmount.m_strName = i18n("Eject");
961#else
962 unmount.m_strName = i18n("Unmount");
963#endif
964 unmount.m_type = ST_UNMOUNT;
965 result.append( unmount );
966 }
967 }
968 }
969
970 return result;
971}
972
973TQValueList<KDEDesktopMimeType::Service> KDEDesktopMimeType::userDefinedServices( const TQString& path, bool bLocalFiles )
974{
975 TDESimpleConfig cfg( path, true );
976 return userDefinedServices( path, cfg, bLocalFiles );
977}
978
979TQValueList<KDEDesktopMimeType::Service> KDEDesktopMimeType::userDefinedServices( const TQString& path, TDEConfig& cfg, bool bLocalFiles )
980{
981 return userDefinedServices( path, cfg, bLocalFiles, KURL::List() );
982}
983
984TQValueList<KDEDesktopMimeType::Service> KDEDesktopMimeType::userDefinedServices( const TQString& path, TDEConfig& cfg, bool bLocalFiles, const KURL::List & file_list )
985{
986 TQValueList<Service> result;
987
988 cfg.setDesktopGroup();
989
990 if ( !cfg.hasKey( "Actions" ) && !cfg.hasKey( "X-TDE-GetActionMenu") )
991 return result;
992
993 if ( cfg.hasKey( "TryExec" ) )
994 {
995 TQString tryexec = cfg.readPathEntry( "TryExec" );
996 TQString exe = TDEStandardDirs::findExe( tryexec );
997 if (exe.isEmpty()) {
998 return result;
999 }
1000 }
1001
1002 TQStringList keys;
1003
1004 if( cfg.hasKey( "X-TDE-GetActionMenu" )) {
1005 TQString dcopcall = cfg.readEntry( "X-TDE-GetActionMenu" );
1006 const TQCString app = TQString(dcopcall.section(' ', 0,0)).utf8();
1007
1008 TQByteArray dataToSend;
1009 TQDataStream dataStream(dataToSend, IO_WriteOnly);
1010 dataStream << file_list;
1011 TQCString replyType;
1012 TQByteArray replyData;
1013 TQCString object = TQString(dcopcall.section(' ', 1,-2)).utf8();
1014 TQString function = dcopcall.section(' ', -1);
1015 if(!function.endsWith("(KURL::List)")) {
1016 kdWarning() << "Desktop file " << path << " contains an invalid X-TDE-ShowIfDcopCall - the function must take the exact parameter (KURL::List) and must be specified." << endl;
1017 } else {
1018 if(tdeApp->dcopClient()->call( app, object,
1019 function.utf8(),
1020 dataToSend, replyType, replyData, true, -1)
1021 && replyType == "TQStringList" ) {
1022
1023 TQDataStream dataStreamIn(replyData, IO_ReadOnly);
1024 dataStreamIn >> keys;
1025 }
1026 }
1027 }
1028
1029 keys += cfg.readListEntry( "Actions", ';' ); //the desktop standard defines ";" as separator!
1030
1031 if ( keys.count() == 0 )
1032 return result;
1033
1034 TQStringList::ConstIterator it = keys.begin();
1035 TQStringList::ConstIterator end = keys.end();
1036 for ( ; it != end; ++it )
1037 {
1038 //kdDebug(7009) << "CURRENT KEY = " << (*it) << endl;
1039
1040 TQString group = *it;
1041
1042 if (group == "_SEPARATOR_")
1043 {
1044 Service s;
1045 result.append(s);
1046 continue;
1047 }
1048
1049 group.prepend( "Desktop Action " );
1050
1051 bool bInvalidMenu = false;
1052
1053 if ( cfg.hasGroup( group ) )
1054 {
1055 cfg.setGroup( group );
1056
1057 if ( !cfg.hasKey( "Name" ) || !cfg.hasKey( "Exec" ) )
1058 bInvalidMenu = true;
1059 else
1060 {
1061 TQString exec = cfg.readPathEntry( "Exec" );
1062 if ( bLocalFiles || exec.contains("%U") || exec.contains("%u") )
1063 {
1064 Service s;
1065 s.m_strName = cfg.readEntry( "Name" );
1066 s.m_strIcon = cfg.readEntry( "Icon" );
1067 s.m_strExec = exec;
1068 s.m_type = ST_USER_DEFINED;
1069 s.m_display = !cfg.readBoolEntry( "NoDisplay" );
1070 result.append( s );
1071 }
1072 }
1073 }
1074 else
1075 bInvalidMenu = true;
1076
1077 if ( bInvalidMenu )
1078 {
1079 TQString tmp = i18n("The desktop entry file\n%1\n has an invalid menu entry\n%2.").arg( path ).arg( *it );
1080 KMessageBoxWrapper::error( 0, tmp );
1081 }
1082 }
1083
1084 return result;
1085}
1086
1087void KDEDesktopMimeType::executeService( const TQString& _url, KDEDesktopMimeType::Service& _service )
1088{
1089 KURL u;
1090 u.setPath(_url);
1091 KURL::List lst;
1092 lst.append( u );
1093 executeService( lst, _service );
1094}
1095
1096void KDEDesktopMimeType::executeService( const KURL::List& urls, KDEDesktopMimeType::Service& _service )
1097{
1098 //kdDebug(7009) << "EXECUTING Service " << _service.m_strName << endl;
1099
1100 if ( _service.m_type == ST_USER_DEFINED )
1101 {
1102 kdDebug() << "KDEDesktopMimeType::executeService " << _service.m_strName
1103 << " first url's path=" << urls.first().path() << " exec=" << _service.m_strExec << endl;
1104 KRun::run( _service.m_strExec, urls, _service.m_strName, _service.m_strIcon, _service.m_strIcon );
1105 // The action may update the desktop file. Example: eject unmounts (#5129).
1106 KDirNotify_stub allDirNotify("*", "KDirNotify*");
1107 allDirNotify.FilesChanged( urls );
1108 return;
1109 }
1110 else if ( _service.m_type == ST_MOUNT || _service.m_type == ST_UNMOUNT )
1111 {
1112 Q_ASSERT( urls.count() == 1 );
1113 TQString path = urls.first().path();
1114 //kdDebug(7009) << "MOUNT&UNMOUNT" << endl;
1115
1116 TDESimpleConfig cfg( path, true );
1117 cfg.setDesktopGroup();
1118 TQString dev = cfg.readEntry( "Dev" );
1119 if ( dev.isEmpty() )
1120 {
1121 TQString tmp = i18n("The desktop entry file\n%1\nis of type FSDevice but has no Dev=... entry.").arg( path );
1122 KMessageBoxWrapper::error( 0, tmp );
1123 return;
1124 }
1125 TQString mp = TDEIO::findDeviceMountPoint( dev );
1126
1127 if ( _service.m_type == ST_MOUNT )
1128 {
1129 // Already mounted? Strange, but who knows ...
1130 if ( !mp.isEmpty() )
1131 {
1132 kdDebug(7009) << "ALREADY Mounted" << endl;
1133 return;
1134 }
1135
1136 bool ro = cfg.readBoolEntry( "ReadOnly", false );
1137 TQString fstype = cfg.readEntry( "FSType" );
1138 if ( fstype == "Default" ) // KDE-1 thing
1139 fstype = TQString::null;
1140 TQString point = cfg.readEntry( "MountPoint" );
1141#ifndef TQ_WS_WIN
1142 (void)new KAutoMount( ro, fstype, dev, point, path, false );
1143#endif
1144 }
1145 else if ( _service.m_type == ST_UNMOUNT )
1146 {
1147 // Not mounted? Strange, but who knows ...
1148 if ( mp.isEmpty() )
1149 return;
1150
1151#ifndef TQ_WS_WIN
1152 (void)new KAutoUnmount( mp, path );
1153#endif
1154 }
1155 }
1156 else
1157 assert( 0 );
1158}
1159
1160const TQString & KMimeType::defaultMimeType()
1161{
1162 static const TQString & s_strDefaultMimeType =
1163 TDEGlobal::staticQString( "application/octet-stream" );
1164 return s_strDefaultMimeType;
1165}
1166
1167void KMimeType::virtual_hook( int id, void* data )
1168{ KServiceType::virtual_hook( id, data ); }
1169
1170void KFolderType::virtual_hook( int id, void* data )
1171{ KMimeType::virtual_hook( id, data ); }
1172
1173void KDEDesktopMimeType::virtual_hook( int id, void* data )
1174{ KMimeType::virtual_hook( id, data ); }
1175
1176void KExecMimeType::virtual_hook( int id, void* data )
1177{ KMimeType::virtual_hook( id, data ); }
1178
1179#include "kmimetyperesolver.moc"
1180
KAutoMount
This class implements synchronous mounting of devices, as well as showing a file-manager window after...
Definition: kautomount.h:42
KAutoUnmount
This class implements synchronous unmounting of devices, It is a wrapper around the asychronous TDEIO...
Definition: kautomount.h:87
KDEDesktopMimeType::run
static pid_t run(const KURL &_url, bool _is_local)
Invokes the default action for the desktop entry.
Definition: kmimetype.cpp:790
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:920
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:973
KDEDesktopMimeType::executeService
static void executeService(const TQString &path, KDEDesktopMimeType::Service &service) TDE_DEPRECATED
Definition: kmimetype.cpp:1087
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:756
KMimeMagicResult
Definition: kmimemagic.h:47
KMimeMagicResult::mimeType
TQString mimeType() const
Retrieve the mimetype (e.g.
Definition: kmimemagic.h:55
KMimeMagicResult::isValid
bool isValid() const
Returns whether the result is valid (i.e.
Definition: kmimemagic.h:63
KMimeMagicResult::accuracy
int accuracy() const
Retrieve the accuracy of the matching.
Definition: kmimemagic.h:59
KMimeMagic::findFileType
KMimeMagicResult * findFileType(const TQString &_filename)
Try to find a MimeType for the given file.
Definition: kmimemagic.cpp:360
KMimeMagic::self
static KMimeMagic * self()
Returns a pointer to the unique KMimeMagic instance in this process.
Definition: kmimemagic.cpp:49
KMimeMagic::findBufferType
KMimeMagicResult * findBufferType(const TQByteArray &p)
Same functionality as above, except data is not read from a file.
Definition: kmimemagic.cpp:289
KMimeType
Represent a mime type, like "text/plain", and the data that is associated with it.
Definition: kmimetype.h:48
KMimeType::s_bChecked
static bool s_bChecked
true if check for vital mime types has been done.
Definition: kmimetype.h:459
KMimeType::load
virtual void load(TQDataStream &qs)
Load the mimetype from a stream.
Definition: kmimetype.cpp:417
KMimeType::errorMissingMimeType
static void errorMissingMimeType(const TQString &_type)
Signal a missing mime type.
Definition: kmimetype.cpp:134
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
KMimeType::property
virtual TQVariant property(const TQString &_name) const
Returns the property with the given _name.
Definition: kmimetype.cpp:437
KMimeType::save
virtual void save(TQDataStream &qs)
Save the mimetype to a stream.
Definition: kmimetype.cpp:429
KMimeType::parentMimeType
TQString parentMimeType() const
If this mimetype inherits from ("is also") another mimetype, return the name of the parent.
Definition: kmimetype.cpp:561
KMimeType::checkEssentialMimeTypes
static void checkEssentialMimeTypes()
This function makes sure that vital mime types are installed.
Definition: kmimetype.cpp:97
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::is
bool is(const TQString &mimeTypeName) const
Do not use name()=="somename" anymore, to check for a given mimetype.
Definition: kmimetype.cpp:567
KMimeType::defaultMimeType
static const TQString & defaultMimeType()
Returns the name of the default mimetype.
Definition: kmimetype.cpp:1160
KMimeType::propertyNames
virtual TQStringList propertyNames() const
Retrieves a list of all properties associated with this KMimeType.
Definition: kmimetype.cpp:445
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't have a special URL for which you search a pixmap.
Definition: kmimetype.cpp:457
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::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
KMimeType::allMimeTypes
static List allMimeTypes()
Get all the mimetypes.
Definition: kmimetype.cpp:160
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
KMimeType::KMimeType
KMimeType(const TQString &_fullpath, const TQString &_type, const TQString &_icon, const TQString &_comment, const TQStringList &_patterns)
Constructor.
Definition: kmimetype.cpp:359
KMimeType::defaultMimeTypePtr
static KMimeType::Ptr defaultMimeTypePtr()
Returns the default mimetype.
Definition: kmimetype.cpp:89
KMimeType::buildDefaultType
static void buildDefaultType()
This function makes sure that the default mime type exists.
Definition: kmimetype.cpp:68
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::favIconForURL
static TQString favIconForURL(const KURL &url)
Return the "favicon" (see http://www.favicon.com) for the given url, if available.
Definition: kmimetype.cpp:536
KMimeType::comment
TQString comment() const
Returns the descriptive comment associated with the MIME type.
Definition: kmimetype.h:202
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
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
KProtocolInfo::defaultMimetype
static TQString defaultMimetype(const KURL &url)
Returns default mimetype for this URL based on the protocol.
Definition: kprotocolinfo.cpp:249
KProtocolInfo::determineMimetypeFromExtension
static bool determineMimetypeFromExtension(const TQString &protocol)
Returns whether mimetypes can be determined based on extension for this protocol.
KProtocolInfo::icon
static TQString icon(const TQString &protocol)
Returns the name of the icon, associated with the specified protocol.
KProtocolInfo::supportsListing
static bool supportsListing(const KURL &url)
Returns whether the protocol can list files/objects.
Definition: kprotocolinfo.cpp:121
KRun
To open files with their associated applications in KDE, use KRun.
Definition: krun.h:59
KRun::runURL
static pid_t runURL(const KURL &_url, const TQString &_mimetype, bool tempFile, bool runExecutables)
Open the given URL.
Definition: krun.cpp:94
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:759
KServiceType
A service type is the generic notion for a mimetype, a type of service instead of a type of file.
Definition: kservicetype.h:46
KServiceType::propertyNames
virtual TQStringList propertyNames() const
Returns the list of all properties of this service type.
Definition: kservicetype.cpp:191
KServiceType::isValid
bool isValid() const
Checks whether the service type is valid.
Definition: kservicetype.h:158
KServiceType::property
virtual TQVariant property(const TQString &_name) const
Returns the requested property.
Definition: kservicetype.cpp:171
KServiceType::inherits
bool inherits(const TQString &servTypeName) const
Checks whether this service type is or inherits from servTypeName.
Definition: kservicetype.cpp:154
KServiceType::icon
TQString icon() const
Returns the icon associated with this service type.
Definition: kservicetype.h:94
KServiceType::name
TQString name() const
Returns the name of this service type.
Definition: kservicetype.h:106
KService
Represent a service, i.e.
Definition: kservice.h:49
TDEIO::findDeviceMountPoint
TDEIO_EXPORT TQString findDeviceMountPoint(const TQString &device)
Returns the mount point where device is mounted right now.
Definition: global.cpp:1401
KDEDesktopMimeType::Service
Structure representing a service, in the list of services returned by builtinServices and userDefined...
Definition: kmimetype.h:518

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.9.4
This website is maintained by Timothy Pearson.