Make archiver ioslave extensible
ClosedPublic

Authored by marten on Mar 20 2017, 1:31 PM.

Details

Summary

The tar, zip and ar ioslaves are implemented in kio-extras/archive by a single plugin (class ArchiveProtocol). This uses the URL scheme to determine which archive decoder to use - KTar, KZip or KAr all from the KArchive (tier 1) framework. Unfortunately, it is not possible to use this ioslave as a base for another archive format plugin to be distributed and built outside of the KDE source tree, because the supported protocols and their decoders are hardcoded in the depths of ArchiveProtocol::checkNewFile(). This means that a new ioslave for another archive format would need to copy and adapt the whole of the ArchiveProtocol source.

This change makes it possible to do that by moving most of ArchiveProtocol into an abstract base class ArchiveProtocolBase, compiled into an library and installed along with its supporting files. This is not a framework library (and is not ever intended to be), but a support library similar to libkonq. It calls a virtual function in a derived class to create the KArchive-based decoder depending on the URL scheme. The ioslave plugin for the existing archive formats is a single derived class (although it could just as easily be three) which is installed in the same way as before.

With this change, it is then possible to build and install an additional out-of-tree ioslave plugin, deriving from ArchiveProtocolBase and using its installed headers and library, without needing any further changes to kio-extras.

The additional files installed are:

lib/cmake/KF5KioArchive/KF5KioArchiveConfig.cmake
lib/cmake/KF5KioArchive/KF5KioArchiveConfigVersion.cmake
lib/cmake/KF5KioArchive/KF5KioArchiveTargets.cmake
lib/cmake/KF5KioArchive/KF5KioArchiveTargets-debug.cmake
include/KF5/kio_archivebase.h
include/KF5/libkioarchive_export.h
lib/libKF5KioArchive.so.5.97.0
lib/libKF5KioArchive.so.6 -> libKF5KioArchive.so.5.97.0
lib/libKF5KioArchive.so -> libKF5KioArchive.so.6

The .so versions are set as for libkonq, although they can easily be changed if required.

Test Plan

Built kio-extras with this change, all autotests pass.
Konqueror operates correctly to browse tar and zip archives.
External archive format plugin builds and works correctly.

Diff Detail

Repository
R320 KIO Extras
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
marten created this revision.Mar 20 2017, 1:31 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMar 20 2017, 1:31 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
dfaure edited edge metadata.Mar 27 2017, 7:40 PM

The idea sounds OK to me.

archive/CMakeLists.txt
32

The KF5 prefix is wrong, this isn't part of KF5.

44

The KF5 prefix is wrong, this isn't part of KF5.

Point taken regarding the KF5 prefix, this was based on the installed names for libkonq (= libKF5Konq.so etc) although not every application support library is named the same way (libkworkspace5.so isn't).

Would the name libKioArchive.so, etc be appropriate, or should it be all lower case (libkioarchive.so)?

Yeah KF5Konq is a bug, it shouldn't be named that way.

I don't really care about casing, the cmake code will refer to the imported target (which shouldn't have a KF5:: prefix either), not to the library name anyway.

marten updated this revision to Diff 12896.Mar 28 2017, 8:22 AM

Remove KF5 prefixes, the library is now libkioarchive.so

dfaure accepted this revision.Mar 29 2017, 6:56 AM

Looks OK. It would be good to port this away from kdelibs4support though, to avoid propagating that dependency on users of the lib -- making it impossible to remove later.
At least it should be removed as a public dependency (in the target_link_libraries line and from KioArchiveConfig.cmake.in).

This revision is now accepted and ready to land.Mar 29 2017, 6:56 AM

I'd done some porting away from kdelibs4 in this change, in particular KMimeType -> QMime* but realized that it was getting a bit involved and would be mixing up two unrelated changes (involving about 30 files for the whole of kio-extras) . So I'll submit a separate change for the remainder of the porting.

This revision was automatically updated to reflect the committed changes.