Also add title argument to Error elsewhere
This commit is contained in:
parent
a5b021cffd
commit
b9b82d783f
@ -429,7 +429,7 @@ void AudioManager::mediaStatusChanged()
|
||||
next();
|
||||
if (badEntry && badEntry->enclosure()) {
|
||||
badEntry->enclosure()->deleteFile();
|
||||
Q_EMIT logError(Error::Type::InvalidMedia, badEntry->feed()->url(), badEntry->id(), QMediaPlayer::InvalidMedia, i18n("Invalid Media"));
|
||||
Q_EMIT logError(Error::Type::InvalidMedia, badEntry->feed()->url(), badEntry->id(), QMediaPlayer::InvalidMedia, i18n("Invalid Media"), QString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ Q_SIGNALS:
|
||||
|
||||
void canGoNextChanged();
|
||||
|
||||
void logError(Error::Type type, const QString &url, const QString &id, const int errorId, const QString &errorString);
|
||||
void logError(Error::Type type, const QString &url, const QString &id, const int errorId, const QString &errorString, const QString &title);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
|
@ -45,6 +45,8 @@ bool Database::migrate()
|
||||
TRUE_OR_RETURN(migrateTo2());
|
||||
if (dbversion < 3)
|
||||
TRUE_OR_RETURN(migrateTo3());
|
||||
if (dbversion < 4)
|
||||
TRUE_OR_RETURN(migrateTo4());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -96,6 +98,18 @@ bool Database::migrateTo3()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Database::migrateTo4()
|
||||
{
|
||||
qDebug() << "Migrating database to version 4";
|
||||
TRUE_OR_RETURN(execute(QStringLiteral("BEGIN TRANSACTION;")));
|
||||
TRUE_OR_RETURN(execute(QStringLiteral("DROP TABLE Errors;")));
|
||||
TRUE_OR_RETURN(
|
||||
execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Errors (type INTEGER, url TEXT, id TEXT, code INTEGER, message TEXT, date INTEGER, title TEXT);")));
|
||||
TRUE_OR_RETURN(execute(QStringLiteral("PRAGMA user_version = 4;")));
|
||||
TRUE_OR_RETURN(execute(QStringLiteral("COMMIT;")));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Database::execute(const QString &query)
|
||||
{
|
||||
QSqlQuery q;
|
||||
|
@ -30,5 +30,6 @@ private:
|
||||
bool migrateTo1();
|
||||
bool migrateTo2();
|
||||
bool migrateTo3();
|
||||
bool migrateTo4();
|
||||
void cleanup();
|
||||
};
|
||||
|
@ -91,7 +91,8 @@ void Enclosure::download()
|
||||
m_entry->feed()->url(),
|
||||
m_entry->id(),
|
||||
0,
|
||||
i18n("Podcast downloads not allowed due to user setting"));
|
||||
i18n("Podcast downloads not allowed due to user setting"),
|
||||
QString());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -120,7 +121,12 @@ void Enclosure::download()
|
||||
if (downloadJob->error() != QNetworkReply::OperationCanceledError) {
|
||||
m_entry->feed()->setErrorId(downloadJob->error());
|
||||
m_entry->feed()->setErrorString(downloadJob->errorString());
|
||||
Q_EMIT downloadError(Error::Type::MediaDownload, m_entry->feed()->url(), m_entry->id(), downloadJob->error(), downloadJob->errorString());
|
||||
Q_EMIT downloadError(Error::Type::MediaDownload,
|
||||
m_entry->feed()->url(),
|
||||
m_entry->id(),
|
||||
downloadJob->error(),
|
||||
downloadJob->errorString(),
|
||||
QString());
|
||||
}
|
||||
}
|
||||
disconnect(this, &Enclosure::cancelDownload, this, nullptr);
|
||||
|
@ -81,7 +81,7 @@ Q_SIGNALS:
|
||||
void durationChanged();
|
||||
void sizeChanged();
|
||||
void sizeOnDiskChanged();
|
||||
void downloadError(const Error::Type type, const QString &url, const QString &id, const int errorId, const QString &errorString);
|
||||
void downloadError(const Error::Type type, const QString &url, const QString &id, const int errorId, const QString &errorString, const QString &title);
|
||||
|
||||
private:
|
||||
void processDownloadedFile();
|
||||
|
@ -27,7 +27,8 @@ ErrorLogModel::ErrorLogModel()
|
||||
|
||||
query.value(QStringLiteral("code")).toInt(),
|
||||
query.value(QStringLiteral("message")).toString(),
|
||||
QDateTime::fromSecsSinceEpoch(query.value(QStringLiteral("date")).toInt()));
|
||||
QDateTime::fromSecsSinceEpoch(query.value(QStringLiteral("date")).toInt()),
|
||||
query.value(QStringLiteral("title")).toString());
|
||||
m_errors += error;
|
||||
}
|
||||
}
|
||||
@ -53,25 +54,30 @@ int ErrorLogModel::rowCount(const QModelIndex &parent) const
|
||||
return m_errors.count();
|
||||
}
|
||||
|
||||
void ErrorLogModel::monitorErrorMessages(const Error::Type type, const QString &url, const QString &id, const int errorCode, const QString &errorString)
|
||||
void ErrorLogModel::monitorErrorMessages(const Error::Type type,
|
||||
const QString &url,
|
||||
const QString &id,
|
||||
const int errorCode,
|
||||
const QString &errorString,
|
||||
const QString &title)
|
||||
{
|
||||
qDebug() << "Error happened:" << type << url << id << errorCode << errorString;
|
||||
QString title;
|
||||
|
||||
Error *error = new Error(type, url, id, errorCode, errorString, QDateTime::currentDateTime());
|
||||
Error *error = new Error(type, url, id, errorCode, errorString, QDateTime::currentDateTime(), title);
|
||||
beginInsertRows(QModelIndex(), 0, 0);
|
||||
m_errors.prepend(error);
|
||||
endInsertRows();
|
||||
|
||||
// Also add error to database
|
||||
QSqlQuery query;
|
||||
query.prepare(QStringLiteral("INSERT INTO Errors VALUES (:type, :url, :id, :code, :message, :date);"));
|
||||
query.bindValue(QStringLiteral(":type"), Error::typeToDb(error->type));
|
||||
query.bindValue(QStringLiteral(":url"), error->url);
|
||||
query.bindValue(QStringLiteral(":id"), error->id);
|
||||
query.bindValue(QStringLiteral(":code"), error->code);
|
||||
query.bindValue(QStringLiteral(":message"), error->message);
|
||||
query.prepare(QStringLiteral("INSERT INTO Errors VALUES (:type, :url, :id, :code, :message, :date, :title);"));
|
||||
query.bindValue(QStringLiteral(":type"), Error::typeToDb(type));
|
||||
query.bindValue(QStringLiteral(":url"), url);
|
||||
query.bindValue(QStringLiteral(":id"), id);
|
||||
query.bindValue(QStringLiteral(":code"), errorCode);
|
||||
query.bindValue(QStringLiteral(":message"), errorString);
|
||||
query.bindValue(QStringLiteral(":date"), error->date.toSecsSinceEpoch());
|
||||
query.bindValue(QStringLiteral(":title"), title);
|
||||
Database::instance().execute(query);
|
||||
|
||||
// Send signal to display inline error message
|
||||
|
@ -32,7 +32,8 @@ public:
|
||||
Q_INVOKABLE void clearAll();
|
||||
|
||||
public:
|
||||
void monitorErrorMessages(const Error::Type type, const QString &url, const QString &id, const int errorCode, const QString &errorString);
|
||||
void
|
||||
monitorErrorMessages(const Error::Type type, const QString &url, const QString &id, const int errorCode, const QString &errorString, const QString &title);
|
||||
|
||||
Q_SIGNALS:
|
||||
void newErrorLogged(Error *error);
|
||||
|
@ -90,7 +90,7 @@ void Fetcher::fetchAll()
|
||||
void Fetcher::retrieveFeed(const QString &url)
|
||||
{
|
||||
if (isMeteredConnection() && !SettingsManager::self()->allowMeteredFeedUpdates()) {
|
||||
Q_EMIT error(Error::Type::MeteredNotAllowed, url, QString(), 0, i18n("Podcast updates not allowed due to user setting"));
|
||||
Q_EMIT error(Error::Type::MeteredNotAllowed, url, QString(), 0, i18n("Podcast updates not allowed due to user setting"), QString());
|
||||
m_updateProgress++;
|
||||
Q_EMIT updateProgressChanged(m_updateProgress);
|
||||
return;
|
||||
@ -107,7 +107,7 @@ void Fetcher::retrieveFeed(const QString &url)
|
||||
if (reply->error()) {
|
||||
qWarning() << "Error fetching feed";
|
||||
qWarning() << reply->errorString();
|
||||
Q_EMIT error(Error::Type::FeedUpdate, url, QString(), reply->error(), reply->errorString());
|
||||
Q_EMIT error(Error::Type::FeedUpdate, url, QString(), reply->error(), reply->errorString(), QString());
|
||||
} else {
|
||||
QByteArray data = reply->readAll();
|
||||
Syndication::DocumentSource *document = new Syndication::DocumentSource(data, url);
|
||||
|
@ -61,7 +61,7 @@ Q_SIGNALS:
|
||||
const QString &description,
|
||||
const QDateTime &lastUpdated);
|
||||
void feedUpdateFinished(const QString &url);
|
||||
void error(Error::Type type, const QString &url, const QString &id, const int errorId, const QString &errorString);
|
||||
void error(Error::Type type, const QString &url, const QString &id, const int errorId, const QString &errorString, const QString &title);
|
||||
void entryAdded(const QString &feedurl, const QString &id);
|
||||
void downloadFinished(QString url) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user