Commit c285acd0 authored by Jonathan Marten's avatar Jonathan Marten

filter: Port away from KDELibs4Support

Differential Revision: https://phabricator.kde.org/D5561
parent bbd3d8fe
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} )
......
......@@ -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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment