Commit d2698814 authored by Ragnar Thomsen's avatar Ragnar Thomsen
Browse files

Harmonize the CliPlugins

Use Q_DECL_OVERRIDE and same names in ParseState enum.
parent ee7e9305
......@@ -40,7 +40,7 @@ K_PLUGIN_FACTORY( CliPluginFactory, registerPlugin< CliPlugin >(); )
CliPlugin::CliPlugin(QObject *parent, const QVariantList & args)
: CliInterface(parent, args)
, m_archiveType(ArchiveType7z)
, m_state(ReadStateHeader)
, m_parseState(ParseStateHeader)
{
qCDebug(KERFUFFLE_PLUGIN) << "Loaded cli_7z plugin";
}
......@@ -51,7 +51,7 @@ CliPlugin::~CliPlugin()
void CliPlugin::resetParsing()
{
m_state = ReadStateHeader;
m_parseState = ParseStateHeader;
}
ParameterList CliPlugin::parameterList() const
......@@ -105,22 +105,22 @@ bool CliPlugin::readListLine(const QString& line)
static const QLatin1String archiveInfoDelimiter2("----"); // 7z 9.04
static const QLatin1String entryInfoDelimiter("----------");
switch (m_state) {
case ReadStateHeader:
switch (m_parseState) {
case ParseStateHeader:
if (line.startsWith(QStringLiteral("Listing archive:"))) {
qCDebug(KERFUFFLE_PLUGIN) << "Archive name: "
<< line.right(line.size() - 16).trimmed();
} else if ((line == archiveInfoDelimiter1) ||
(line == archiveInfoDelimiter2)) {
m_state = ReadStateArchiveInformation;
m_parseState = ParseStateArchiveInformation;
} else if (line.contains(QStringLiteral("Error: "))) {
qCWarning(KERFUFFLE_PLUGIN) << line.mid(7);
}
break;
case ReadStateArchiveInformation:
case ParseStateArchiveInformation:
if (line == entryInfoDelimiter) {
m_state = ReadStateEntryInformation;
m_parseState = ParseStateEntryInformation;
} else if (line.startsWith(QStringLiteral("Type = "))) {
const QString type = line.mid(7).trimmed();
qCDebug(KERFUFFLE_PLUGIN) << "Archive type: " << type;
......@@ -144,7 +144,7 @@ bool CliPlugin::readListLine(const QString& line)
break;
case ReadStateEntryInformation:
case ParseStateEntryInformation:
if (line.startsWith(QStringLiteral("Path = "))) {
const QString entryFilename =
QDir::fromNativeSeparators(line.mid(7).trimmed());
......
......@@ -34,29 +34,26 @@ public:
explicit CliPlugin(QObject *parent, const QVariantList & args);
virtual ~CliPlugin();
protected:
virtual void resetParsing();
virtual Kerfuffle::ParameterList parameterList() const;
virtual bool readListLine(const QString &line);
virtual void resetParsing() Q_DECL_OVERRIDE;
virtual Kerfuffle::ParameterList parameterList() const Q_DECL_OVERRIDE;
virtual bool readListLine(const QString &line) Q_DECL_OVERRIDE;
private:
enum ArchiveType {
ArchiveType7z = 0,
ArchiveTypeBZip2,
ArchiveTypeGZip,
ArchiveTypeTar,
ArchiveTypeZip
};
enum ReadState {
ReadStateHeader = 0,
ReadStateArchiveInformation,
ReadStateEntryInformation
};
ArchiveType m_archiveType;
ArchiveType7z = 0,
ArchiveTypeBZip2,
ArchiveTypeGZip,
ArchiveTypeTar,
ArchiveTypeZip
} m_archiveType;
enum ParseState {
ParseStateHeader = 0,
ParseStateArchiveInformation,
ParseStateEntryInformation
} m_parseState;
Kerfuffle::ArchiveEntry m_currentArchiveEntry;
ReadState m_state;
};
#endif // CLIPLUGIN_H
......@@ -36,7 +36,7 @@ K_PLUGIN_FACTORY( CliPluginFactory, registerPlugin< CliPlugin >(); )
CliPlugin::CliPlugin(QObject *parent, const QVariantList &args)
: CliInterface(parent, args),
m_status(Header),
m_parseState(ParseStateHeader),
m_firstLine(true)
{
qCDebug(KERFUFFLE_PLUGIN) << "Loaded cli_7z plugin";
......@@ -48,7 +48,7 @@ CliPlugin::~CliPlugin()
void CliPlugin::resetParsing()
{
m_status = Header;
m_parseState = ParseStateHeader;
}
ParameterList CliPlugin::parameterList() const
......@@ -85,19 +85,19 @@ bool CliPlugin::readListLine(const QString &line)
{
const QString m_headerString = QLatin1String("----------");
switch(m_status) {
case Header:
switch(m_parseState) {
case ParseStateHeader:
if (line.startsWith(m_headerString)) {
m_status = Entry;
m_parseState = ParseStateEntry;
m_firstLine = true;
}
break;
case Entry:
case ParseStateEntry:
const QStringList entryList = line.split(QLatin1Char(' '), QString::SkipEmptyParts);
if (m_firstLine) { // This line will contain the filename
if (entryList.count() == 8) { // End of entries
m_status = Header;
m_parseState = ParseStateHeader;
}
else {
m_internalId = line;
......
......@@ -31,15 +31,15 @@ public:
explicit CliPlugin(QObject *parent, const QVariantList &args);
virtual ~CliPlugin();
virtual void resetParsing();
virtual Kerfuffle::ParameterList parameterList() const;
virtual bool readListLine(const QString &line);
virtual void resetParsing() Q_DECL_OVERRIDE;
virtual Kerfuffle::ParameterList parameterList() const Q_DECL_OVERRIDE;
virtual bool readListLine(const QString &line) Q_DECL_OVERRIDE;
private:
enum {
Header = 0,
Entry
} m_status;
enum ParseState {
ParseStateHeader = 0,
ParseStateEntry
} m_parseState;
QString m_entryFilename;
QString m_internalId;
......
......@@ -33,10 +33,10 @@ public:
explicit CliPlugin(QObject *parent, const QVariantList &args);
virtual ~CliPlugin();
virtual void resetParsing();
virtual QString escapeFileName(const QString &fileName) const;
virtual Kerfuffle::ParameterList parameterList() const;
virtual bool readListLine(const QString &line);
virtual void resetParsing() Q_DECL_OVERRIDE;
virtual QString escapeFileName(const QString &fileName) const Q_DECL_OVERRIDE;
virtual Kerfuffle::ParameterList parameterList() const Q_DECL_OVERRIDE;
virtual bool readListLine(const QString &line) Q_DECL_OVERRIDE;
private:
......
......@@ -38,7 +38,7 @@ K_PLUGIN_FACTORY( CliPluginFactory, registerPlugin< CliPlugin >(); )
CliPlugin::CliPlugin(QObject *parent, const QVariantList & args)
: CliInterface(parent, args)
, m_status(Header)
, m_parseState(ParseStateHeader)
{
qCDebug(KERFUFFLE_PLUGIN) << "Loaded cli_zip plugin";
}
......@@ -49,7 +49,7 @@ CliPlugin::~CliPlugin()
void CliPlugin::resetParsing()
{
m_status = Header;
m_parseState = ParseStateHeader;
}
// #208091: infozip applies special meanings to some characters, so we
......@@ -124,11 +124,11 @@ bool CliPlugin::readListLine(const QString &line)
static const QRegularExpression entryPattern(QStringLiteral(
"^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\d{8}).(\\d{6})\\s+(.+)$") );
switch (m_status) {
case Header:
m_status = Entry;
switch (m_parseState) {
case ParseStateHeader:
m_parseState = ParseStateEntry;
break;
case Entry:
case ParseStateEntry:
QRegularExpressionMatch rxMatch = entryPattern.match(line);
if (rxMatch.hasMatch()) {
ArchiveEntry e;
......
......@@ -31,16 +31,16 @@ public:
explicit CliPlugin(QObject *parent, const QVariantList &args);
virtual ~CliPlugin();
virtual void resetParsing();
virtual void resetParsing() Q_DECL_OVERRIDE;
virtual QString escapeFileName(const QString &fileName) const Q_DECL_OVERRIDE;
virtual Kerfuffle::ParameterList parameterList() const Q_DECL_OVERRIDE;
virtual bool readListLine(const QString &line) Q_DECL_OVERRIDE;
private:
enum {
Header = 0,
Entry
} m_status;
enum ParseState {
ParseStateHeader = 0,
ParseStateEntry
} m_parseState;
};
#endif // CLIPLUGIN_H
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