Since last monday, the class KFilePlugin
has been
removed and all the KFilePlugin
implementations have to be
ported. As an example of how to port a KFilePlugin
, I will
rewrite KDviPlugin
(h,
cpp)as
a Strigi analyzer.
On first inspection, we see that KDviPlugin
only
implements KFilePlugin::readInfo()
and not
KFilePlugin::writeInfo()
. This makes it easier to port it;
we only need to write either a StreamThroughAnalyzer
or a
StreamEndAnalyzer
.
But which of the two? To determine this, we look again at the code.
From one of the comments in the code, we gather that the maximum amount
of data that is read by KDviPlugin
is 270 bytes. This means
we can implement a StreamThroughAnalyzer
. For any filetype
for which you read only a few kb from the start of the file, it is
better to implement a StreamThroughAnalyzer
, because these
can work in parallel. So we will implement a
DviThroughAnalyzer
.
The plugin extracts two items from DVI files: “Comment” and “Pages”. The first is a string, the last is an unsigned integer. (two other items, “Type” and “Modified”, are also extracted, but they apply to all files and can be left out).
Now we can start of on the code. We will implement a plugin, so we do not need a header file. The code is commented so that you may understand what it does.
Now you have to add an entry to CMakeLists.txt to build and install the plugin.
Comments
Post a comment