diff --git a/filter/CMakeLists.txt b/filter/CMakeLists.txt --- a/filter/CMakeLists.txt +++ b/filter/CMakeLists.txt @@ -1,7 +1,16 @@ -add_library(kio_filter MODULE filter.cc) -target_link_libraries(kio_filter KF5::KDELibs4Support KF5::Archive KF5::KIOCore) -set_target_properties(kio_filter PROPERTIES OUTPUT_NAME "filter") +include(ECMQtDeclareLoggingCategory) + +set(kio_filter_SRCS filter.cc) +ecm_qt_declare_logging_category(kio_filter_SRCS + HEADER loggingcategory.h + IDENTIFIER KIO_FILTER_DEBUG + CATEGORY_NAME kio_filter + DEFAULT_SEVERITY Debug) + +add_library(kio_filter MODULE ${kio_filter_SRCS}) +target_link_libraries(kio_filter KF5::Archive KF5::KIOCore) +set_target_properties(kio_filter PROPERTIES OUTPUT_NAME "filter") install(TARGETS kio_filter DESTINATION ${PLUGIN_INSTALL_DIR}/kf5/kio) install( FILES gzip.protocol DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/filter/filter.cc b/filter/filter.cc --- a/filter/filter.cc +++ b/filter/filter.cc @@ -23,24 +23,29 @@ */ #include "filter.h" + +#include #include #include +#include +#include +#include +#include -#include -#include -#include #include #include #include -#include + +#include "loggingcategory.h" extern "C" { Q_DECL_EXPORT int kdemain(int argc, char **argv); } int kdemain( int argc, char ** argv) { - KComponentData componentData( "kio_filter" ); + QCoreApplication app(argc, argv); + app.setApplicationName("kio_filter"); - kDebug(7110) << "Starting"; + qDebug(KIO_FILTER_DEBUG) << "Starting"; if (argc != 4) { @@ -51,7 +56,7 @@ FilterProtocol slave(argv[1], argv[2], argv[3]); slave.dispatchLoop(); - kDebug(7110) << "Done"; + qDebug(KIO_FILTER_DEBUG) << "Done"; return 0; } @@ -113,7 +118,7 @@ #else result = localFile.read(inputBuffer.data(), inputBuffer.size()); #endif - kDebug(7110) << "requestData: got " << result; + qDebug(KIO_FILTER_DEBUG) << "requestData: got " << result; if (result <= 0) { bError = true; @@ -131,7 +136,7 @@ result = filter->uncompress(); if ((filter->outBufferAvailable() == 0) || (result == KFilterBase::End)) { - kDebug(7110) << "avail_out = " << filter->outBufferAvailable(); + qDebug(KIO_FILTER_DEBUG) << "avail_out = " << filter->outBufferAvailable(); if (filter->outBufferAvailable() != 0) { // Discard unused space :-) @@ -140,17 +145,18 @@ if (bNeedMimetype) { // Can we use the "base" filename? E.g. foo.txt.bz2 const QString extension = QFileInfo(subURL.path()).suffix(); - KMimeType::Ptr mime; + QMimeDatabase db; + QMimeType mime; if (extension == "gz" || extension == "bz" || extension == "bz2") { QString baseName = subURL.path(); baseName.truncate(baseName.length() - extension.length() - 1 /*the dot*/); - kDebug(7110) << "baseName=" << baseName; - mime = KMimeType::findByNameAndContent(baseName, outputBuffer); + qDebug(KIO_FILTER_DEBUG) << "baseName=" << baseName; + mime = db.mimeTypeForFileNameAndData(baseName, outputBuffer); } else { - mime = KMimeType::findByContent(outputBuffer); + mime = db.mimeTypeForData(outputBuffer); } - kDebug(7110) << "Emitting mimetype " << mime->name(); - mimeType( mime->name() ); + qDebug(KIO_FILTER_DEBUG) << "Emitting mimetype " << mime.name(); + mimeType( mime.name() ); bNeedMimetype = false; } data( outputBuffer ); // Send data @@ -172,7 +178,7 @@ #else result = localFile.read(inputBuffer.data(), inputBuffer.size()); #endif - kDebug(7110) << "requestData: got" << result << "(expecting 0)"; + qDebug(KIO_FILTER_DEBUG) << "requestData: got" << result << "(expecting 0)"; data(QByteArray()); // Send EOF }