KDECore
kmimetype.cpp
Go to the documentation of this file.
80 if ((unsigned char)(p[i]) < 32 && p[i] != 9 && p[i] != 10 && p[i] != 13) // ASCII control character
143 // remote executable file? stop here (otherwise findFromContent can do that better for local files)
176 if no glob matches, or if more than one glob matches, use default mimetype and mark as "can be refined".
231 KMimeType::Ptr mime = KMimeTypeRepository::self()->findFromContent(device, &magicAccuracy, beginning);
234 //kDebug(servicesDebugArea()) << "findFromContent said" << (mime?mime->name():QString()) << "with accuracy" << magicAccuracy;
244 //kDebug(servicesDebugArea()) << "sniffedMime=" << sniffedMime << "mimeFromPattern=" << mimeFromPattern->name();
473 // and for the root of the protocol (e.g. trash:/) the protocol icon has priority over the mimetype icon
627 kWarning() << "No file found for" << file << ", even though the file appeared in a directory listing.";
628 kWarning() << "Either it was just removed, or the directory doesn't have executable permission...";
689 kFatal() << "Programming error in KMimeType XML loading, please create a bug report on http://bugs.kde.org and attach the file" << fullPath;
KMimeType::Ptr defaultMimeTypePtr()
Definition: kmimetyperepository.cpp:662
#define KDE_MAKE_VERSION(a, b, c)
Make a number from the major, minor and release number of a KDE version.
Definition: kdeversion.h.cmake:75
void clear()
QString iconName(const KUrl &url=KUrl()) const
Return the filename of the icon associated with the mimetype.
Definition: kmimetype.cpp:604
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
static bool determineMimetypeFromExtension(const QString &protocol)
Returns whether mimetypes can be determined based on extension for this protocol. ...
Definition: kprotocolinfo.cpp:328
bool readNextStartElement()
static QString iconNameForUrl(const KUrl &url, mode_t mode=0)
Return the filename of the icon associated with the mimetype, for a given url.
Definition: kmimetype.cpp:460
iterator insert(const Key &key, const T &value)
QStringList patternsForMimetype(const QString &mimeType)
Return the patterns (globs) for a given mimetype TEMPORARY method, it will go away once we can requir...
Definition: kmimetyperepository.cpp:599
KMimeType::Ptr findMimeTypeByName(const QString &_name, KMimeType::FindByNameOption options=KMimeType::DontResolveAlias)
Creates a KMimeType.
Definition: kmimetyperepository.cpp:59
static QString favIconForUrl(const KUrl &url)
Return the "favicon" (see http://www.favicon.com) for the given url, if available.
Definition: kmimetype.cpp:488
static bool matchFileName(const QString &filename, const QString &pattern)
Returns true if the given filename matches the given pattern.
Definition: kmimetype.cpp:775
T pop()
virtual QStringList propertyNames() const
Definition: kservicetype.cpp:169
const T & previous()
QString userSpecifiedIconName() const
Returns the user-specified icon for this mimetype.
Definition: kmimetype.cpp:731
QString toString() const
void push(const T &t)
static Ptr findByPath(const QString &path, mode_t mode=0, bool fast_mode=false, int *accuracy=0)
Finds a KMimeType with the given url.
Definition: kmimetype.cpp:329
Represent a mime type, like "text/plain", and the data that is associated with it.
Definition: kmimetype.h:46
int size() const
bool contains(const QString &str, Qt::CaseSensitivity cs) const
virtual QVariant property(const QString &name) const
Definition: kservicetype.cpp:154
virtual QString iconName(const KUrl &) const
Definition: kmimetype.cpp:785
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
Definition: kurl.cpp:885
A service type is, well, a type of service, where a service is an application or plugin.
Definition: kservicetype.h:43
static int sharedMimeInfoVersion()
Returns the version of the installed update-mime-database program (from freedesktop.org shared-mime-info).
Definition: kmimetype.cpp:738
static QString extractKnownExtension(const QString &fileName)
Determines the extension from a filename (or full path) using the mimetype database.
Definition: kmimetype.cpp:354
QStringRef value(const QString &namespaceUri, const QString &name) const
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
static bool matchFileName(const QString &filename, const QString &pattern)
Definition: kmimetyperepository.cpp:98
virtual int serviceOffersOffset() const
Definition: kmimetype.cpp:780
static KMimeType::Ptr defaultMimeTypePtr()
Returns the default mimetype.
Definition: kmimetype.cpp:43
QDBusMessage call(const QString &method, const QVariant &arg1, const QVariant &arg2, const QVariant &arg3, const QVariant &arg4, const QVariant &arg5, const QVariant &arg6, const QVariant &arg7, const QVariant &arg8)
QStringList parentMimeTypes() const
If this mimetype is a subclass of one or more other mimetypes, return the list of those mimetypes...
Definition: kmimetype.cpp:565
void clear()
void skipCurrentElement()
QStringList parents(const QString &mime)
Returns the list of parents for a given mimetype.
Definition: kmimetyperepository.cpp:294
static KProtocolInfoFactory * self()
The instance of the KProtocolInfoFactory.
Definition: kprotocolinfofactory.cpp:119
void append(const T &value)
static QString icon(const QString &protocol)
Returns the name of the icon, associated with the specified protocol.
Definition: kprotocolinfo.cpp:287
QString readElementText(ReadElementTextBehaviour behaviour)
Definition: ksycocafactory.h:28
bool useFavIcons()
Returns true if KMimeType::favIconForUrl should talk to kded's favicons module.
Definition: kmimetyperepository.cpp:681
Type value() const
QString protocol() const
Returns the protocol for the URL (i.e., file, http, etc.), lowercased.
Definition: kurl.cpp:672
bool isEmpty() const
bool isEmpty() const
int removeAll(const T &value)
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
QString mainExtension() const
Return the primary extension associated with this mimetype, if any.
Definition: kmimetype.cpp:743
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
virtual bool open(QFlags< QIODevice::OpenModeFlag > flags)
qint64 read(char *data, qint64 maxSize)
bool isOpen() const
void toBack()
T & first()
KProtocolInfo::Ptr findProtocol(const QString &protocol)
Definition: kprotocolinfofactory.cpp:91
int sharedMimeInfoVersion()
Definition: kmimetyperepository.cpp:783
QString resolveAlias(const QString &mime)
Check if mime is an alias, and return the canonical name for it if it is, otherwise empty...
Definition: kmimetyperepository.cpp:85
virtual QString comment(const KUrl &=KUrl()) const
Definition: kmimetype_p.h:42
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
bool isDefault() const
Return true if this mimetype is the default mimetype.
Definition: kmimetype.cpp:48
void clear()
const T value(const Key &key) const
QStringList resourceDirs(const char *type) const
This function is used internally by almost all other function as it serves and fills the directories ...
Definition: kstandarddirs.cpp:1069
static Ptr findByNameAndContent(const QString &name, const QByteArray &data, mode_t mode=0, int *accuracy=0)
Tries to find out the MIME type of filename/url and a data chunk.
Definition: kmimetype.cpp:337
bool hasPrevious() const
QStringList languageList() const
Returns the language codes selected by user, ordered by decreasing priority.
Definition: klocale.cpp:439
static Ptr findByContent(const QByteArray &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:361
QByteArray toLatin1() const
const ushort * utf16() const
QString mid(int position, int n) const
QStringList allParentMimeTypes() const
Return all parent mimetypes of this mimetype, direct or indirect.
Definition: kmimetype.cpp:586
virtual QStringList propertyNames() const
Definition: kmimetype.cpp:448
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
Returns the filename of the path.
Definition: kurl.cpp:1283
static QString defaultMimeType()
Returns the name of the default mimetype.
Definition: kmimetype.cpp:597
static Ptr findByUrl(const KUrl &url, mode_t mode=0, bool is_local_file=false, bool fast_mode=false, int *accuracy=0)
Finds a KMimeType with the given url.
Definition: kmimetype.cpp:316
virtual QVariant property(const QString &name) const
Definition: kmimetype.cpp:436
const QChar at(int position) const
void checkEssentialMimeTypes()
This function makes sure that vital mime types are installed.
Definition: kmimetyperepository.cpp:616
int length() const
char * data()
QString left(int n) const
QXmlStreamAttributes attributes() const
QString fromLatin1(const char *str, int size)
static Ptr mimeType(const QString &name, FindByNameOption options=ResolveAliases)
Retrieve a pointer to the mime type name.
Definition: kmimetype.cpp:58
void prepend(const T &value)
static KMimeType::Ptr findFromMode(const QString &path, mode_t mode, bool is_local_file)
Definition: kmimetype.cpp:86
iterator insert(const Key &key, const T &value)
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
Returns the URL as string, with all escape sequences intact, encoded in a given charset.
Definition: kurl.cpp:1035
QStringList findAllResources(const char *type, const QString &filter=QString(), SearchOptions options=NoSearchOptions) const
Tries to find all resources with the specified type.
Definition: kstandarddirs.cpp:900
int serviceOffersOffset(const QString &mimeTypeName)
Returns the offset into the service offers for a given mimetype.
Definition: kmimetypefactory.cpp:55
static Ptr findByFileContent(const QString &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:375
QString comment() const
Returns the descriptive comment associated, if any.
Definition: kservicetype.cpp:232
int size() const
Definition: kmimetype_p.h:24
static bool isBufferBinaryData(const QByteArray &data)
Returns whether a buffer has an internal format that is not human readable.
Definition: kmimetype.cpp:74
QStringRef name() const
QString canonicalName(const QString &mime)
Resolve mime if it's an alias, and return it otherwise.
Definition: kmimetyperepository.cpp:90
QStringList patterns() const
Retrieve the list of patterns associated with the MIME Type.
Definition: kmimetype.cpp:610
QString parentMimeType() const
If this mimetype is a subclass of another mimetype, return the name of the parent.
Definition: kmimetype.cpp:532
static void collectParentMimeTypes(const QString &mime, QStringList &allParents)
Definition: kmimetype.cpp:571
bool is(const QString &mimeTypeName) const
Do not use name()=="somename" anymore, to check for a given mimetype.
Definition: kmimetype.cpp:556
const T value(const Key &key) const
static bool isBinaryData(const QString &fileName)
Returns whether a file has an internal format that is not human readable.
Definition: kmimetype.cpp:397
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.