diff --git a/iso/CMakeLists.txt b/iso/CMakeLists.txt index 70cf642e..abd45349 100644 --- a/iso/CMakeLists.txt +++ b/iso/CMakeLists.txt @@ -1,29 +1,30 @@ include(FindZLIB) include(libisofs/CMakeLists.txt) include_directories(${KF5_INCLUDES_DIRS} ${QT_INCLUDES}) set(kio_iso_PART_SRCS kisodirectory.cpp kisofile.cpp qfilehack.cpp kiso.cpp - kisodebug.cpp - iso.cpp) + iso.cpp + ../krusader/krdebuglogger.cpp +) add_library(kio_iso MODULE ${kio_iso_PART_SRCS} ${libisofs_SRCS}) #this is a library so it needs to enforce it's translation domain, not use the application's domain. add_definitions(-DTRANSLATION_DOMAIN="krusader") target_link_libraries(kio_iso KF5::Archive KF5::ConfigCore KF5::KIOCore ${ZLIB_LIBRARY} ) install(TARGETS kio_iso DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES iso.protocol DESTINATION ${SERVICES_INSTALL_DIR}) install(FILES kio_isorc DESTINATION ${CONFIG_INSTALL_DIR}) diff --git a/iso/kiso.cpp b/iso/kiso.cpp index fbf63a17..31f7fd38 100644 --- a/iso/kiso.cpp +++ b/iso/kiso.cpp @@ -1,513 +1,513 @@ /***************************************************************************** * Copyright (C) 2000 David Faure * * Copyright (C) 2003 Leo Savernik * * Copyright (C) 2002 Szombathelyi György * * This file is heavily based on ktar from kdelibs * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This package 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this package; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ #include "kiso.h" // QtCore #include #include #include #include #include #include #include #include #include #include #include "libisofs/isofs.h" #include "qfilehack.h" #ifdef Q_OS_LINUX #undef __STRICT_ANSI__ #include #define __STRICT_ANSI__ #include #include #endif //////////////////////////////////////////////////////////////////////// /////////////////////////// KIso /////////////////////////////////// //////////////////////////////////////////////////////////////////////// /** * puts the track layout of the device 'fname' into 'tracks' * tracks structure: start sector, track number, ... * tracks should be 100*2 entry long (this is the maximum in the CD-ROM standard) * currently it's linux only, porters are welcome */ static int getTracks(const char *fname, int *tracks) { - KISOFUNC; + KRFUNC; int ret = 0; memset(tracks, 0, 200*sizeof(int)); #ifdef Q_OS_LINUX int fd, i; struct cdrom_tochdr tochead; struct cdrom_tocentry tocentry; //qDebug() << "getTracks open:" << fname << endl; fd = QT_OPEN(fname, O_RDONLY | O_NONBLOCK); if (fd > 0) { if (ioctl(fd, CDROMREADTOCHDR, &tochead) != -1) { // qDebug() << "getTracks first track:" << tochead.cdth_trk0 // << " last track " << tochead.cdth_trk1 << endl; for (i = tochead.cdth_trk0;i <= tochead.cdth_trk1;++i) { if (ret > 99) break; memset(&tocentry, 0, sizeof(struct cdrom_tocentry)); tocentry.cdte_track = i; tocentry.cdte_format = CDROM_LBA; if (ioctl(fd, CDROMREADTOCENTRY, &tocentry) < 0) break; // qDebug() << "getTracks got track " << i << " starting at: " << // tocentry.cdte_addr.lba << endl; if ((tocentry.cdte_ctrl & 0x4) == 0x4) { tracks[ret<<1] = tocentry.cdte_addr.lba; tracks[(ret<<1)+1] = i; ret++; } } } close(fd); } #endif return ret; } class KIso::KIsoPrivate { public: KIsoPrivate() {} QStringList dirList; }; KIso::KIso(const QString& filename, const QString & _mimetype) : KArchive(0L) { - KISOFUNC; - KISODEBUG("Starting KIso: " << filename << " - type: " << _mimetype); + KRFUNC; + KRDEBUG("Starting KIso: " << filename << " - type: " << _mimetype); m_startsec = -1; m_filename = filename; d = new KIsoPrivate; QString mimetype(_mimetype); bool forced = true; if (mimetype.isEmpty()) { QMimeDatabase db; QMimeType mt = db.mimeTypeForFile(filename, QMimeDatabase::MatchContent); if (mt.isValid()) mimetype = mt.name(); //qDebug() << "KIso::KIso mimetype=" << mimetype << endl; // Don't move to prepareDevice - the other constructor theoretically allows ANY filter if (mimetype == "application/x-tgz" || mimetype == "application/x-targz" || // the latter is deprecated but might still be around mimetype == "application/x-webarchive") // that's a gzipped tar file, so ask for gzip filter mimetype = "application/x-gzip"; else if (mimetype == "application/x-tbz") // that's a bzipped2 tar file, so ask for bz2 filter mimetype = "application/x-bzip2"; else { // Something else. Check if it's not really gzip though (e.g. for KOffice docs) QFile file(filename); if (file.open(QIODevice::ReadOnly)) { char firstByte; char secondByte; char thirdByte; file.getChar(&firstByte); file.getChar(&secondByte); file.getChar(&thirdByte); if (firstByte == 0037 && secondByte == (char)0213) mimetype = "application/x-gzip"; else if (firstByte == 'B' && secondByte == 'Z' && thirdByte == 'h') mimetype = "application/x-bzip2"; else if (firstByte == 'P' && secondByte == 'K' && thirdByte == 3) { char fourthByte; file.getChar(&fourthByte); if (fourthByte == 4) mimetype = "application/x-zip"; } } } forced = false; } prepareDevice(filename, mimetype, forced); } void KIso::prepareDevice(const QString & filename, const QString & mimetype, bool forced) { - KISOFUNC; - KISODEBUG("Preparing: " << filename << " - type: " << mimetype << " - using the force: " << forced); + KRFUNC; + KRDEBUG("Preparing: " << filename << " - type: " << mimetype << " - using the force: " << forced); /* 'hack' for Qt's false assumption that only S_ISREG is seekable */ if ("inode/blockdevice" == mimetype) setDevice(new QFileHack(filename)); else { if ("application/x-gzip" == mimetype || "application/x-bzip2" == mimetype) forced = true; KCompressionDevice *device; if(mimetype.isEmpty()) { device = new KFilterDev(filename); } else { device = new KCompressionDevice(filename, KFilterDev::compressionTypeForMimeType(mimetype)); } if (device->compressionType() == KCompressionDevice::None && forced) { delete device; } else { setDevice(device); } } } KIso::KIso(QIODevice * dev) : KArchive(dev) { d = new KIsoPrivate; } KIso::~KIso() { // mjarrett: Closes to prevent ~KArchive from aborting w/o device if (isOpen()) close(); if (!m_filename.isEmpty()) delete device(); // we created it ourselves delete d; } /* callback function for libisofs */ static int readf(char *buf, unsigned int start, unsigned int len, void *udata) { - KISOFUNC; + KRFUNC; QIODevice* dev = (static_cast(udata))->device(); if (dev->seek((qint64)start << (qint64)11)) { if ((dev->read(buf, len << 11u)) != -1) return (len); } //qDebug() << "KIso::ReadRequest failed start: " << start << " len: " << len << endl; return -1; } /* callback function for libisofs */ static int mycallb(struct iso_directory_record *idr, void *udata) { - KISOFUNC; + KRFUNC; KIso *iso = static_cast(udata); QString path, user, group, symlink; int i; int access; int time, cdate, adate; rr_entry rr; bool special = false; KArchiveEntry *entry = NULL, *oldentry = NULL; char z_algo[2], z_params[2]; long long z_size = 0; if ((idr->flags[0] & 1) && !iso->showhidden) return 0; if (iso->level) { if (isonum_711(idr->name_len) == 1) { switch (idr->name[0]) { case 0: path += ("."); special = true; break; case 1: path += (".."); special = true; break; } } if (iso->showrr && ParseRR(idr, &rr) > 0) { if (!special) path = rr.name; symlink = rr.sl; access = rr.mode; time = rr.t_mtime; adate = rr.t_atime; cdate = rr.t_ctime; user.setNum(rr.uid); group.setNum(rr.gid); z_algo[0] = rr.z_algo[0];z_algo[1] = rr.z_algo[1]; z_params[0] = rr.z_params[0];z_params[1] = rr.z_params[1]; z_size = rr.z_size; } else { access = iso->dirent->permissions() & ~S_IFMT; adate = cdate = time = isodate_915(idr->date, 0); user = iso->dirent->user(); group = iso->dirent->group(); if (idr->flags[0] & 2) access |= S_IFDIR; else access |= S_IFREG; if (!special) { if (iso->joliet) { for (i = 0;i < (isonum_711(idr->name_len) - 1);i += 2) { QChar ch(be2me_16(*((ushort*)&(idr->name[i])))); if (ch == ';') break; path += ch; } } else { for (i = 0;i < isonum_711(idr->name_len);++i) { if (idr->name[i] == ';') break; if (idr->name[i]) path += (idr->name[i]); } } if (path.endsWith('.')) path.resize(path.length() - 1); } } if (iso->showrr) FreeRR(&rr); if (idr->flags[0] & 2) { entry = new KIsoDirectory(iso, path, access | S_IFDIR, time, adate, cdate, user, group, symlink); } else { entry = new KIsoFile(iso, path, access, time, adate, cdate, user, group, symlink, (long long)(isonum_733(idr->extent)) << (long long)11, isonum_733(idr->size)); if (z_size)(static_cast (entry))->setZF(z_algo, z_params, z_size); } iso->dirent->addEntry(entry); } if ((idr->flags[0] & 2) && (iso->level == 0 || !special)) { if (iso->level) { oldentry = iso->dirent; iso->dirent = static_cast(entry); } iso->level++; ProcessDir(&readf, isonum_733(idr->extent), isonum_733(idr->size), &mycallb, udata); iso->level--; if (iso->level) iso->dirent = static_cast(oldentry); } return 0; } void KIso::addBoot(struct el_torito_boot_descriptor* bootdesc) { - KISOFUNC; + KRFUNC; int i; long long size; boot_head boot; boot_entry *be; QString path; KIsoFile *entry; path = "Catalog"; entry = new KIsoFile(this, path, dirent->permissions() & ~S_IFDIR, dirent->date(), dirent->adate(), dirent->cdate(), dirent->user(), dirent->group(), QString(), (long long)isonum_731(bootdesc->boot_catalog) << (long long)11, (long long)2048); dirent->addEntry(entry); if (!ReadBootTable(&readf, isonum_731(bootdesc->boot_catalog), &boot, this)) { i = 1; be = boot.defentry; while (be) { size = BootImageSize(isonum_711(be->data.d_e.media), isonum_721(be->data.d_e.seccount)); path = "Default Image"; if (i > 1) path += " (" + QString::number(i) + ')'; entry = new KIsoFile(this, path, dirent->permissions() & ~S_IFDIR, dirent->date(), dirent->adate(), dirent->cdate(), dirent->user(), dirent->group(), QString(), (long long)isonum_731(be->data.d_e.start) << (long long)11, size << (long long)9); dirent->addEntry(entry); be = be->next; i++; } FreeBootTable(&boot); } } void KIso::readParams() { - KISOFUNC; + KRFUNC; KConfig *config; config = new KConfig("kio_isorc"); KConfigGroup group(config, QString()); showhidden = group.readEntry("showhidden", false); showrr = group.readEntry("showrr", true); delete config; } bool KIso::openArchive(QIODevice::OpenMode mode) { - KISOFUNC; + KRFUNC; iso_vol_desc *desc; QString path, uid, gid; QT_STATBUF buf; int tracks[2*100], trackno = 0, i, access, c_b, c_i, c_j; KArchiveDirectory *root; struct iso_directory_record* idr; struct el_torito_boot_descriptor* bootdesc; if (mode == QIODevice::WriteOnly) return false; readParams(); d->dirList.clear(); tracks[0] = 0; if (m_startsec > 0) tracks[0] = m_startsec; //qDebug() << " m_startsec: " << m_startsec << endl; /* We'll use the permission and user/group of the 'host' file except * in Rock Ridge, where the permissions are stored on the file system */ if (QT_STAT(m_filename.toLocal8Bit(), &buf) < 0) { /* defaults, if stat fails */ memset(&buf, 0, sizeof(struct stat)); buf.st_mode = 0777; } else { /* If it's a block device, try to query the track layout (for multisession) */ if (m_startsec == -1 && S_ISBLK(buf.st_mode)) trackno = getTracks(m_filename.toLatin1(), (int*) & tracks); } uid.setNum(buf.st_uid); gid.setNum(buf.st_gid); access = buf.st_mode & ~S_IFMT; //qDebug() << "KIso::openArchive number of tracks: " << trackno << endl; if (trackno == 0) trackno = 1; for (i = 0;i < trackno;++i) { c_b = 1;c_i = 1;c_j = 1; root = rootDir(); if (trackno > 1) { path.clear(); QTextStream(&path) << "Track " << tracks[(i<<1)+1]; root = new KIsoDirectory(this, path, access | S_IFDIR, buf.st_mtime, buf.st_atime, buf.st_ctime, uid, gid, QString()); rootDir()->addEntry(root); } desc = ReadISO9660(&readf, tracks[i<<1], this); if (!desc) { //qDebug() << "KIso::openArchive no volume descriptors" << endl; continue; } while (desc) { switch (isonum_711(desc->data.type)) { case ISO_VD_BOOT: bootdesc = (struct el_torito_boot_descriptor*) & (desc->data); if (!memcmp(EL_TORITO_ID, bootdesc->system_id, ISODCL(8, 39))) { path = "El Torito Boot"; if (c_b > 1) path += " (" + QString::number(c_b) + ')'; dirent = new KIsoDirectory(this, path, access | S_IFDIR, buf.st_mtime, buf.st_atime, buf.st_ctime, uid, gid, QString()); root->addEntry(dirent); addBoot(bootdesc); c_b++; } break; case ISO_VD_PRIMARY: case ISO_VD_SUPPLEMENTARY: idr = (struct iso_directory_record*) & (((struct iso_primary_descriptor*) & desc->data)->root_directory_record); joliet = JolietLevel(&desc->data); if (joliet) { QTextStream(&path) << "Joliet level " << joliet; if (c_j > 1) path += " (" + QString::number(c_j) + ')'; } else { path = "ISO9660"; if (c_i > 1) path += " (" + QString::number(c_i) + ')'; } dirent = new KIsoDirectory(this, path, access | S_IFDIR, buf.st_mtime, buf.st_atime, buf.st_ctime, uid, gid, QString()); root->addEntry(dirent); level = 0; mycallb(idr, this); if (joliet) c_j++; else c_i++; break; } desc = desc->next; } free(desc); } device()->close(); return true; } bool KIso::closeArchive() { - KISOFUNC; + KRFUNC; d->dirList.clear(); return true; } bool KIso::writeDir(const QString&, const QString&, const QString&, mode_t, time_t, time_t, time_t) { return false; } bool KIso::prepareWriting(const QString&, const QString&, const QString&, qint64, mode_t, time_t, time_t, time_t) { return false; } bool KIso::finishWriting(qint64) { return false; } bool KIso::writeSymLink(const QString &, const QString &, const QString &, const QString &, mode_t, time_t, time_t, time_t) { return false; } bool KIso::doWriteDir(const QString&, const QString&, const QString&, mode_t, const QDateTime&, const QDateTime &, const QDateTime &) { return false; } bool KIso::doWriteSymLink(const QString &, const QString &, const QString &, const QString &, mode_t, const QDateTime&, const QDateTime&, const QDateTime&) { return false; } bool KIso::doPrepareWriting(const QString& , const QString& , const QString& , qint64, mode_t, const QDateTime&, const QDateTime&, const QDateTime&) { return false; } bool KIso::doFinishWriting(qint64) { return false; } void KIso::virtual_hook(int id, void* data) { KArchive::virtual_hook(id, data); } diff --git a/iso/kiso.h b/iso/kiso.h index ff2d7fe7..f0d8d5f0 100644 --- a/iso/kiso.h +++ b/iso/kiso.h @@ -1,121 +1,121 @@ /***************************************************************************** * Copyright (C) 2000 David Faure * * Copyright (C) 2003 Leo Savernik * * Copyright (C) 2002 Szombathelyi György * * This file is heavily based on ktar from kdelibs * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This package 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this package; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ #ifndef KISO_H #define KISO_H // QtCore #include #include #include +#include "../krusader/krdebuglogger.h" #include "kisofile.h" #include "kisodirectory.h" -#include "kisodebug.h" /** * @short A class for reading (optionally compressed) iso9660 files. */ class KIso : public KArchive { public: /** * Creates an instance that operates on the given filename. * using the compression filter associated to given mimetype. * * @param filename is a local path (e.g. "/home/weis/myfile.tgz") * @param mimetype "application/x-gzip" or "application/x-bzip2" * Do not use application/x-tgz or so. Only the compression layer ! * If the mimetype is omitted, it will be determined from the filename. */ KIso(const QString& filename, const QString & mimetype = QString()); /** * Creates an instance that operates on the given device. * The device can be compressed (KFilterDev) or not (QFile, etc.). * WARNING: don't assume that giving a QFile here will decompress the file, * in case it's compressed! */ KIso(QIODevice * dev); /** * If the .iso is still opened, then it will be * closed automatically by the destructor. */ virtual ~KIso(); /** * The name of the os file, as passed to the constructor * Null if you used the QIODevice constructor. */ QString fileName() { return m_filename; } bool writeDir(const QString& , const QString& , const QString&, mode_t, time_t, time_t, time_t); bool writeSymLink(const QString &, const QString &, const QString &, const QString &, mode_t, time_t, time_t, time_t); bool prepareWriting(const QString& , const QString& , const QString& , qint64, mode_t, time_t, time_t, time_t); bool finishWriting(qint64); void setStartSec(int startsec) { m_startsec = startsec; } int startSec() { return m_startsec; } bool showhidden, showrr; int level, joliet; KIsoDirectory *dirent; protected: /** * Opens the archive for reading. * Parses the directory listing of the archive * and creates the KArchiveDirectory/KArchiveFile entries. * */ void readParams(); virtual bool openArchive(QIODevice::OpenMode mode) Q_DECL_OVERRIDE; virtual bool closeArchive() Q_DECL_OVERRIDE; virtual bool doWriteDir(const QString&, const QString&, const QString&, mode_t, const QDateTime &, const QDateTime &, const QDateTime &) Q_DECL_OVERRIDE; virtual bool doWriteSymLink(const QString &, const QString &, const QString &, const QString &, mode_t, const QDateTime &, const QDateTime &, const QDateTime &) Q_DECL_OVERRIDE; virtual bool doPrepareWriting(const QString& , const QString& , const QString& , qint64, mode_t, const QDateTime &, const QDateTime &, const QDateTime &) Q_DECL_OVERRIDE; virtual bool doFinishWriting(qint64) Q_DECL_OVERRIDE; private: /** * @internal */ void addBoot(struct el_torito_boot_descriptor* bootdesc); void prepareDevice(const QString & filename, const QString & mimetype, bool forced = false); int m_startsec; QString m_filename; protected: virtual void virtual_hook(int id, void* data) Q_DECL_OVERRIDE; private: class KIsoPrivate; KIsoPrivate * d; }; #endif diff --git a/iso/kisodebug.cpp b/iso/kisodebug.cpp deleted file mode 100644 index 8892d976..00000000 --- a/iso/kisodebug.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** - krdebuglogger.cpp - ------------------ - copyright : (C) 2016 by Rafi Yanai & Shie Erlich - email : krusader@users.sf.net - web site : http://krusader.sourceforge.net - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "kisodebug.h" - -int KIsoDebug::indentation = 1; -const int KIsoDebug::indentationIncrease = 3; -const QString KIsoDebug::logFile = QDir::tempPath() + "/kisodebug"; - -//! This constructor is used inside the KRFUNC macro. For more details: the description of the KRFUNC macro can be seen -KIsoDebug::KIsoDebug(const QString &argFunction, int line) : function(argFunction) -{ - QFile file; - QTextStream stream; - prepareWriting(file, stream); - stream << QString("┏"); // Indicates that a function has been started - stream << function << "(" << line << ")" << endl; - indentation += indentationIncrease; -} - -//! For more information: the description of the KRFUNC macro can be seen -KIsoDebug::~KIsoDebug() -{ - indentation -= indentationIncrease; - QFile file; - QTextStream stream; - prepareWriting(file, stream); - stream << QString("┗"); // Indicates that a function is going to finish - stream << function << endl; -} - -//! Prepares some elements before a writing into the kiso debug log file -void KIsoDebug::prepareWriting(QFile &file, QTextStream &stream) -{ - file.setFileName(logFile); - file.open(QIODevice::WriteOnly | QIODevice::Append); - stream.setDevice(&file); - stream << "Pid:" << (int)getpid(); - // Applies the indentation level to make logs clearer - for (int x = 0; x < indentation; ++x) - stream << " "; -} diff --git a/iso/kisodebug.h b/iso/kisodebug.h deleted file mode 100644 index 04a3ba97..00000000 --- a/iso/kisodebug.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - krdebuglogger.h - ------------------ - copyright : (C) 2016 by Rafi Yanai & Shie Erlich - email : krusader@users.sf.net - web site : http://krusader.sourceforge.net - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef KISODEBUG_H -#define KISODEBUG_H - -// QtCore -#include -#include -#include - -#include - -//! A class to manage some aspects of the writing of messages into the kiso debug log file -class KIsoDebug -{ -private: - QString function; //! The name of a function which is going to be written about - static int indentation; //! The indentation that is presently used, it represents how many spaces are going to be used - const static int indentationIncrease; //! The quantity of spaces that are going be added to the indentation when increasing it - static const QString logFile; //! The name of the log file - -public: - KIsoDebug(const QString& argFunction, int line); - ~KIsoDebug(); - static void prepareWriting(QFile &, QTextStream &); -}; - -#ifdef QT_DEBUG - -//! Writes a function name in the kiso debug log, etc. when entering the function and automatically before exiting from it -#define KISOFUNC \ - KIsoDebug functionLogger(__FUNCTION__, __LINE__); - -#define KISODEBUG(X...) do{ \ - QFile file; \ - QTextStream stream; \ - KIsoDebug::prepareWriting(file, stream); \ - stream << __FUNCTION__ << "(" <<__LINE__<< "): "; \ - stream << X << endl; \ - } while(0); -#else -#define KISOFUNC -#define KISODEBUG(X...) qDebug() << X -#endif - -#endif // KISODEBUG_H - diff --git a/krArc/CMakeLists.txt b/krArc/CMakeLists.txt index 63a16fdc..c8d24059 100644 --- a/krArc/CMakeLists.txt +++ b/krArc/CMakeLists.txt @@ -1,26 +1,26 @@ include_directories(${KF5_INCLUDES_DIRS} ${QT_INCLUDES}) set(kio_krarc_PART_SRCS krarc.cpp krarcbasemanager.cpp krlinecountingprocess.cpp - krdebuglogger.cpp + ../krusader/krdebuglogger.cpp ) add_library(kio_krarc MODULE ${kio_krarc_PART_SRCS}) #this is a library so it needs to enforce it's translation domain, not use the application's domain. add_definitions(-DTRANSLATION_DOMAIN="krusader") # TODO porting : new variables needed? target_link_libraries(kio_krarc Qt5::Gui KF5::Archive KF5::ConfigCore KF5::CoreAddons KF5::I18n KF5::KIOCore ) install(TARGETS kio_krarc DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES krarc.protocol DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/krArc/krarc.h b/krArc/krarc.h index a86c9586..919c284b 100644 --- a/krArc/krarc.h +++ b/krArc/krarc.h @@ -1,141 +1,141 @@ /*************************************************************************** krarc.h ------------------- begin : Sat Jun 14 14:42:49 IDT 2003 copyright : (C) 2003 by Rafi Yanai & Shie Erlich email : yanai@users.sf.net ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef KRARC_H #define KRARC_H // QtCore #include #include #include #include #include #include #include #include #include #include "krarcbasemanager.h" #include "krlinecountingprocess.h" -#include "krdebuglogger.h" +#include "../krusader/krdebuglogger.h" class KFileItem; class QByteArray; class QTextCodec; class kio_krarcProtocol : public QObject, public KIO::SlaveBase, public KrArcBaseManager { Q_OBJECT public: kio_krarcProtocol(const QByteArray &pool_socket, const QByteArray &app_socket); virtual ~kio_krarcProtocol(); virtual void stat(const QUrl &url) Q_DECL_OVERRIDE; virtual void get(const QUrl &url) Q_DECL_OVERRIDE; virtual void put(const QUrl &url, int permissions, KIO::JobFlags flags) Q_DECL_OVERRIDE; virtual void mkdir(const QUrl &url, int permissions) Q_DECL_OVERRIDE; virtual void listDir(const QUrl &url) Q_DECL_OVERRIDE; virtual void del(QUrl const & url, bool isFile) Q_DECL_OVERRIDE; virtual void copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags) Q_DECL_OVERRIDE; virtual void rename(const QUrl &src, const QUrl & dest, KIO::JobFlags flags) Q_DECL_OVERRIDE; public slots: void receivedData(KProcess *, QByteArray &); void checkOutputForPassword(KProcess *, QByteArray &); protected: virtual bool initDirDict(const QUrl &url, bool forced = false); virtual bool initArcParameters(); void checkIf7zIsEncrypted(bool &, QString); virtual void parseLine(int lineNo, QString line); virtual bool setArcFile(const QUrl &url); virtual QString getPassword(); virtual void invalidatePassword(); QString getPath(const QUrl &url, QUrl::FormattingOptions options = 0); QString localeEncodedString(QString str); QByteArray encodeString(QString); QString decodeString(char *); // archive specific commands QString cmd; ///< the archiver name. QStringList listCmd; ///< list files. QStringList getCmd; ///< unpack files command. QStringList delCmd; ///< delete files command. QStringList putCmd; ///< add file command. QStringList copyCmd; ///< copy to file command. QStringList renCmd; ///< rename file command. private: void get(const QUrl &url, int tries); /** checks if a returned status ("exit code") of an archiving-related process is OK. */ bool checkStatus(int exitCode); /** service function for parseLine. */ QString nextWord(QString &s, char d = ' '); /** translate permittion string to mode_t. */ mode_t parsePermString(QString perm); /** return the name of the directory inside the archive. */ QString findArcDirectory(const QUrl &url); /** find the UDSEntry of a file in a directory. */ KIO::UDSEntry* findFileEntry(const QUrl &url); /** add a new directory (file list container). */ KIO::UDSEntryList* addNewDir(QString path); QString fullPathName(QString name); static QString detectFullPathName(QString name); bool checkWriteSupport(); QHash dirDict; //< the directoris data structure. bool encrypted; //< tells whether the archive is encrypted bool archiveChanged; //< true if the archive was changed. bool archiveChanging; //< true if the archive is currently changing. bool newArchiveURL; //< true if new archive was entered for the protocol bool noencoding; //< 7z files use UTF-16, so encoding is unnecessary KIO::filesize_t decompressedLen; //< the number of the decompressed bytes KFileItem* arcFile; //< the archive file item. QString arcPath; //< the archive location QString arcTempDir; //< the currently used temp directory. QString arcType; //< the archive type. bool extArcReady; //< Used for RPM & DEB files. QString password; //< Password for the archives KConfig krConf; //< The configuration file for krusader KConfigGroup confGrp; //< the 'Dependencies' config group QString lastData; QString encryptedArchPath; QString currentCharset; QTextCodec * codec; }; #ifdef Q_WS_WIN #define DIR_SEPARATOR "/" #define DIR_SEPARATOR2 "\\" #define DIR_SEPARATOR_CHAR '/' #define DIR_SEPARATOR_CHAR2 '\\' #define REPLACE_DIR_SEP2(x) x = x.replace( DIR_SEPARATOR2, DIR_SEPARATOR ); #define ROOT_DIR "C:\\" #define EXEC_SUFFIX ".exe" #else #define DIR_SEPARATOR "/" #define DIR_SEPARATOR2 "/" #define DIR_SEPARATOR_CHAR '/' #define DIR_SEPARATOR_CHAR2 '/' #define REPLACE_DIR_SEP2(x) #define ROOT_DIR "/" #define EXEC_SUFFIX "" #endif #endif diff --git a/krusader/CMakeLists.txt b/krusader/CMakeLists.txt index f5365859..f5755695 100644 --- a/krusader/CMakeLists.txt +++ b/krusader/CMakeLists.txt @@ -1,131 +1,133 @@ include_directories(${KF5_INCLUDES_DIRS} ${QT_INCLUDES}) configure_file(krusaderversion.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/krusaderversion.h) add_subdirectory(ActionMan) add_subdirectory(Archive) add_subdirectory(BookMan) add_subdirectory(Dialogs) add_subdirectory(DiskUsage) add_subdirectory(Filter) add_subdirectory(GUI) add_subdirectory(Konfigurator) add_subdirectory(KViewer) add_subdirectory(JobMan) add_subdirectory(Locate) add_subdirectory(MountMan) add_subdirectory(Panel) add_subdirectory(Search) add_subdirectory(Splitter) add_subdirectory(UserAction) add_subdirectory(UserMenu) add_subdirectory(VFS) if(SYNCHRONIZER_ENABLED) add_subdirectory(Synchronizer) endif(SYNCHRONIZER_ENABLED) message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}: skipped subdir $(KRJSDIR)") set(krusader_SRCS krglobal.cpp actionsbase.cpp tabactions.cpp kractions.cpp paneltabbar.cpp panelmanager.cpp krservices.cpp main.cpp krusaderview.cpp krusader.cpp krslots.cpp kicons.cpp - krtrashhandler.cpp) + krtrashhandler.cpp + krdebuglogger.cpp +) # TODO porting: missing kf5 equivalent #kde4_add_app_icon(krusader_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/hi*-app-krusader_user.png") qt5_add_resources(krusader_RC_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/resources.qrc" ) add_executable(krusader ${krusader_SRCS} ${krusader_RC_SRCS}) target_link_libraries(krusader Panel BookMan Dialogs DiskUsage GUI Konfigurator KViewer MountMan VFS Search Splitter UserMenu Locate UserAction ActionMan KViewer Filter Dialogs GUI Archive JobMan KF5::Notifications KF5::Parts KF5::WindowSystem Qt5::PrintSupport ) if(SYNCHRONIZER_ENABLED) target_link_libraries( krusader Synchronizer ) endif(SYNCHRONIZER_ENABLED) install(TARGETS krusader ${INSTALL_TARGETS_DEFAULT_ARGS}) install(PROGRAMS org.kde.krusader.desktop org.kde.krusader.root-mode.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) install(FILES krusaderui.rc krusaderlisterui.rc krviewer.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/krusader) install(FILES midnight_commander.color total_commander.color total_commander.keymap total_commander.keymap.info useraction_examples.xml layout.xml splash.png DESTINATION ${DATA_INSTALL_DIR}/krusader) install(FILES org.kde.krusader.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) ecm_install_icons(ICONS icons/16-apps-krusader_blue.png icons/16-apps-krusader_red.png icons/16-apps-krusader_root.png icons/16-apps-krusader_user.png icons/22-apps-krusader_blue.png icons/22-apps-krusader_red.png icons/22-apps-krusader_root.png icons/22-apps-krusader_shield.png icons/22-apps-krusader_user.png icons/32-apps-krusader_blue.png icons/32-apps-krusader_red.png icons/32-apps-krusader_root.png icons/32-apps-krusader_shield.png icons/32-apps-krusader_user.png icons/48-apps-krusader_blue.png icons/48-apps-krusader_red.png icons/48-apps-krusader_root.png icons/48-apps-krusader_shield.png icons/48-apps-krusader_user.png icons/64-apps-krusader_blue.png icons/64-apps-krusader_red.png icons/64-apps-krusader_root.png icons/64-apps-krusader_shield.png icons/64-apps-krusader_user.png icons/128-apps-krusader_root.png icons/128-apps-krusader_user.png DESTINATION ${ICON_INSTALL_DIR} ) diff --git a/krArc/krdebuglogger.cpp b/krusader/krdebuglogger.cpp similarity index 100% rename from krArc/krdebuglogger.cpp rename to krusader/krdebuglogger.cpp diff --git a/krArc/krdebuglogger.h b/krusader/krdebuglogger.h similarity index 93% rename from krArc/krdebuglogger.h rename to krusader/krdebuglogger.h index 5d92c99e..072f3bab 100644 --- a/krArc/krdebuglogger.h +++ b/krusader/krdebuglogger.h @@ -1,62 +1,62 @@ /*************************************************************************** krdebuglogger.h ------------------ copyright : (C) 2016 by Rafi Yanai & Shie Erlich email : krusader@users.sf.net web site : http://krusader.sourceforge.net ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef KRDEBUGLOGGER_H #define KRDEBUGLOGGER_H // QtCore #include #include #include #include -//! A class to manage some aspects of the writing of messages into the krarc debug log file +//! A class to manage some aspects of the writing of messages into the Krusader debug log file class KrDebugLogger { private: QString function; //! The name of a function which is going to be written about static int indentation; //! The indentation that is presently used, it represents how many spaces are going to be used const static int indentationIncrease; //! The quantity of spaces that are going be added to the indentation when increasing it static const QString logFile; //! The name of the log file public: KrDebugLogger(const QString &, int); ~KrDebugLogger(); static void prepareWriting(QFile &, QTextStream &); }; #ifdef QT_DEBUG -//! Writes a function name in the krarc debug log, etc. when entering the function and automatically before exiting from it +//! Writes a function name, etc. in the Krusader debug log when entering the function and automatically before exiting from it #define KRFUNC \ KrDebugLogger functionLogger(__FUNCTION__, __LINE__); #define KRDEBUG(X...) do{ \ QFile file; \ QTextStream stream; \ KrDebugLogger::prepareWriting(file, stream); \ stream << __FUNCTION__ << "(" <<__LINE__<< "): "; \ stream << X << endl; \ } while(0); #else #define KRFUNC #define KRDEBUG(X...) qDebug() << X #endif #endif // KRDEBUGLOGGER_H