summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Marten <[email protected]>2017-05-06 11:26:20 +0100
committerJonathan Marten <[email protected]>2017-05-06 11:26:20 +0100
commitc285acd05e32f4d7cd59951c6b42bde0ac67e4a5 (patch)
treec7467d91499180c6dc8fc6a6f4ad3725c55504c8
parentbbd3d8feb250c4b010a1589643f47929f233f446 (diff)
filter: Port away from KDELibs4Support
Differential Revision: https://phabricator.kde.org/D5561
-rw-r--r--filter/CMakeLists.txt15
-rw-r--r--filter/filter.cc38
2 files changed, 34 insertions, 19 deletions
diff --git a/filter/CMakeLists.txt b/filter/CMakeLists.txt
index 506d16d..540d6f1 100644
--- 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
index e1ff36d..152fc0d 100644
--- a/filter/filter.cc
+++ b/filter/filter.cc
@@ -23,24 +23,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "filter.h"
+
+#include <QCoreApplication>
#include <QFileInfo>
#include <QFile>
+#include <QDebug>
+#include <QUrl>
+#include <QMimeType>
+#include <QMimeDatabase>
-#include <kcomponentdata.h>
-#include <kdebug.h>
-#include <kmimetype.h>
#include <kfilterbase.h>
#include <kcompressiondevice.h>
#include <kfilterdev.h>
-#include <QUrl>
+
+#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 @@ int kdemain( int argc, char ** argv)
FilterProtocol slave(argv[1], argv[2], argv[3]);
slave.dispatchLoop();
- kDebug(7110) << "Done";
+ qDebug(KIO_FILTER_DEBUG) << "Done";
return 0;
}
@@ -113,7 +118,7 @@ void FilterProtocol::get(const QUrl& url)
#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 @@ void FilterProtocol::get(const QUrl& url)
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 @@ void FilterProtocol::get(const QUrl& url)
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 @@ void FilterProtocol::get(const QUrl& url)
#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
}