diff --git a/CMakeLists.txt b/CMakeLists.txt index 17d37636..9387092b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,14 +113,6 @@ set_package_properties(DBusMenuQt PROPERTIES TYPE RECOMMENDED ) -macro_optional_find_package(LibExtractor) -set_package_properties(LibExtractor PROPERTIES - DESCRIPTION "GNU Libextractor is a library used to extract meta data from files" - URL "https://www.gnu.org/software/libextractor/" - TYPE RECOMMENDED - PURPOSE "Required by KIO" -) - macro_optional_find_package(MPV 0.23.0) set_package_properties(MPV PROPERTIES DESCRIPTION "A fork of mplayer2 and MPlayer" diff --git a/appveyor.yml b/appveyor.yml index fdb93d4f..1c2eea97 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,7 +21,7 @@ build_script: sudo apt-get install -qq cmake katie-dev libenchant-dev \ libmagick++-dev libmpv-dev xorg-dev mesa-common-dev \ libavahi-common-dev libwebp-dev libudev-dev liblzma-dev \ - libexiv2-dev libbz2-dev libacl1-dev libcdio-dev libextractor-dev \ + libexiv2-dev libbz2-dev libacl1-dev libcdio-dev \ libcurl4-openssl-dev libssl-dev libdbusmenu-katie \ media-player-info shared-mime-info media-player-info xdg-utils ccache diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index 8316a105..b6ee2fd2 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -13,7 +13,6 @@ set(cmakeFilesDontInstall FindENCHANT.cmake FindACL.cmake FindLibCDIO.cmake - FindLibExtractor.cmake FindDevinfo.cmake ) diff --git a/cmake/modules/FindLibExtractor.cmake b/cmake/modules/FindLibExtractor.cmake deleted file mode 100644 index a12b970a..00000000 --- a/cmake/modules/FindLibExtractor.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# Try to find GNU Libextractor, once done this will define: -# -# LIBEXTRACTOR_FOUND - system has GNU Libextractor -# LIBEXTRACTOR_INCLUDES - the GNU Libextractor include directory -# LIBEXTRACTOR_LIBRARIES - the libraries needed to use GNU Libextractor -# -# Copyright (c) 2022 Ivailo Monev -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -if(NOT WIN32) - include(FindPkgConfig) - pkg_check_modules(PC_LIBEXTRACTOR QUIET libextractor) - - set(LIBEXTRACTOR_INCLUDES ${PC_LIBEXTRACTOR_INCLUDE_DIRS}) - set(LIBEXTRACTOR_LIBRARIES ${PC_LIBEXTRACTOR_LIBRARIES}) -endif() - -set(LIBEXTRACTOR_VERSION ${PC_LIBEXTRACTOR_VERSION}) - -if(NOT LIBEXTRACTOR_INCLUDES OR NOT LIBEXTRACTOR_LIBRARIES) - find_path(LIBEXTRACTOR_INCLUDES - NAMES extractor.h - HINTS $ENV{LIBEXTRACTORDIR}/include - ) - - find_library(LIBEXTRACTOR_LIBRARIES - NAMES extractor - HINTS $ENV{LIBEXTRACTORDIR}/lib - ) -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(LibExtractor - VERSION_VAR LIBEXTRACTOR_VERSION - REQUIRED_VARS LIBEXTRACTOR_LIBRARIES LIBEXTRACTOR_INCLUDES -) - -mark_as_advanced(LIBEXTRACTOR_INCLUDES LIBEXTRACTOR_LIBRARIES) diff --git a/kio/CMakeLists.txt b/kio/CMakeLists.txt index f7004935..b4a1fc1f 100644 --- a/kio/CMakeLists.txt +++ b/kio/CMakeLists.txt @@ -1,9 +1,5 @@ project(kio) -if(NOT LibExtractor_FOUND) - set(KIO_NO_LIBEXTRACTOR TRUE) -endif() - # This applies to all subdirs; let's put kio's dependencies (and own dirs) here, once and for all include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/bookmarks @@ -20,21 +16,8 @@ include_directories( ${CMAKE_BINARY_DIR}/kutils/kpasswdstore ) -set(KIO_EXTRA_LIBS) -if(NOT KIO_NO_LIBEXTRACTOR) - include_directories(${LIBEXTRACTOR_INCLUDES}) - set(KIO_EXTRA_LIBS - ${KIO_EXTRA_LIBS} - ${LIBEXTRACTOR_LIBRARIES} - ) -endif() - -configure_file( - kio/config-kio.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/kio/config-kio.h -) - add_subdirectory(misc) +add_subdirectory(metadata) if(ENABLE_TESTING) add_subdirectory(tests) endif() @@ -69,6 +52,7 @@ set(kiocore_STAT_SRCS kio/kfileitemdelegate.cpp kio/kfilemetainfo.cpp kio/kfilemetainfoitem.cpp + kio/kfilemetadata.cpp kio/kmimetypechooser.cpp kio/kprotocolmanager.cpp kio/kremoteencoding.cpp @@ -161,10 +145,6 @@ set(kio_LIB_SRCS add_library(kio ${LIBRARY_TYPE} ${kio_LIB_SRCS}) -target_link_libraries(kio PRIVATE - ${KIO_EXTRA_LIBS} -) - target_link_libraries(kio PUBLIC ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS} @@ -197,6 +177,7 @@ install( application.desktop kcmodule.desktop kcmoduleinit.desktop + kfilemetadataplugin.desktop kurifilterplugin.desktop kfile/kpropertiesdialogplugin.desktop kio/kfileitemactionplugin.desktop @@ -257,6 +238,7 @@ install( kio/kfileitemdelegate.h kio/kfilemetainfo.h kio/kfilemetainfoitem.h + kio/kfilemetadata.h kio/kmimetypechooser.h kio/knfsshare.h kio/kprotocolmanager.h diff --git a/kio/kfile/kfilemetadataconfigurationwidget.cpp b/kio/kfile/kfilemetadataconfigurationwidget.cpp index e3481bce..ac71d325 100644 --- a/kio/kfile/kfilemetadataconfigurationwidget.cpp +++ b/kio/kfile/kfilemetadataconfigurationwidget.cpp @@ -26,8 +26,6 @@ #include #include "kfilemetadataprovider_p.h" -#include - #include #include #include diff --git a/kio/kfile/kfilemetadatawidget.cpp b/kio/kfile/kfilemetadatawidget.cpp index 6e360a15..60af7abb 100644 --- a/kio/kfile/kfilemetadatawidget.cpp +++ b/kio/kfile/kfilemetadatawidget.cpp @@ -34,8 +34,6 @@ #include #include -#include - class KFileMetaDataWidget::Private { public: diff --git a/kio/kfilemetadataplugin.desktop b/kio/kfilemetadataplugin.desktop new file mode 100644 index 00000000..60a706b2 --- /dev/null +++ b/kio/kfilemetadataplugin.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KFileMetaData/Plugin +Name=File Meta Information Plugin diff --git a/kio/kio/config-kio.h.cmake b/kio/kio/config-kio.h.cmake deleted file mode 100644 index f06ca545..00000000 --- a/kio/kio/config-kio.h.cmake +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine KIO_NO_LIBEXTRACTOR diff --git a/kio/kio/kdesktopfileactions.cpp b/kio/kio/kdesktopfileactions.cpp index a9c835c6..ad08fc96 100644 --- a/kio/kio/kdesktopfileactions.cpp +++ b/kio/kio/kdesktopfileactions.cpp @@ -19,8 +19,6 @@ #include "kdesktopfileactions.h" -#include "config-kio.h" - #include "krun.h" #include "kautomount.h" diff --git a/kio/kio/kfileitem.cpp b/kio/kio/kfileitem.cpp index bfb744c9..6f71ca3d 100644 --- a/kio/kio/kfileitem.cpp +++ b/kio/kio/kfileitem.cpp @@ -21,14 +21,12 @@ #include "kfileitem.h" #include -#include #include #include #include #include #include - #include #include diff --git a/kio/kio/kfilemetadata.cpp b/kio/kio/kfilemetadata.cpp new file mode 100644 index 00000000..a7eb1f7a --- /dev/null +++ b/kio/kio/kfilemetadata.cpp @@ -0,0 +1,47 @@ +/* This file is part of the KDE libraries + Copyright (C) 2022 Ivailo Monev + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "kfilemetadata.h" + +KFileMetaDataPlugin::KFileMetaDataPlugin(QObject *parent) + : QObject(parent) +{ +} + +KFileMetaDataPlugin::~KFileMetaDataPlugin() +{ +} + +QStringList KFileMetaDataPlugin::keys() const +{ + return QStringList(); +} + +QStringList KFileMetaDataPlugin::mimeTypes() const +{ + return QStringList(); +} + +QList KFileMetaDataPlugin::metaData(const KUrl &url, const KFileMetaInfo::WhatFlags flags) +{ + Q_UNUSED(url); + Q_UNUSED(flags); + return QList(); +} + +#include "moc_kfilemetadata.cpp" diff --git a/kio/kio/kfilemetadata.h b/kio/kio/kfilemetadata.h new file mode 100644 index 00000000..adf1087c --- /dev/null +++ b/kio/kio/kfilemetadata.h @@ -0,0 +1,49 @@ +/* This file is part of the KDE libraries + Copyright (C) 2022 Ivailo Monev + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KFILEMETADATA_H +#define KFILEMETADATA_H + +#include "kio_export.h" +#include "kurl.h" +#include "kfilemetainfo.h" +#include "kfilemetainfoitem.h" + +#include +#include + +/*! + Class to retrieve file metadata. + + @since 4.21 + @warning the API is subject to change +*/ +class KIO_EXPORT KFileMetaDataPlugin : public QObject +{ + Q_OBJECT +public: + KFileMetaDataPlugin(QObject *parent = nullptr); + ~KFileMetaDataPlugin(); + + virtual QStringList keys() const; + virtual QStringList mimeTypes() const; + + virtual QList metaData(const KUrl &url, const KFileMetaInfo::WhatFlags flags); +}; + +#endif diff --git a/kio/kio/kfilemetainfo.cpp b/kio/kio/kfilemetainfo.cpp index 56ab015a..f084841b 100644 --- a/kio/kio/kfilemetainfo.cpp +++ b/kio/kio/kfilemetainfo.cpp @@ -19,22 +19,21 @@ #include "kfilemetainfo.h" #include "kfilemetainfoitem.h" #include "kfilemetainfoitem_p.h" - -#ifndef KIO_NO_LIBEXTRACTOR -#include -#endif +#include "kfilemetadata.h" #include #include #include #include #include +#include +#include +#include #include #include #include -#ifndef KIO_NO_LIBEXTRACTOR static const KFileMetaInfoItem nullitem; static KFileMetaInfoItem mutablenullitem; @@ -44,601 +43,40 @@ public: KFileMetaInfoItemList items; KUrl m_url; - void init(const QByteArray &filepath, const KUrl& url, KFileMetaInfo::WhatFlags w); + void init(const QString &filename, const KUrl& url, KFileMetaInfo::WhatFlags w); void operator=(const KFileMetaInfoPrivate& kfmip) { items = kfmip.items; m_url = kfmip.m_url; } - - static QString string(enum EXTRACTOR_MetaFormat format, - const char *data, size_t data_len); - static QString time(enum EXTRACTOR_MetaFormat format, - const char *data, size_t data_len); - static QString frameRate(enum EXTRACTOR_MetaFormat format, - const char *data, size_t data_len); - static QString sampleRate(enum EXTRACTOR_MetaFormat format, - const char *data, size_t data_len); - static QString bitRate(enum EXTRACTOR_MetaFormat format, - const char *data, size_t data_len); - static int metadata(void *cls, - const char *plugin_name, - enum EXTRACTOR_MetaType type, - enum EXTRACTOR_MetaFormat format, - const char *data_mime_type, - const char *data, - size_t data_len); }; -QString KFileMetaInfoPrivate::string(enum EXTRACTOR_MetaFormat format, - const char *data, size_t data_len) -{ - switch (format) { - case EXTRACTOR_METAFORMAT_UTF8: { - return QString::fromUtf8(data, data_len - 1); - } - case EXTRACTOR_METAFORMAT_C_STRING: { - return QString::fromLocal8Bit(data, data_len - 1); - } - case EXTRACTOR_METAFORMAT_BINARY: { - return QString(); - } - case EXTRACTOR_METAFORMAT_UNKNOWN: - default: { - kWarning() << "Unknown metadata format"; - return QString(); - } - } - Q_UNREACHABLE(); - return QString(); -} - -QString KFileMetaInfoPrivate::time(enum EXTRACTOR_MetaFormat format, - const char *data, size_t data_len) -{ - const QString timestring = KFileMetaInfoPrivate::string(format, data, data_len); - const QStringList splittimestring = timestring.split(QLatin1Char('.')); - if (splittimestring.size() == 2) { - return splittimestring.at(0); - } - kDebug() << "Unexpected time" << timestring; - return timestring; -} - -QString KFileMetaInfoPrivate::frameRate(enum EXTRACTOR_MetaFormat format, - const char *data, size_t data_len) -{ - const QString frameratestring = KFileMetaInfoPrivate::string(format, data, data_len); - const QStringList splitframeratestring = frameratestring.split(QLatin1Char('/')); - if (splitframeratestring.size() == 2) { - return i18n("%1 per second").arg(splitframeratestring.at(0)); - } - kDebug() << "Unexpected frame rate" << frameratestring; - return frameratestring; -} - -QString KFileMetaInfoPrivate::sampleRate(enum EXTRACTOR_MetaFormat format, - const char *data, size_t data_len) -{ - const QString ratestring = KFileMetaInfoPrivate::string(format, data, data_len); - return i18n("%1 kHz").arg(ratestring.toInt() / 1000); -} - -QString KFileMetaInfoPrivate::bitRate(enum EXTRACTOR_MetaFormat format, - const char *data, size_t data_len) -{ - const QString ratestring = KFileMetaInfoPrivate::string(format, data, data_len); - return i18n("%1 Kbps").arg(ratestring.toInt() / 1000); -} - -int KFileMetaInfoPrivate::metadata(void *cls, - const char *plugin_name, - enum EXTRACTOR_MetaType type, - enum EXTRACTOR_MetaFormat format, - const char *data_mime_type, - const char *data, - size_t data_len) -{ - // kDebug() << type << format << data_mime_type << data_len; - KFileMetaInfoPrivate* kfmip = static_cast(cls); - switch (type) { - case EXTRACTOR_METATYPE_MIMETYPE: { - // kfileitem#mimetype, handled internally - break; - } - case EXTRACTOR_METATYPE_FILENAME: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_COMMENT: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_TITLE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_PAGE_COUNT: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#pageCount", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - // TODO: or http://www.semanticdesktop.org/ontologies/2007/03/22/nco#emailAddress? - case EXTRACTOR_METATYPE_AUTHOR_EMAIL: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Email", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_PUBLISHER: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#publisher", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_URL: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_URI: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#uniqueFileIdentifier", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_HASH_MD4: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashValue", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - const KFileMetaInfoItem kfmi2("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashAlgorithm", QString::fromLatin1("MD4")); - kfmip->items.append(kfmi2); - break; - } - case EXTRACTOR_METATYPE_HASH_MD5: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashValue", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - const KFileMetaInfoItem kfmi2("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashAlgorithm", QString::fromLatin1("MD5")); - kfmip->items.append(kfmi2); - break; - } - case EXTRACTOR_METATYPE_HASH_SHA0: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashValue", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - const KFileMetaInfoItem kfmi2("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashAlgorithm", QString::fromLatin1("SHA-0")); - kfmip->items.append(kfmi2); - break; - } - case EXTRACTOR_METATYPE_HASH_SHA1: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashValue", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - const KFileMetaInfoItem kfmi2("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashAlgorithm", QString::fromLatin1("SHA-1")); - kfmip->items.append(kfmi2); - break; - } - case EXTRACTOR_METATYPE_GPS_LATITUDE_REF: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLatitudeRef", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_GPS_LONGITUDE_REF: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLongitudeRef", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_LOCATION_COUNTRY: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#country", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_DESCRIPTION: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_COPYRIGHT: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#copyright", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_KEYWORDS: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#keyword", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_SUMMARY: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#summary", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_SUBJECT: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#subject", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CREATOR: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#creator", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generator", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CREATION_DATE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_MODIFICATION_DATE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentLastModified", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_EXPOSURE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureTime", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_EXPOSURE_BIAS: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureBiasValue", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_APERTURE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#apertureValue", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_FLASH: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#flash", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_FOCAL_LENGTH: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLength", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_FOCAL_LENGTH_35MM: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLengthIn35mmFilm", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_ISO_SPEED: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#isoSpeedRatings", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_EXPOSURE_MODE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureMode", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_METERING_MODE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#meteringMode", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_WHITE_BALANCE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#whiteBalance", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_ORIENTATION: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#orientation", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_IMAGE_RESOLUTION: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#resolution", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CHARACTER_SET: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#characterSet", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_LINE_COUNT: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#lineCount", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_WORD_COUNT: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#wordCount", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CHARACTER_COUNT: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#characterCount", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_REVISION_NUMBER: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#sequence", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_ALBUM: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicAlbum", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_ARTIST: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#artist", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_GENRE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#genre", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_TRACK_NUMBER: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#trackNumber", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_PERFORMER: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#performer", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CONTACT_INFORMATION: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_DISCLAIMER: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#disclaimer", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_WRITER: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#textWriter", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CONTRIBUTOR_NAME: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contributor", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_MOVIE_DIRECTOR: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#director", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CONDUCTOR: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#conductor", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_INTERPRETATION: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#interpretedBy", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_COMPOSER: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#composer", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_BEATS_PER_MINUTE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#beatsPerMinute", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_ENCODED_BY: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#encodedBy", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_ORIGINAL_ARTIST: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#originalArtist", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_ORIGINAL_WRITER: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#originalTextWriter", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_ORIGINAL_RELEASE_YEAR: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#originalReleaseYear", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_LYRICS: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#SynchronizedText", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_LICENSEE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#licensee", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_MUSICIAN_CREDITS_LIST: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#InvolvedPerson", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_SUBTITLE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#subtitle", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CODEC: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#codec", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_VIDEO_CODEC: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#videoCodec", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_AUDIO_CODEC: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#audioCodec", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_SUBTITLE_CODEC: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#subtitleCodec", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CONTAINER_FORMAT: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#belongsToContainer", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_BITRATE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#averageBitrate", KFileMetaInfoPrivate::bitRate(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_ENCODER: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#encoder", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_GROUPING: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#UnionOfEventJournalTodo", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_DEVICE_MANUFACTURER: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#make", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CAMERA_MODEL: - case EXTRACTOR_METATYPE_DEVICE_MODEL: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#model", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_CHANNELS: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#channels", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_SAMPLE_RATE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#sampleRate", KFileMetaInfoPrivate::sampleRate(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_AUDIO_DEPTH: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#audioBitDepth", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_AUDIO_BITRATE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#audioBitRate", KFileMetaInfoPrivate::bitRate(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_VIDEO_DEPTH: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#videoBitDepth", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_FRAME_RATE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#frameRate", KFileMetaInfoPrivate::frameRate(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#aspectRatio", KFileMetaInfoPrivate::string(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_VIDEO_BITRATE: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#videoBitRate", KFileMetaInfoPrivate::bitRate(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_DURATION: - case EXTRACTOR_METATYPE_VIDEO_DURATION: - case EXTRACTOR_METATYPE_AUDIO_DURATION: { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#duration", KFileMetaInfoPrivate::time(format, data, data_len)); - kfmip->items.append(kfmi); - break; - } - case EXTRACTOR_METATYPE_IMAGE_DIMENSIONS: - case EXTRACTOR_METATYPE_VIDEO_DIMENSIONS: { - const QString dimensions = KFileMetaInfoPrivate::string(format, data, data_len); - const QStringList splitdimensions = dimensions.split(QLatin1Char('x')); - if (splitdimensions.size() == 2) { - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width", splitdimensions.at(0)); - kfmip->items.append(kfmi); - const KFileMetaInfoItem kfmi2("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height", splitdimensions.at(1)); - kfmip->items.append(kfmi2); - } else { - kWarning() << "Invalid dimensions" << dimensions; - } - break; - } - } - return 0; -} - -void KFileMetaInfoPrivate::init(const QByteArray &filepath, const KUrl& url, KFileMetaInfo::WhatFlags w) +void KFileMetaInfoPrivate::init(const QString &filename, const KUrl &url, KFileMetaInfo::WhatFlags w) { m_url = url; - struct EXTRACTOR_PluginList *extractorplugins = NULL; - // since EXTRACTOR_plugin_remove() does not really work explicitly enable most plugins - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "av", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "exiv2", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "flac", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "gif", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "gstreamer", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "jpeg", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "midi", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "mpeg", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "ogg", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "tiff", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "it", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "nsf", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "nsfe", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "png", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "riff", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "s3m", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "sid", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "wav", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "xm", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - if ((w & KFileMetaInfo::ContentInfo) != 0) { - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "pdf", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "ole2", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "html", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "dvi", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "man", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - extractorplugins = EXTRACTOR_plugin_add(extractorplugins, "ps", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); + const KService::List kfmdplugins = KServiceTypeTrader::self()->query("KFileMetaData/Plugin"); + foreach (const KService::Ptr &kfmdplugin, kfmdplugins) { + KFileMetaDataPlugin *kfmdplugininstance = kfmdplugin->createInstance(); + if (kfmdplugininstance) { + const KMimeType::Ptr filemimetype = KMimeType::findByUrl(url); + // qDebug() << Q_FUNC_INFO << filemimetype->name() << kfmdplugininstance->mimeTypes(); + foreach (const QString &kfmdpluginmime, kfmdplugininstance->mimeTypes()) { + if (filemimetype->is(kfmdpluginmime)) { + items.append(kfmdplugininstance->metaData(url, w)); + break; + } + } + delete kfmdplugininstance; + } else { + kWarning() << "Could not create KFileMetaDataPlugin instance"; + } } - EXTRACTOR_extract( - extractorplugins, - filepath.constData(), - NULL, //data - 0, // size - KFileMetaInfoPrivate::metadata, this - ); - EXTRACTOR_plugin_remove_all(extractorplugins); - - bool hasfilename = false; - // remove duplicates from the falltrough cases in the extraction which essentially have the - // same meaning + // remove duplicates. first comes, first serves KFileMetaInfoItemList::iterator it = items.begin(); QStringList itemkeys; itemkeys.reserve(items.size()); while (it != items.end()) { - if (it->key() == QLatin1String("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName")) { - hasfilename = true; - } - if (!itemkeys.contains(it->key())) { itemkeys.append(it->key()); it++; @@ -649,11 +87,17 @@ void KFileMetaInfoPrivate::init(const QByteArray &filepath, const KUrl& url, KFi } // for compatibility - if (!hasfilename) { - const QString kfmifilename = QFileInfo(filepath).fileName(); - const KFileMetaInfoItem kfmi("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName", kfmifilename); - items.append(kfmi); - } + const KFileMetaInfoItem kfmi( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName"), + filename + ); + items.append(kfmi); + const QString kfmiurl = url.prettyUrl(); + const KFileMetaInfoItem kfmi2( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url"), + kfmiurl + ); + items.append(kfmi2); } KFileMetaInfo::KFileMetaInfo(const QString& path, KFileMetaInfo::WhatFlags w) @@ -662,15 +106,15 @@ KFileMetaInfo::KFileMetaInfo(const QString& path, KFileMetaInfo::WhatFlags w) QFileInfo fileinfo(path); // only open the file if it is not a pipe if (fileinfo.isFile() || fileinfo.isDir() || fileinfo.isSymLink()) { - d->init(path.toLocal8Bit(), KUrl(path), w); + d->init(fileinfo.fileName(), KUrl(path), w); } } KFileMetaInfo::KFileMetaInfo(const KUrl& url, KFileMetaInfo::WhatFlags w) : d(new KFileMetaInfoPrivate()) { - const QString path = url.toLocalFile(); - d->init(path.toLocal8Bit(), url, w); + const QString filename = QFileInfo(url.toLocalFile()).fileName(); + d->init(filename, url, w); } KFileMetaInfo::KFileMetaInfo() @@ -754,90 +198,24 @@ QStringList KFileMetaInfo::preferredKeys() const QStringList KFileMetaInfo::supportedKeys() { - static const QStringList s_keys = QStringList() - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#pageCount" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#creator" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Email" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#publisher" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashValue" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashAlgorithm" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLatitudeRef" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLongitudeRef" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#country" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#copyright" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#keyword" - << "http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#summary" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#subject" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generator" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentLastModified" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureTime" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureBiasValue" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#apertureValue" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#flash" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLength" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLengthIn35mmFilm" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#isoSpeedRatings" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureMode" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#meteringMode" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#whiteBalance" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#orientation" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#resolution" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#characterSet" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#lineCount" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#wordCount" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#characterCount" - << "http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#sequence" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#duration" - << "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicAlbum" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#artist" - << "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#genre" - << "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#trackNumber" - << "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#performer" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact" - << "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#disclaimer" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#textWriter" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#contributor" - << "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#director" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#conductor" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#interpretedBy" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#composer" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#beatsPerMinute" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#encodedBy" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#originalArtist" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#originalTextWriter" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#originalReleaseYear" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#SynchronizedText" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#licensee" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#InvolvedPerson" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#subtitle" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#codec" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#videoCodec" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#audioCodec" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#subtitleCodec" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#belongsToContainer" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#averageBitrate" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#encoder" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#uniqueFileIdentifier" - << "http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#UnionOfEventJournalTodo" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#make" - << "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#model" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#channels" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#sampleRate" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#audioBitDepth" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#audioBitRate" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#videoBitDepth" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#frameRate" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#aspectRatio" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#videoBitRate" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width" - << "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height"; - return s_keys; + QStringList keys = QStringList() + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url"); + + const KService::List kfmdplugins = KServiceTypeTrader::self()->query("KFileMetaData/Plugin"); + foreach (const KService::Ptr &kfmdplugin, kfmdplugins) { + KFileMetaDataPlugin *kfmdplugininstance = kfmdplugin->createInstance(); + if (kfmdplugininstance) { + keys.append(kfmdplugininstance->keys()); + delete kfmdplugininstance; + } else { + kWarning() << "Could not create KFileMetaDataPlugin instance"; + } + } + keys.removeDuplicates(); + qSort(keys); + + return keys; } QString KFileMetaInfo::name(const QString& key) @@ -854,38 +232,43 @@ QString KFileMetaInfo::name(const QString& key) { "kfileitem#mimetype", i18nc("@label", "MIME Type") }, // implemented so far { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName", i18nc("@label", "Filename") }, + { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url", i18nc("@label file URL", "URL") }, + { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width", i18nc("@label", "Width") }, + { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height", i18nc("@label", "Height") }, + { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#copyright", i18nc("@label", "Copyright") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment", i18nc("@label", "Comment") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title", i18nc("@label music title", "Title") }, + { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#keyword", i18nc("@label", "Keyword") }, + { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description", i18nc("@label", "Description") }, + { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generator", i18nc("@label Software used to generate content", "Generator") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#make", i18nc("@label EXIF", "Manufacturer") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#model", i18nc("@label EXIF", "Model") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#orientation", i18nc("@label EXIF", "Orientation") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#artist", i18nc("@label music or image artist", "Artist") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLatitudeRef", i18nc("@label", "GPS Latitude Reference") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLongitudeRef", i18nc("@label", "GPS Longitude Reference") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#flash", i18nc("@label EXIF", "Flash") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureTime", i18nc("@label EXIF", "Exposure Time") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureBiasValue", i18nc("@label EXIF", "Exposure Bias Value") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureMode", i18nc("@label EXIF", "Exposure Mode") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#apertureValue", i18nc("@label EXIF aperture value", "Aperture") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLength", i18nc("@label EXIF", "Focal Length") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLengthIn35mmFilm", i18nc("@label EXIF", "Focal Length 35 mm") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#isoSpeedRatings", i18nc("@label EXIF", "ISO Speed Ratings") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#meteringMode", i18nc("@label EXIF", "Metering Mode") }, + { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#whiteBalance", i18nc("@label EXIF", "White Balance") }, + // TODO: implement { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#pageCount", i18nc("@label", "Page Count") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#creator", i18nc("@label", "Creator") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Email", i18nc("@label", "Creator E-Mail") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#publisher", i18nc("@label", "Publisher") }, - { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url", i18nc("@label file URL", "URL") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashValue", i18nc("@label", "Hash Value") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#hashAlgorithm", i18nc("@label", "Hash Algorithm") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLatitudeRef", i18nc("@label", "GPS Latitude Reference") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLongitudeRef", i18nc("@label", "GPS Longitude Reference") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#country", i18nc("@label", "Country") }, - { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description", i18nc("@label", "Description") }, - { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#copyright", i18nc("@label", "Copyright") }, - { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#keyword", i18nc("@label", "Keyword") }, { "http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#summary", i18nc("@label", "Summary") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#subject", i18nc("@label", "Subject") }, - { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generator", i18nc("@label Software used to generate content", "Generator") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated", i18nc("@label creation date", "Created") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentLastModified", i18nc("@label modification date", "Modified") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureTime", i18nc("@label EXIF", "Exposure Time") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureBiasValue", i18nc("@label EXIF", "Exposure Bias Value") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#apertureValue", i18nc("@label EXIF aperture value", "Aperture") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#flash", i18nc("@label EXIF", "Flash") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLength", i18nc("@label EXIF", "Focal Length") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLengthIn35mmFilm", i18nc("@label EXIF", "Focal Length 35 mm") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#isoSpeedRatings", i18nc("@label EXIF", "ISO Speed Ratings") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureMode", i18nc("@label EXIF", "Exposure Mode") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#meteringMode", i18nc("@label EXIF", "Metering Mode") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#whiteBalance", i18nc("@label EXIF", "White Balance") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#orientation", i18nc("@label EXIF", "Orientation") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#resolution", i18nc("@label EXIF", "Resolution") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#characterSet", i18nc("@label", "Character Set") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#lineCount", i18nc("@label number of lines", "Lines") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#wordCount", i18nc("@label number of words", "Words") }, @@ -893,7 +276,6 @@ QString KFileMetaInfo::name(const QString& key) { "http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#sequence", i18nc("@label", "Revision") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#duration", i18nc("@label", "Duration") }, { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicAlbum", i18nc("@label music album", "Album") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#artist", i18nc("@label music or image artist", "Artist") }, { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#genre", i18nc("@label music genre", "Genre") }, { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#trackNumber", i18nc("@label music track number", "Track") }, { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#performer", i18nc("@label", "Performer") }, @@ -923,8 +305,6 @@ QString KFileMetaInfo::name(const QString& key) { "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#encoder", i18nc("@label", "Encoder") }, { "http://www.semanticdesktop.org/ontologies/2007/05/10/nid3#uniqueFileIdentifier", i18nc("@label", "URI") }, { "http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#UnionOfEventJournalTodo", i18nc("@label", "Grouping") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#make", i18nc("@label EXIF", "Manufacturer") }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#model", i18nc("@label EXIF", "Model") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#channels", i18nc("@label", "Channels") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#sampleRate", i18nc("@label", "Sample Rate") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#audioBitDepth", i18nc("@label", "Audio Bit Depth") }, @@ -933,8 +313,6 @@ QString KFileMetaInfo::name(const QString& key) { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#frameRate", i18nc("@label", "Frame Rate") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#aspectRatio", i18nc("@label", "Aspect Ratio") }, { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#videoBitRate", i18nc("@label", "Video Bit Rate") }, - { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width", i18nc("@label", "Width") }, - { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height", i18nc("@label", "Height") }, }; const TranslationMap::const_iterator it = s_translations.find(key); @@ -949,95 +327,3 @@ QString KFileMetaInfo::name(const QString& key) } return key; } - -#else //KIO_NO_LIBEXTRACTOR - -class KFileMetaInfoPrivate : public QSharedData -{ -public: -}; - -KFileMetaInfo::KFileMetaInfo(const QString& path, KFileMetaInfo::WhatFlags w) -{ - Q_UNUSED(path); - Q_UNUSED(w); -} - -KFileMetaInfo::KFileMetaInfo(const KUrl& url, KFileMetaInfo::WhatFlags w) -{ - Q_UNUSED(url); - Q_UNUSED(w); -} - -KFileMetaInfo::KFileMetaInfo() -{ -} - -KFileMetaInfo::KFileMetaInfo(const KFileMetaInfo& kfmi) -{ - Q_UNUSED(kfmi); -} - -KFileMetaInfo& KFileMetaInfo::operator=(KFileMetaInfo const& kfmi) -{ - Q_UNUSED(kfmi); - return *this; -} - -KFileMetaInfo::~KFileMetaInfo() -{ -} - -const KUrl& KFileMetaInfo::url() const -{ - static const KUrl item; - return item; -} - -const KFileMetaInfoItemList& KFileMetaInfo::items() const -{ - static const KFileMetaInfoItemList items; - return items; -} - -const KFileMetaInfoItem& KFileMetaInfo::item(const QString& key) const -{ - Q_UNUSED(key); - static const KFileMetaInfoItem item; - return item; -} - -QStringList KFileMetaInfo::keys() const -{ - return QStringList(); -} - -KFileMetaInfoItem& KFileMetaInfo::item(const QString& key) -{ - Q_UNUSED(key); - static KFileMetaInfoItem item; - return item; -} - -bool KFileMetaInfo::isValid() const -{ - return false; -} - -QStringList KFileMetaInfo::preferredKeys() const -{ - return QStringList(); -} - -QStringList KFileMetaInfo::supportedKeys() const -{ - return QStringList(); -} - -QString KFileMetaInfo::name(const QString& key) -{ - Q_UNUSED(key); - retrun QString(); -} - -#endif // KIO_NO_LIBEXTRACTOR diff --git a/kio/kio/kfilemetainfoitem.h b/kio/kio/kfilemetainfoitem.h index 28f473c1..415c19db 100644 --- a/kio/kio/kfilemetainfoitem.h +++ b/kio/kio/kfilemetainfoitem.h @@ -39,6 +39,10 @@ public: * @brief Copy constructor **/ KFileMetaInfoItem(const KFileMetaInfoItem& item); + /** + * @brief Constructor used by plugins + **/ + KFileMetaInfoItem(const QString& key, const QString& value); /** * @brief Destructor **/ @@ -65,8 +69,6 @@ public: const QString& name() const; private: QSharedDataPointer d; - - KFileMetaInfoItem(const QString& key, const QString& value); }; #endif // KFILEMETAINFOITEM_H diff --git a/kio/kio/kurifilter.h b/kio/kio/kurifilter.h index 924ff73e..0ccec587 100644 --- a/kio/kio/kurifilter.h +++ b/kio/kio/kurifilter.h @@ -30,12 +30,11 @@ #include #include - +#include class KUriFilterPrivate; class KUriFilterDataPrivate; class KCModule; -#include /** * Class that holds information about a search provider. diff --git a/kio/metadata/CMakeLists.txt b/kio/metadata/CMakeLists.txt new file mode 100644 index 00000000..8d348522 --- /dev/null +++ b/kio/metadata/CMakeLists.txt @@ -0,0 +1,19 @@ +set(kfilemetadata_exiv2_SRCS kfilemetadata_exiv2.cpp ) + +kde4_add_plugin(kfilemetadata_exiv2 ${kfilemetadata_exiv2_SRCS}) +target_link_libraries(kfilemetadata_exiv2 + ${KDE4_KIO_LIBS} + ${KDE4_KEXIV2_LIBS} +) + +install( + TARGETS kfilemetadata_exiv2 + DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} +) + +########### install files ############### + +install( + FILES kfilemetadata_exiv2.desktop + DESTINATION ${KDE4_SERVICES_INSTALL_DIR} +) diff --git a/kio/metadata/kfilemetadata_exiv2.cpp b/kio/metadata/kfilemetadata_exiv2.cpp new file mode 100644 index 00000000..8484dc92 --- /dev/null +++ b/kio/metadata/kfilemetadata_exiv2.cpp @@ -0,0 +1,284 @@ +/* This file is part of the KDE libraries + Copyright (C) 2022 Ivailo Monev + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "kfilemetadata_exiv2.h" +#include "kpluginfactory.h" +#include "kexiv2.h" + +#include + +KFileMetaDataExiv2Plugin::KFileMetaDataExiv2Plugin(QObject* parent, const QVariantList &args) + : KFileMetaDataPlugin(parent) +{ + Q_UNUSED(args); +} + +KFileMetaDataExiv2Plugin::~KFileMetaDataExiv2Plugin() +{ +} + +QStringList KFileMetaDataExiv2Plugin::keys() const +{ + static const QStringList result = QStringList() + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#copyright") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#keyword") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generator") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#make") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#model") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#orientation") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#artist") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLatitudeRef") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLongitudeRef") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#flash") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureTime") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureBiasValue") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureMode") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#apertureValue") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLength") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLengthIn35mmFilm") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#isoSpeedRatings") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#meteringMode") + << QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#whiteBalance"); + return result; +} + +QStringList KFileMetaDataExiv2Plugin::mimeTypes() const +{ + // for reference: + // https://dev.exiv2.org/projects/exiv2/wiki/Supported_image_formats + static const QStringList result = QStringList() + << QString::fromLatin1("image/jpeg") + << QString::fromLatin1("image/x-exv") + << QString::fromLatin1("image/x-canon-cr2") + << QString::fromLatin1("image/x-canon-crw") + << QString::fromLatin1("image/x-minolta-mrw") + << QString::fromLatin1("image/tiff") + << QString::fromLatin1("image/webp") + << QString::fromLatin1("image/x-webp") + << QString::fromLatin1("image/x-nikon-nef") + << QString::fromLatin1("image/x-pentax-pef") + << QString::fromLatin1("image/x-panasonic-rw2") + << QString::fromLatin1("image/x-olympus-orf") + << QString::fromLatin1("image/png") + << QString::fromLatin1("image/x-fuji-raf") + << QString::fromLatin1("image/x-eps") + << QString::fromLatin1("image/gif") + << QString::fromLatin1("image/photoshop") + << QString::fromLatin1("image/x-photoshop") + << QString::fromLatin1("image/x-tga") + << QString::fromLatin1("image/bmp") + << QString::fromLatin1("image/x-bmp") + << QString::fromLatin1("image/x-ms-bmp") + << QString::fromLatin1("image/jp2"); + return result; +} + +QList KFileMetaDataExiv2Plugin::metaData(const KUrl &url, const KFileMetaInfo::WhatFlags flags) +{ + Q_UNUSED(flags); + QList result; + const KExiv2 kexiv2(url.toLocalFile()); + const KExiv2::DataMap kexiv2metadata = kexiv2.data(); + foreach (const QByteArray &kexiv2key, kexiv2metadata.keys()) { + const QString kexiv2value = kexiv2metadata.value(kexiv2key); + // qDebug() << Q_FUNC_INFO << kexiv2key << kexiv2value; + // for reference: + // https://exiv2.org/tags.html + if (kexiv2key == "Exif.Image.ImageWidth") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.ImageLength") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.Copyright") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#copyright"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.UserComment" || kexiv2key == "Exif.Photo.XPComment") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Photo.XPTitle") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.XPKeywords") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#keyword"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.ImageDescription") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.Software") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generator"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.Make") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#make"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.Model") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#model"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.Orientation") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#orientation"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.Artist") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#artist"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.GPSInfo.GPSLatitudeRef") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLatitudeRef"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.GPSInfo.GPSLongitudeRef") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#gpsLongitudeRef"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.Flash") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#flash"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Photo.ExposureTime") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureTime"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.ExposureBiasValue") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureBiasValue"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Photo.ExposureMode") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#exposureMode"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Photo.ApertureValue") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#apertureValue"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.FocalLength") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLength"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Photo.FocalLengthIn35mmFilm") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#focalLengthIn35mmFilm"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Image.ISOSpeedRatings") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#isoSpeedRatings"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Photo.MeteringMode") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#meteringMode"), + kexiv2value + ) + ); + } else if (kexiv2key == "Exif.Photo.WhiteBalance") { + result.append( + KFileMetaInfoItem( + QString::fromLatin1("http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#whiteBalance"), + kexiv2value + ) + ); + } + } + // qDebug() << Q_FUNC_INFO << url << kexiv2metadata; + return result; +} + +K_PLUGIN_FACTORY(KFileMetaDataExiv2PluginFactory, registerPlugin();) +K_EXPORT_PLUGIN(KFileMetaDataExiv2PluginFactory("kfilemetadata_exiv2")) + +#include "moc_kfilemetadata_exiv2.cpp" diff --git a/kio/metadata/kfilemetadata_exiv2.desktop b/kio/metadata/kfilemetadata_exiv2.desktop new file mode 100644 index 00000000..6511e061 --- /dev/null +++ b/kio/metadata/kfilemetadata_exiv2.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Type=Service +Name=KFileMetaDataExiv2Plugin +X-KDE-Library=kfilemetadata_exiv2 +X-KDE-ServiceTypes=KFileMetaData/Plugin +InitialPreference=1 diff --git a/kio/metadata/kfilemetadata_exiv2.h b/kio/metadata/kfilemetadata_exiv2.h new file mode 100644 index 00000000..f59ad854 --- /dev/null +++ b/kio/metadata/kfilemetadata_exiv2.h @@ -0,0 +1,37 @@ +/* This file is part of the KDE libraries + Copyright (C) 2022 Ivailo Monev + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2, as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KFILEMETADATA_EXIV2_H +#define KFILEMETADATA_EXIV2_H + +#include "kfilemetadata.h" + +class KFileMetaDataExiv2Plugin : public KFileMetaDataPlugin +{ + Q_OBJECT +public: + KFileMetaDataExiv2Plugin(QObject* parent, const QVariantList &args); + ~KFileMetaDataExiv2Plugin(); + + QStringList keys() const final; + QStringList mimeTypes() const final; + + QList metaData(const KUrl &url, const KFileMetaInfo::WhatFlags flags) final; +}; + +#endif // KFILEMETADATA_EXIV2_H diff --git a/kio/tests/CMakeLists.txt b/kio/tests/CMakeLists.txt index 39d7c230..a8a6bd9e 100644 --- a/kio/tests/CMakeLists.txt +++ b/kio/tests/CMakeLists.txt @@ -64,8 +64,5 @@ target_link_libraries(kfstest ${KDE4_KIO_LIBS}) ########### kfilemetainfotest ############### -if(NOT KIO_NO_LIBEXTRACTOR) - kde4_add_test(kio-kfilemetainfotest kfilemetainfotest.cpp) - target_link_libraries(kio-kfilemetainfotest ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) -endif() - +kde4_add_test(kio-kfilemetainfotest kfilemetainfotest.cpp) +target_link_libraries(kio-kfilemetainfotest ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})