summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2015-03-17 08:03:30 (GMT)
committerMontel Laurent <montel@kde.org>2015-03-17 08:03:30 (GMT)
commit778f5bb9cb8faa81f981ead802f10f2a66953e44 (patch)
tree72ae5c80be9a16d3b05b435242e0934c51b2a08b
parent855d2df586d385a319bea1760f915d7f7adbb262 (diff)
Reactivate it
-rw-r--r--generators/chm/CMakeLists.txt2
-rw-r--r--generators/chm/kio-msits/CMakeLists.txt4
-rw-r--r--generators/chm/kio-msits/kio_mits_debug.cpp23
-rw-r--r--generators/chm/kio-msits/kio_mits_debug.h27
-rw-r--r--generators/chm/kio-msits/msits.cpp64
5 files changed, 87 insertions, 33 deletions
diff --git a/generators/chm/CMakeLists.txt b/generators/chm/CMakeLists.txt
index 736a024..e048248 100644
--- a/generators/chm/CMakeLists.txt
+++ b/generators/chm/CMakeLists.txt
@@ -1,4 +1,4 @@
-#add_subdirectory( kio-msits )
+add_subdirectory( kio-msits )
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../..
diff --git a/generators/chm/kio-msits/CMakeLists.txt b/generators/chm/kio-msits/CMakeLists.txt
index 746e819..435b94c 100644
--- a/generators/chm/kio-msits/CMakeLists.txt
+++ b/generators/chm/kio-msits/CMakeLists.txt
@@ -7,12 +7,12 @@ include_directories(
########### next target ###############
-set(kio_msits_PART_SRCS msits.cpp )
+set(kio_msits_PART_SRCS msits.cpp kio_mits_debug.cpp)
add_library(kio_msits MODULE ${kio_msits_PART_SRCS})
-target_link_libraries(kio_msits KF5::KIOCore ${CHM_LIBRARY} )
+target_link_libraries(kio_msits KF5::KIOCore Qt5::Core ${CHM_LIBRARY} )
install(TARGETS kio_msits DESTINATION ${KDE_INSTALL_PLUGINDIR} )
diff --git a/generators/chm/kio-msits/kio_mits_debug.cpp b/generators/chm/kio-msits/kio_mits_debug.cpp
new file mode 100644
index 0000000..35758e0
--- /dev/null
+++ b/generators/chm/kio-msits/kio_mits_debug.cpp
@@ -0,0 +1,23 @@
+/* This file is part of the KDE project
+ Copyright (C) 2014 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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 "kio_mits_debug.h"
+Q_LOGGING_CATEGORY(KIO_MITS_LOG, "log_kio_msits")
+
+
diff --git a/generators/chm/kio-msits/kio_mits_debug.h b/generators/chm/kio-msits/kio_mits_debug.h
new file mode 100644
index 0000000..afcdf17
--- /dev/null
+++ b/generators/chm/kio-msits/kio_mits_debug.h
@@ -0,0 +1,27 @@
+/* This file is part of the KDE project
+ Copyright (C) 2014 Laurent Montel <montel@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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 KIO_MITS_DEBUG_H
+#define KIO_MITS_DEBUG_H
+
+#include <QLoggingCategory>
+Q_DECLARE_LOGGING_CATEGORY(KIO_MITS_LOG)
+
+#endif
+
diff --git a/generators/chm/kio-msits/msits.cpp b/generators/chm/kio-msits/msits.cpp
index 8d22c40..9fe3d7c 100644
--- a/generators/chm/kio-msits/msits.cpp
+++ b/generators/chm/kio-msits/msits.cpp
@@ -18,8 +18,8 @@
#include <stdlib.h>
#include <sys/stat.h>
-#include <kapplication.h>
-#include <QDebug>
+#include <qcoreapplication.h>
+#include "kio_mits_debug.h"
#include <QUrl>
#include <QMimeType>
#include <QMimeDatabase>
@@ -38,20 +38,21 @@ extern "C"
{
int Q_DECL_EXPORT kdemain( int argc, char **argv )
{
- kDebug() << "*** kio_msits Init";
+ qCDebug(KIO_MITS_LOG) << "*** kio_msits Init";
- KComponentData instance( "kio_msits" );
+ QCoreApplication app(argc, argv);
+ app.setApplicationName(QLatin1String("kio_msits"));
if ( argc != 4 )
{
- kDebug() << "Usage: kio_msits protocol domain-socket1 domain-socket2";
+ qCDebug(KIO_MITS_LOG) << "Usage: kio_msits protocol domain-socket1 domain-socket2";
exit (-1);
}
ProtocolMSITS slave ( argv[2], argv[3] );
slave.dispatchLoop();
- kDebug() << "*** kio_msits Done";
+ qCDebug(KIO_MITS_LOG) << "*** kio_msits Done";
return 0;
}
}
@@ -84,30 +85,30 @@ void ProtocolMSITS::get( const QUrl& url )
chmUnitInfo ui;
QByteArray buf;
- kDebug() << "kio_msits::get() " << url.path();
+ qCDebug(KIO_MITS_LOG) << "kio_msits::get() " << url.path();
if ( !parseLoadAndLookup ( url, fileName ) )
return; // error() has been called by parseLoadAndLookup
- kDebug() << "kio_msits::get: parseLoadAndLookup returned " << fileName;
+ qCDebug(KIO_MITS_LOG) << "kio_msits::get: parseLoadAndLookup returned " << fileName;
if ( LCHMUrlFactory::handleFileType( url.path(), htmdata ) )
{
buf = htmdata.toUtf8();
- kDebug() << "Using special handling for image pages: " << htmdata;
+ qCDebug(KIO_MITS_LOG) << "Using special handling for image pages: " << htmdata;
}
else
{
if ( isDirectory (fileName) )
{
- error( KIO::ERR_IS_DIRECTORY, url.prettyUrl() );
+ error( KIO::ERR_IS_DIRECTORY, url.toString() );
return;
}
if ( !ResolveObject ( fileName, &ui) )
{
- kDebug() << "kio_msits::get: could not resolve filename " << fileName;
- error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
+ qCDebug(KIO_MITS_LOG) << "kio_msits::get: could not resolve filename " << fileName;
+ error( KIO::ERR_DOES_NOT_EXIST, url.toString() );
return;
}
@@ -115,17 +116,20 @@ void ProtocolMSITS::get( const QUrl& url )
if ( RetrieveObject (&ui, (unsigned char*) buf.data(), 0, ui.length) == 0 )
{
- kDebug() << "kio_msits::get: could not retrieve filename " << fileName;
- error( KIO::ERR_NO_CONTENT, url.prettyUrl() );
+ qCDebug(KIO_MITS_LOG) << "kio_msits::get: could not retrieve filename " << fileName;
+ error( KIO::ERR_NO_CONTENT, url.toString() );
return;
}
}
totalSize( buf.size() );
+#if 0 //PORT QT5
+ QMimeDatabase db;
QMimeType result = db.mimeTypeForNameAndData( fileName, buf );
- kDebug() << "Emitting mimetype " << result->name();
+ qCDebug(KIO_MITS_LOG) << "Emitting mimetype " << result.name();
- mimeType( result->name() );
+ mimeType( result.name() );
+#endif
data( buf );
processedSize( buf.size() );
@@ -135,13 +139,13 @@ void ProtocolMSITS::get( const QUrl& url )
bool ProtocolMSITS::parseLoadAndLookup ( const QUrl& url, QString& abspath )
{
- kDebug() << "ProtocolMSITS::parseLoadAndLookup (const KUrl&) " << url.path();
+ qCDebug(KIO_MITS_LOG) << "ProtocolMSITS::parseLoadAndLookup (const KUrl&) " << url.path();
int pos = url.path().indexOf ("::");
if ( pos == -1 )
{
- error( KIO::ERR_MALFORMED_URL, url.prettyUrl() );
+ error( KIO::ERR_MALFORMED_URL, url.toString() );
return false;
}
@@ -152,11 +156,11 @@ bool ProtocolMSITS::parseLoadAndLookup ( const QUrl& url, QString& abspath )
if ( abspath.startsWith( "ms-its:" ) )
abspath = abspath.mid( 7 );
- kDebug() << "ProtocolMSITS::parseLoadAndLookup: filename " << filename << ", path " << abspath;
+ qCDebug(KIO_MITS_LOG) << "ProtocolMSITS::parseLoadAndLookup: filename " << filename << ", path " << abspath;
if ( filename.isEmpty() )
{
- error( KIO::ERR_MALFORMED_URL, url.prettyUrl() );
+ error( KIO::ERR_MALFORMED_URL, url.toString() );
return false;
}
@@ -164,14 +168,14 @@ bool ProtocolMSITS::parseLoadAndLookup ( const QUrl& url, QString& abspath )
if ( m_chmFile && filename == m_openedFile )
return true;
- kDebug() << "Opening a new CHM file " << QFile::encodeName( QDir::toNativeSeparators( filename ) );
+ qCDebug(KIO_MITS_LOG) << "Opening a new CHM file " << QFile::encodeName( QDir::toNativeSeparators( filename ) );
// First try to open a temporary file
chmFile * tmpchm;
- if( (tmpchm = chm_open ( QFile::encodeName( QDir::toNativeSeparators( filename) ) ) ) == 0 )
+ if( (tmpchm = chm_open ( QFile::encodeName( QDir::toNativeSeparators( filename) ).constData() ) ) == 0 )
{
- error( KIO::ERR_COULD_NOT_READ, url.prettyUrl() );
+ error( KIO::ERR_COULD_NOT_READ, url.toString() );
return false;
}
@@ -182,7 +186,7 @@ bool ProtocolMSITS::parseLoadAndLookup ( const QUrl& url, QString& abspath )
m_chmFile = tmpchm;
m_openedFile = filename;
- kDebug() << "A CHM file " << filename << " has beed opened successfully";
+ qCDebug(KIO_MITS_LOG) << "A CHM file " << filename << " has beed opened successfully";
return true;
}
@@ -225,18 +229,18 @@ void ProtocolMSITS::stat (const QUrl &url)
QString fileName;
chmUnitInfo ui;
- kDebug() << "kio_msits::stat (const KUrl& url) " << url.path();
+ qCDebug(KIO_MITS_LOG) << "kio_msits::stat (const KUrl& url) " << url.path();
if ( !parseLoadAndLookup ( url, fileName ) )
return; // error() has been called by parseLoadAndLookup
if ( !ResolveObject ( fileName, &ui ) )
{
- error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
+ error( KIO::ERR_DOES_NOT_EXIST, url.toString() );
return;
}
- kDebug() << "kio_msits::stat: adding an entry for " << fileName;
+ qCDebug(KIO_MITS_LOG) << "kio_msits::stat: adding an entry for " << fileName;
UDSEntry entry;
if ( isDirectory ( fileName ) )
@@ -262,7 +266,7 @@ void ProtocolMSITS::listDir (const QUrl & url)
{
QString filepath;
- kDebug() << "kio_msits::listDir (const KUrl& url) " << url.path();
+ qCDebug(KIO_MITS_LOG) << "kio_msits::listDir (const KUrl& url) " << url.path();
if ( !parseLoadAndLookup ( url, filepath ) )
return; // error() has been called by parseLoadAndLookup
@@ -275,12 +279,12 @@ void ProtocolMSITS::listDir (const QUrl & url)
return;
}
- kDebug() << "kio_msits::listDir: enumerating directory " << filepath;
+ qCDebug(KIO_MITS_LOG) << "kio_msits::listDir: enumerating directory " << filepath;
QVector<QString> listing;
if ( chm_enumerate_dir ( m_chmFile,
- filepath.toLocal8Bit(),
+ filepath.toLocal8Bit().constData(),
CHM_ENUMERATE_NORMAL | CHM_ENUMERATE_FILES | CHM_ENUMERATE_DIRS,
chmlib_enumerator,
&listing ) != 1 )