void ExtScript::readConfiguration()
{
    AbstractExtItem::readConfiguration();

    for (int i = directories().count() - 1; i >= 0; i--) {
        if (!QDir(directories().at(i))
                 .entryList(QDir::Files)
                 .contains(fileName()))
            continue;
        QSettings settings(
            QString("%1/%2").arg(directories().at(i)).arg(fileName()),
            QSettings::IniFormat);

        settings.beginGroup(QString("Desktop Entry"));
        setExecutable(settings.value(QString("Exec"), m_executable).toString());
        setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString());
        setStrRedirect(
            settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
        // api == 3
        setFilters(settings.value(QString("X-AW-Filters"), m_filters)
                       .toString()
                       .split(QChar(','), QString::SkipEmptyParts));
        settings.endGroup();
    }

    // update for current API
    if ((apiVersion() > 0) && (apiVersion() < AWESAPI)) {
        qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to"
                           << AWESAPI;
        setApiVersion(AWESAPI);
        writeConfiguration();
    }
}
void AbstractExtItem::bumpApi(const int _newVer)
{
    qCDebug(LOG_LIB) << "Bump API using new version" << _newVer;

    // update for current API
    if ((apiVersion() > 0) && (apiVersion() < _newVer)) {
        qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to"
                           << _newVer;
        setApiVersion(_newVer);
        writeConfiguration();
    }
}
/*!
 * Returns \c true if this request is equal to \a other; \c false otherwise.
 *
 * Note, most derived *Request classes do not need to provider their own
 * implementations of this function, since most such request classes rely on
 * this class' parameters functionality for all request parameters, and that
 * parameters map is already checked via this implementation.
 */
bool CloudFrontRequest::operator==(const CloudFrontRequest &other) const
{
    return ((action() == other.action()) &&
            (apiVersion() == other.apiVersion()) &&
            (parameters() == other.parameters()) &&
            (QtAws::Core::AwsAbstractRequest::operator ==(other)));
}
/*!
 * Returns \c true if this request is equal to \a other; \c false otherwise.
 *
 * Note, most derived *Request classes do not need to provider their own
 * implementations of this function, since most such request classes rely on
 * this class' parameters functionality for all request parameters, and that
 * parameters map is already checked via this implementation.
 */
bool CognitoIdentityProviderRequest::operator==(const CognitoIdentityProviderRequest &other) const
{
    return ((action() == other.action()) &&
            (apiVersion() == other.apiVersion()) &&
            (parameters() == other.parameters()) &&
            (QtAws::Core::AwsAbstractRequest::operator ==(other)));
}
/*!
 * Returns \c true if this request is equal to \a other; \c false otherwise.
 *
 * Note, most derived *Request classes do not need to provider their own
 * implementations of this function, since most such request classes rely on
 * this class' parameters functionality for all request parameters, and that
 * parameters map is already checked via this implementation.
 */
bool ApiGatewayV2Request::operator==(const ApiGatewayV2Request &other) const
{
    return ((action() == other.action()) &&
            (apiVersion() == other.apiVersion()) &&
            (parameters() == other.parameters()) &&
            (QtAws::Core::AwsAbstractRequest::operator ==(other)));
}
void AbstractExtItem::copyDefaults(AbstractExtItem *_other) const
{
    _other->setActive(isActive());
    _other->setApiVersion(apiVersion());
    _other->setComment(comment());
    _other->setCron(cron());
    _other->setInterval(interval());
    _other->setName(name());
    _other->setSocket(socket());
}
void AbstractExtItem::readConfiguration()
{
    QSettings settings(m_fileName, QSettings::IniFormat);

    settings.beginGroup("Desktop Entry");
    setName(settings.value("Name", name()).toString());
    setComment(settings.value("Comment", comment()).toString());
    setApiVersion(settings.value("X-AW-ApiVersion", apiVersion()).toInt());
    setActive(settings.value("X-AW-Active", isActive()).toBool());
    setInterval(settings.value("X-AW-Interval", interval()).toInt());
    setNumber(settings.value("X-AW-Number", number()).toInt());
    setCron(settings.value("X-AW-Schedule", cron()).toString());
    setSocket(settings.value("X-AW-Socket", socket()).toString());
    settings.endGroup();
}
ExtScript *ExtScript::copy(const QString _fileName, const int _number)
{
    qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number;

    ExtScript *item = new ExtScript(static_cast<QWidget *>(parent()), _fileName,
                                    directories());
    item->setActive(isActive());
    item->setApiVersion(apiVersion());
    item->setComment(comment());
    item->setExecutable(executable());
    item->setInterval(interval());
    item->setName(name());
    item->setNumber(_number);
    item->setPrefix(prefix());
    item->setRedirect(redirect());

    return item;
}
void AbstractExtItem::writeConfiguration() const
{
    QSettings settings(writtableConfig(), QSettings::IniFormat);
    qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();

    settings.beginGroup("Desktop Entry");
    settings.setValue("Encoding", "UTF-8");
    settings.setValue("Name", name());
    settings.setValue("Comment", comment());
    settings.setValue("X-AW-ApiVersion", apiVersion());
    settings.setValue("X-AW-Active", isActive());
    settings.setValue("X-AW-Interval", interval());
    settings.setValue("X-AW-Number", number());
    settings.setValue("X-AW-Schedule", cron());
    settings.setValue("X-AW-Socket", socket());
    settings.endGroup();

    settings.sync();
}