23 #include <sys/types.h> 33 #include <kprotocolinfo.h> 34 #include <tdeio/global.h> 35 #include "kmimetype.h" 36 #include "kservicetypefactory.h" 37 #include "kmimemagic.h" 40 #include "kautomount.h" 41 #include <kdirnotify_stub.h> 45 #include <kmessageboxwrapper.h> 47 #include <dcopclient.h> 49 #include <tdeapplication.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> 59 #include <tdesycoca.h> 62 template class TDESharedPtr<KMimeType>;
63 template class TQValueList<KMimeType::Ptr>;
65 KMimeType::Ptr KMimeType::s_pDefaultType = 0L;
70 assert ( !s_pDefaultType );
75 if (mime && mime->isType( KST_KMimeType ))
77 s_pDefaultType = KMimeType::Ptr((
KMimeType *) mime);
82 TDEStandardDirs stdDirs;
83 TQString sDefaultMimeType = stdDirs.resourceDirs(
"mime").first()+
defaultMimeType()+
".desktop";
85 "unknown",
"mime", TQStringList() );
91 if ( !s_pDefaultType )
93 return s_pDefaultType;
101 if ( !s_pDefaultType )
108 if ( !KServiceTypeFactory::self()->checkMimeTypes() )
110 KMessageBoxWrapper::error( 0L, i18n(
"No mime types installed." ) );
136 TQString tmp = i18n(
"Could not find mime type\n%1" ).arg( _type );
138 KMessageBoxWrapper::sorry( 0, tmp );
143 KServiceType * mime = KServiceTypeFactory::self()->findServiceTypeByName( _name );
145 if ( !mime || !mime->isType( KST_KMimeType ) )
149 if ( !KSycoca::self()->isBuilding() )
151 if ( !s_pDefaultType )
153 return s_pDefaultType;
157 return KMimeType::Ptr((
KMimeType *) mime);
162 return KServiceTypeFactory::self()->allMimeTypes();
166 bool _is_local_file,
bool _fast_mode )
169 TQString path = _url.path();
171 if ( !_fast_mode && !_is_local_file && _url.isLocalFile() )
172 _is_local_file =
true;
174 if ( !_fast_mode && _is_local_file && (_mode == 0 || _mode == (mode_t)-1) )
176 KDE_struct_stat buff;
177 if ( KDE_stat( TQFile::encodeName(path), &buff ) != -1 )
178 _mode = buff.st_mode;
182 if ( S_ISDIR( _mode ) )
186 if ( _is_local_file )
188 if ( access( TQFile::encodeName(path), R_OK ) == -1 )
189 return mimeType(
"inode/directory-locked" );
191 return mimeType(
"inode/directory" );
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 ) )
199 if ( S_ISSOCK( _mode ) )
202 if ( !_is_local_file && S_ISREG( _mode ) && ( _mode & ( S_IXUSR | S_IXGRP | S_IXOTH ) ) )
203 return mimeType(
"application/x-executable" );
205 TQString fileName ( _url.fileName() );
207 static const TQString& slash = TDEGlobal::staticQString(
"/");
208 if ( ! fileName.isNull() && !path.endsWith( slash ) )
211 KMimeType::Ptr mime = KServiceTypeFactory::self()->findFromPattern( fileName );
215 if ( _is_local_file || _url.hasSubURL() ||
218 if ( _is_local_file && !_fast_mode ) {
219 if ( mime->patternsAccuracy()<100 )
226 if (resultMime->patternsAccuracy() > 0) {
237 static const TQString& dotdesktop = TDEGlobal::staticQString(
".desktop");
238 static const TQString& dotkdelnk = TDEGlobal::staticQString(
".kdelnk");
239 static const TQString& dotdirectory = TDEGlobal::staticQString(
".directory");
242 if ( fileName.endsWith( dotdesktop ) )
243 return mimeType(
"application/x-desktop" );
246 if ( fileName.endsWith( dotkdelnk ) )
247 return mimeType(
"application/x-desktop" );
250 if ( fileName == dotdirectory )
254 if ( !_is_local_file || _fast_mode )
262 if ( path.endsWith( slash ) || path.isEmpty() )
272 return mimeType( TQString::fromLatin1(
"inode/directory") );
287 if ( !result || !result->
isValid() )
295 bool _is_local_file,
bool _fast_mode,
298 KMimeType::Ptr mime =
findByURL(_url, _mode, _is_local_file, _fast_mode);
299 if (accurate) *accurate = !(_fast_mode) || ((mime->patternsAccuracy() == 100) && mime !=
defaultMimeTypePtr());
303 KMimeType::Ptr KMimeType::diagnoseFileName(
const TQString &fileName, TQString &pattern)
305 return KServiceTypeFactory::self()->findFromPattern( fileName, &pattern );
312 return findByURL( u, mode,
true, fast_mode );
331 #define GZIP_MAGIC1 0x1f 332 #define GZIP_MAGIC2 0x8b 336 KMimeType::Format result;
337 result.compression = Format::NoCompression;
340 result.text = mime->name().startsWith(
"text/");
341 TQVariant v = mime->property(
"X-TDE-text");
343 result.text = v.toBool();
345 if (mime->name().startsWith(
"inode/"))
349 if (f.open(IO_ReadOnly))
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;
360 const TQString& _comment,
const TQStringList& _patterns )
363 m_lstPatterns = _patterns;
368 KDesktopFile _cfg( _fullpath,
true );
372 kdWarning(7009) <<
"mimetype not valid '" << m_strName <<
"' (missing entry in the file ?)" << endl;
380 kdWarning(7009) <<
"mimetype not valid '" << m_strName <<
"' (missing entry in the file ?)" << endl;
383 void KMimeType::init( KDesktopFile * config )
385 config->setDesktopGroup();
386 m_lstPatterns = config->readListEntry(
"Patterns",
';' );
389 TQString XKDEAutoEmbed = TQString::fromLatin1(
"X-TDE-AutoEmbed");
390 if ( config->hasKey( XKDEAutoEmbed ) )
391 m_mapProps.insert( XKDEAutoEmbed, TQVariant( config->readBoolEntry( XKDEAutoEmbed ), 0 ) );
393 TQString XKDEText = TQString::fromLatin1(
"X-TDE-text");
394 if ( config->hasKey( XKDEText ) )
395 m_mapProps.insert( XKDEText, config->readBoolEntry( XKDEText ) );
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 );
403 kdWarning(7009) <<
"Error: " << inherits <<
" inherits from itself!!!!" << endl;
406 TQString XKDEPatternsAccuracy = TQString::fromLatin1(
"X-TDE-PatternsAccuracy");
407 if ( config->hasKey( XKDEPatternsAccuracy ) )
408 m_mapProps.insert( XKDEPatternsAccuracy, config->readEntry( XKDEPatternsAccuracy ) );
414 loadInternal( _str );
419 KServiceType::load( _str );
420 loadInternal( _str );
423 void KMimeType::loadInternal( TQDataStream& _str )
426 _str >> m_lstPatterns;
431 KServiceType::save( _str );
434 _str << m_lstPatterns;
439 if ( _name ==
"Patterns" )
440 return TQVariant( m_lstPatterns );
448 res.append(
"Patterns" );
453 KMimeType::~KMimeType()
458 TQString * _path )
const 460 TDEIconLoader *iconLoader=TDEGlobal::iconLoader();
461 TQString iconName=
icon( TQString::null,
false );
462 if (!iconLoader->extraDesktopThemesAdded())
464 TQPixmap
pixmap=iconLoader->loadIcon( iconName, _group, _force_size, _state, _path,
true );
465 if (!pixmap.isNull() )
return pixmap;
467 iconLoader->addExtraDesktopThemes();
470 return iconLoader->loadIcon( iconName , _group, _force_size, _state, _path,
false );
474 int _state, TQString * _path )
const 476 TDEIconLoader *iconLoader=TDEGlobal::iconLoader();
477 TQString iconName=
icon( _url, _url.isLocalFile() );
478 if (!iconLoader->extraDesktopThemesAdded())
480 TQPixmap
pixmap=iconLoader->loadIcon( iconName, _group, _force_size, _state, _path,
true );
481 if (!pixmap.isNull() )
return pixmap;
483 iconLoader->addExtraDesktopThemes();
486 return iconLoader->loadIcon( iconName , _group, _force_size, _state, _path,
false );
490 int _force_size,
int _state, TQString * _path )
492 TDEIconLoader *iconLoader=TDEGlobal::iconLoader();
493 TQString iconName =
iconForURL( _url, _mode );
495 if (!iconLoader->extraDesktopThemesAdded())
497 TQPixmap
pixmap=iconLoader->loadIcon( iconName, _group, _force_size, _state, _path,
true );
498 if (!pixmap.isNull() )
return pixmap;
500 iconLoader->addExtraDesktopThemes();
503 return iconLoader->loadIcon( iconName , _group, _force_size, _state, _path,
false );
509 const KMimeType::Ptr mt =
findByURL( _url, _mode, _url.isLocalFile(),
511 static const TQString& unknown = TDEGlobal::staticQString(
"unknown");
512 const TQString mimeTypeIcon = mt->icon( _url, _url.isLocalFile() );
513 TQString i = mimeTypeIcon;
518 || _url.path().length() <= 1 )
526 if ( _url.path().length() <= 1 && ( i == unknown || i.isEmpty() ) )
536 static bool useFavIcons =
true;
537 static bool check =
true;
540 TDEConfig *config = TDEGlobal::config();
541 TDEConfigGroupSaver cs( config,
"HTML Settings" );
542 useFavIcons = config->readBoolEntry(
"EnableFavicon",
true );
545 if ( url.isLocalFile() || !url.protocol().startsWith(
"http")
547 return TQString::null;
549 DCOPRef kded(
"kded",
"favicons" );
550 DCOPReply result = kded.call(
"iconForURL(KURL)", url );
551 if ( result.isValid() )
554 return TQString::null;
559 TQVariant v =
property(
"X-TDE-IsAlso");
565 if (
name() == mimeTypeName )
569 while ( !st.isEmpty() )
573 if (!ptr)
return false;
574 if ( ptr->name() == mimeTypeName )
576 st = ptr->parentMimeType();
581 int KMimeType::patternsAccuracy()
const {
582 TQVariant v =
property(
"X-TDE-PatternsAccuracy");
583 if (!v.isValid())
return 100;
597 if ( !_is_local || _url.isEmpty() )
609 u.addPath(
".directory" );
614 if ( TDEStandardDirs::exists( u.path() ) )
616 KSimpleConfig cfg( u.path(), true );
617 cfg.setDesktopGroup();
618 icon = cfg.readEntry(
"Icon" );
619 TQString empty_icon = cfg.readEntry(
"EmptyIcon" );
621 if ( !empty_icon.isEmpty() )
623 bool isempty =
false;
626 dp = opendir( TQFile::encodeName(_url.path()) );
629 TQValueList<TQCString> entries;
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 )
636 entries.append( ep->d_name );
637 if ( readdir( dp ) == 0 ) {
639 isempty = entries.find(
"." ) != entries.end() &&
640 entries.find(
".." ) != entries.end() &&
641 entries.find(
".directory" ) != entries.end();
644 if (!isempty && !strcmp(ep->d_name,
".directory"))
645 isempty = (readdir(dp) == 0L);
654 if ( icon.isEmpty() )
657 if ( icon.startsWith(
"./" ) ) {
661 v.addPath( icon.mid( 2 ) );
670 if ( !_is_local || _url.isEmpty() )
682 u.addPath(
".directory" );
684 KDesktopFile cfg( u.path(), true );
685 TQString
comment = cfg.readComment();
686 if ( comment.isEmpty() )
700 if ( !_is_local || _url.isEmpty() )
704 return icon( u, _is_local );
712 KSimpleConfig cfg( _url.path(), true );
713 cfg.setDesktopGroup();
714 TQString
icon = cfg.readEntry(
"Icon" );
715 TQString type = cfg.readEntry(
"Type" );
717 if ( type ==
"FSDevice" || type ==
"FSDev")
720 TQString unmount_icon = cfg.readEntry(
"UnmountIcon" );
721 TQString dev = cfg.readEntry(
"Dev" );
722 if ( !icon.isEmpty() && !unmount_icon.isEmpty() && !dev.isEmpty() )
729 }
else if ( type ==
"Link" ) {
730 const TQString emptyIcon = cfg.readEntry(
"EmptyIcon" );
731 if ( !emptyIcon.isEmpty() ) {
732 const TQString u = cfg.readPathEntry(
"URL" );
734 if ( url.protocol() ==
"trash" ) {
737 KSimpleConfig trashConfig(
"trashrc",
true );
738 trashConfig.setGroup(
"Status" );
739 if ( trashConfig.readBoolEntry(
"Empty",
true ) ) {
746 if ( icon.isEmpty() )
753 int _state, TQString * _path )
const 755 TQString _icon =
icon( _url, _url.isLocalFile() );
756 TQPixmap pix = TDEGlobal::iconLoader()->loadIcon( _icon, _group,
757 _force_size, _state, _path,
false );
759 pix = TDEGlobal::iconLoader()->loadIcon(
"unknown", _group,
760 _force_size, _state, _path,
false );
766 if ( !_is_local || _url.isEmpty() )
770 return comment( u, _is_local );
778 KDesktopFile cfg( _url.path(), true );
779 TQString
comment = cfg.readComment();
780 if ( comment.isEmpty() )
793 KSimpleConfig cfg( u.path(), true );
794 cfg.setDesktopGroup();
795 TQString type = cfg.readEntry(
"Type" );
796 if ( type.isEmpty() )
798 TQString tmp = i18n(
"The desktop entry file %1 " 799 "has no Type=... entry.").arg(u.path() );
800 KMessageBoxWrapper::error( 0, tmp);
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" )
812 cfg.setDollarExpansion(
true );
813 return runLink( u, cfg );
815 else if ( type ==
"MimeType" )
816 return runMimeType( u, cfg );
819 TQString tmp = i18n(
"The desktop entry of type\n%1\nis unknown.").arg( type );
820 KMessageBoxWrapper::error( 0, tmp);
825 pid_t KDEDesktopMimeType::runFSDevice(
const KURL& _url,
const KSimpleConfig &cfg )
829 TQString dev = cfg.readEntry(
"Dev" );
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);
845 retval =
KRun::runURL( mpURL, TQString::fromLatin1(
"inode/directory") );
849 bool ro = cfg.readBoolEntry(
"ReadOnly",
false );
850 TQString fstype = cfg.readEntry(
"FSType" );
851 if ( fstype ==
"Default" )
852 fstype = TQString::null;
853 TQString point = cfg.readEntry(
"MountPoint" );
855 (void)
new KAutoMount( ro, fstype, dev, point, _url.path() );
863 pid_t KDEDesktopMimeType::runApplication(
const KURL& ,
const TQString & _serviceFile )
874 pid_t KDEDesktopMimeType::runLink(
const KURL& _url,
const KSimpleConfig &cfg )
876 TQString u = cfg.readPathEntry(
"URL" );
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 );
890 TQString lastOpenedWidth = cfg.readEntry(
"X-TDE-LastOpenedWith" );
891 if ( !lastOpenedWidth.isEmpty() )
897 pid_t KDEDesktopMimeType::runMimeType(
const KURL& url ,
const KSimpleConfig & )
903 args <<
"openProperties";
907 if ( !TDEApplication::tdeinitExec(
"kfmclient", args, 0, &pid) )
911 p <<
"kfmclient" << args;
912 p.start(TDEProcess::DontCare);
918 TQValueList<Service> result;
920 if ( !_url.isLocalFile() )
923 KSimpleConfig cfg( _url.path(), true );
924 cfg.setDesktopGroup();
925 TQString type = cfg.readEntry(
"Type" );
927 if ( type.isEmpty() )
930 if ( type ==
"FSDevice" )
932 TQString dev = cfg.readEntry(
"Dev" );
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);
945 mount.m_strName = i18n(
"Mount");
946 mount.m_type = ST_MOUNT;
947 result.append( mount );
956 unmount.m_strName = i18n(
"Eject");
958 unmount.m_strName = i18n(
"Unmount");
960 unmount.m_type = ST_UNMOUNT;
961 result.append( unmount );
971 KSimpleConfig cfg( path,
true );
972 return userDefinedServices( path, cfg, bLocalFiles );
977 return userDefinedServices( path, cfg, bLocalFiles, KURL::List() );
982 TQValueList<Service> result;
984 cfg.setDesktopGroup();
986 if ( !cfg.hasKey(
"Actions" ) && !cfg.hasKey(
"X-TDE-GetActionMenu") )
989 if ( cfg.hasKey(
"TryExec" ) )
991 TQString tryexec = cfg.readPathEntry(
"TryExec" );
992 TQString exe = TDEStandardDirs::findExe( tryexec );
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();
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;
1014 if(kapp->dcopClient()->call( app,
object,
1016 dataToSend, replyType, replyData,
true, -1)
1017 && replyType ==
"TQStringList" ) {
1019 TQDataStream dataStreamIn(replyData, IO_ReadOnly);
1020 dataStreamIn >> keys;
1025 keys += cfg.readListEntry(
"Actions",
';' );
1027 if ( keys.count() == 0 )
1030 TQStringList::ConstIterator it = keys.begin();
1031 TQStringList::ConstIterator end = keys.end();
1032 for ( ; it != end; ++it )
1036 TQString group = *it;
1038 if (group ==
"_SEPARATOR_")
1045 group.prepend(
"Desktop Action " );
1047 bool bInvalidMenu =
false;
1049 if ( cfg.hasGroup( group ) )
1051 cfg.setGroup( group );
1053 if ( !cfg.hasKey(
"Name" ) || !cfg.hasKey(
"Exec" ) )
1054 bInvalidMenu =
true;
1057 TQString exec = cfg.readPathEntry(
"Exec" );
1058 if ( bLocalFiles || exec.contains(
"%U") || exec.contains(
"%u") )
1061 s.m_strName = cfg.readEntry(
"Name" );
1062 s.m_strIcon = cfg.readEntry(
"Icon" );
1064 s.m_type = ST_USER_DEFINED;
1065 s.m_display = !cfg.readBoolEntry(
"NoDisplay" );
1071 bInvalidMenu =
true;
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 );
1089 executeService( lst, _service );
1096 if ( _service.m_type == ST_USER_DEFINED )
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 );
1102 KDirNotify_stub allDirNotify(
"*",
"KDirNotify*");
1103 allDirNotify.FilesChanged( urls );
1106 else if ( _service.m_type == ST_MOUNT || _service.m_type == ST_UNMOUNT )
1108 Q_ASSERT( urls.count() == 1 );
1109 TQString path = urls.first().path();
1112 KSimpleConfig cfg( path,
true );
1113 cfg.setDesktopGroup();
1114 TQString dev = cfg.readEntry(
"Dev" );
1115 if ( dev.isEmpty() )
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 );
1123 if ( _service.m_type == ST_MOUNT )
1126 if ( !mp.isEmpty() )
1128 kdDebug(7009) <<
"ALREADY Mounted" << endl;
1132 bool ro = cfg.readBoolEntry(
"ReadOnly",
false );
1133 TQString fstype = cfg.readEntry(
"FSType" );
1134 if ( fstype ==
"Default" )
1135 fstype = TQString::null;
1136 TQString point = cfg.readEntry(
"MountPoint" );
1138 (void)
new KAutoMount( ro, fstype, dev, point, path,
false );
1141 else if ( _service.m_type == ST_UNMOUNT )
1158 static const TQString & s_strDefaultMimeType =
1159 TDEGlobal::staticQString(
"application/octet-stream" );
1160 return s_strDefaultMimeType;
1163 void KMimeType::virtual_hook(
int id,
void* data )
1164 { KServiceType::virtual_hook(
id, data ); }
1166 void KFolderType::virtual_hook(
int id,
void* data )
1167 { KMimeType::virtual_hook(
id, data ); }
1169 void KDEDesktopMimeType::virtual_hook(
int id,
void* data )
1170 { KMimeType::virtual_hook(
id, data ); }
1172 void KExecMimeType::virtual_hook(
int id,
void* data )
1173 { KMimeType::virtual_hook(
id, data ); }
1175 #include "kmimetyperesolver.moc" 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.
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...
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...
static void checkEssentialMimeTypes()
This function makes sure that vital mime types are installed.
static bool s_bChecked
true if check for vital mime types has been done.
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...
virtual void save(TQDataStream &qs)
Save the mimetype to a stream.
static pid_t runURL(const KURL &_url, const TQString &_mimetype, bool tempFile, bool runExecutables)
Open the given URL.
virtual TQStringList propertyNames() const
Returns the list of all properties of this service type.
This class implements synchronous mounting of devices, as well as showing a file-manager window after...
Represent a service, i.e.
KMimeMagicResult * findFileType(const TQString &_filename)
Try to find a MimeType for the given file.
Represent a mime type, like "text/plain", and the data that is associated with it.
static TQString favIconForURL(const KURL &url)
Return the "favicon" (see http://www.favicon.com) for the given url, if available.
TQString parentMimeType() const
If this mimetype inherits from ("is also") another mimetype, return the name of the parent...
void setPreferredService(const TQString &desktopEntryName)
Set the preferred service for opening this URL, after its mimetype will have been found by KRun...
static bool determineMimetypeFromExtension(const TQString &protocol)
Returns whether mimetypes can be determined based on extension for this protocol. ...
TQString name() const
Returns the name of this service type.
A service type is the generic notion for a mimetype, a type of service instead of a type of file...
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...
bool isValid() const
Checks whether the service type is valid.
bool isValid() const
Checks whether the service is valid.
static KMimeType::Ptr defaultMimeTypePtr()
Returns the default mimetype.
virtual TQStringList propertyNames() const
Retrieves a list of all properties associated with this KMimeType.
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).
To open files with their associated applications in KDE, use KRun.
static KMimeMagic * self()
Returns a pointer to the unique KMimeMagic instance in this process.
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.
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...
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.
static Ptr findByPath(const TQString &path, mode_t mode=0, bool fast_mode=false)
Finds a KMimeType with the given _url.
This class implements synchronous unmounting of devices, It is a wrapper around the asychronous TDEIO...
TQString icon() const
Returns the icon associated with this service type.
static Format findFormatByFileContent(const TQString &fileName)
Returns whether a file has an internal format that is human readable, or that would be human readable...
static void errorMissingMimeType(const TQString &_type)
Signal a missing mime type.
static bool supportsListing(const KURL &url)
Returns whether the protocol can list files/objects.
static void buildDefaultType()
This function makes sure that the default mime type exists.
static const TQString & defaultMimeType()
Returns the name of the default mimetype.
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.
bool isValid() const
Returns whether the result is valid (i.e.
static TQValueList< Service > builtinServices(const KURL &_url)
Returns a list of services for the given .desktop file that are handled by tdeio itself.
TQString mimeType() const
Retrieve the mimetype (e.g.
int accuracy() const
Retrieve the accuracy of the matching.
static pid_t run(const KURL &_url, bool _is_local)
Invokes the default action for the desktop entry.
KMimeType(const TQString &_fullpath, const TQString &_type, const TQString &_icon, const TQString &_comment, const TQStringList &_patterns)
Constructor.
static List allMimeTypes()
Get all the mimetypes.
static void executeService(const TQString &path, KDEDesktopMimeType::Service &service) KDE_DEPRECATED
virtual void load(TQDataStream &qs)
Load the mimetype from a stream.
bool is(const TQString &mimeTypeName) const
Do not use name()=="somename" anymore, to check for a given mimetype.
virtual TQVariant property(const TQString &_name) const
Returns the requested property.
KMimeMagicResult * findBufferType(const TQByteArray &p)
Same functionality as above, except data is not read from a file.
TDEIO_EXPORT TQString findDeviceMountPoint(const TQString &device)
Returns the mount point where device is mounted right now.
bool inherits(const TQString &servTypeName) const
Checks whether this service type is or inherits from servTypeName.
static TQString icon(const TQString &protocol)
Returns the name of the icon, associated with the specified protocol.
TQString comment() const
Returns the descriptive comment associated with the MIME type.
KServiceType(const TQString &_fullpath, const TQString &_name, const TQString &_icon, const TQString &_comment)
Constructor.
Structure representing a service, in the list of services returned by builtinServices and userDefined...
virtual TQVariant property(const TQString &_name) const
Returns the property with the given _name.
static TQString defaultMimetype(const KURL &url)
Returns default mimetype for this URL based on the protocol.