mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kdecore: set error string when the type is invalid or unsupported from KCompressor::setType() and KDecompressor::setType()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
7ede848fe8
commit
1a23738c6d
2 changed files with 30 additions and 2 deletions
|
@ -71,9 +71,23 @@ KCompressor::KCompressorType KCompressor::type() const
|
|||
|
||||
bool KCompressor::setType(const KCompressorType type)
|
||||
{
|
||||
d->m_errorstring.clear();
|
||||
if (type == KCompressor::TypeUnknown) {
|
||||
d->m_errorstring = i18n("Invalid type: %1", int(type));
|
||||
return false;
|
||||
}
|
||||
#if !defined(HAVE_BZIP2_SUPPORT)
|
||||
if (type == KCompressor::TypeBZip2) {
|
||||
d->m_errorstring = i18n("Unsupported type: %1", int(type));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#if !defined(HAVE_XZ_SUPPORT)
|
||||
if (type == KCompressor::TypeXZ) {
|
||||
d->m_errorstring = i18n("Unsupported type: %1", int(type));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
d->m_type = type;
|
||||
return true;
|
||||
}
|
||||
|
@ -254,7 +268,7 @@ bool KCompressor::process(const QByteArray &data)
|
|||
}
|
||||
#endif // HAVE_XZ_SUPPORT
|
||||
default: {
|
||||
kWarning() << "Unsupported type" << d->m_type;
|
||||
d->m_errorstring = i18n("Unsupported type: %1", int(d->m_type));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,9 +70,23 @@ KDecompressor::KDecompressorType KDecompressor::type() const
|
|||
|
||||
bool KDecompressor::setType(const KDecompressorType type)
|
||||
{
|
||||
d->m_errorstring.clear();
|
||||
if (type == KDecompressor::TypeUnknown) {
|
||||
d->m_errorstring = i18n("Invalid type: %1", int(type));
|
||||
return false;
|
||||
}
|
||||
#if !defined(HAVE_BZIP2_SUPPORT)
|
||||
if (type == KCompressor::TypeBZip2) {
|
||||
d->m_errorstring = i18n("Unsupported type: %1", int(type));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#if !defined(HAVE_XZ_SUPPORT)
|
||||
if (type == KCompressor::TypeXZ) {
|
||||
d->m_errorstring = i18n("Unsupported type: %1", int(type));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
d->m_type = type;
|
||||
return true;
|
||||
}
|
||||
|
@ -280,7 +294,7 @@ bool KDecompressor::process(const QByteArray &data)
|
|||
}
|
||||
#endif // HAVE_XZ_SUPPORT
|
||||
default: {
|
||||
kWarning() << "Unsupported type" << d->m_type;
|
||||
d->m_errorstring = i18n("Unsupported type: %1", int(d->m_type));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue