Use QDateTime::currentSecsSinceEpoch()
This commit is contained in:
parent
2604e1a0ff
commit
dde8661e93
|
@ -46,7 +46,7 @@ CollectionQuery::CollectionQuery(const QSqlDatabase &db, const QString &songs_ta
|
|||
limit_(-1) {
|
||||
|
||||
if (filter_options.max_age() != -1) {
|
||||
qint64 cutoff = QDateTime::currentDateTime().toSecsSinceEpoch() - filter_options.max_age();
|
||||
qint64 cutoff = QDateTime::currentSecsSinceEpoch() - filter_options.max_age();
|
||||
|
||||
where_clauses_ << QStringLiteral("ctime > ?");
|
||||
bound_values_ << cutoff;
|
||||
|
|
|
@ -94,7 +94,7 @@ bool OpenTidalCoverProvider::StartSearch(const QString &artist, const QString &a
|
|||
|
||||
if (artist.isEmpty() || album.isEmpty()) return false;
|
||||
|
||||
if (!have_login_ && !login_in_progress_ && QDateTime::currentDateTime().toSecsSinceEpoch() - last_login_attempt_.toSecsSinceEpoch() < 120) {
|
||||
if (!have_login_ && !login_in_progress_ && QDateTime::currentSecsSinceEpoch() - last_login_attempt_.toSecsSinceEpoch() < 120) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ void OpenTidalCoverProvider::LoadSession() {
|
|||
login_time_ = s.value("login_time", 0).toLongLong();
|
||||
s.endGroup();
|
||||
|
||||
if (!token_type_.isEmpty() && !access_token_.isEmpty() && (login_time_ + expires_in_) > (QDateTime::currentDateTime().toSecsSinceEpoch() + 30)) {
|
||||
if (!token_type_.isEmpty() && !access_token_.isEmpty() && (login_time_ + expires_in_) > (QDateTime::currentSecsSinceEpoch() + 30)) {
|
||||
have_login_ = true;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ void OpenTidalCoverProvider::LoadSession() {
|
|||
|
||||
void OpenTidalCoverProvider::FlushRequests() {
|
||||
|
||||
if (have_login_ && (login_time_ + expires_in_) < QDateTime::currentDateTime().toSecsSinceEpoch()) {
|
||||
if (have_login_ && (login_time_ + expires_in_) < QDateTime::currentSecsSinceEpoch()) {
|
||||
have_login_ = false;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ void OpenTidalCoverProvider::FlushRequests() {
|
|||
|
||||
void OpenTidalCoverProvider::LoginCheck() {
|
||||
|
||||
if (!login_in_progress_ && (!last_login_attempt_.isValid() || QDateTime::currentDateTime().toSecsSinceEpoch() - last_login_attempt_.toSecsSinceEpoch() > 120)) {
|
||||
if (!login_in_progress_ && (!last_login_attempt_.isValid() || QDateTime::currentSecsSinceEpoch() - last_login_attempt_.toSecsSinceEpoch() > 120)) {
|
||||
Login();
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ void OpenTidalCoverProvider::LoginFinished(QNetworkReply *reply) {
|
|||
have_login_ = true;
|
||||
token_type_ = json_obj[QLatin1String("token_type")].toString();
|
||||
access_token_ = json_obj[QLatin1String("access_token")].toString();
|
||||
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
login_time_ = QDateTime::currentSecsSinceEpoch();
|
||||
expires_in_ = json_obj[QLatin1String("expires_in")].toInt();
|
||||
|
||||
Settings s;
|
||||
|
|
|
@ -76,7 +76,7 @@ bool GlobalShortcutsBackendGnome::DoRegister() {
|
|||
return false;
|
||||
}
|
||||
|
||||
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentSecsSinceEpoch());
|
||||
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutsBackendGnome::RegisterFinished);
|
||||
|
|
|
@ -76,7 +76,7 @@ bool GlobalShortcutsBackendMate::DoRegister() {
|
|||
return false;
|
||||
}
|
||||
|
||||
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentSecsSinceEpoch());
|
||||
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutsBackendMate::RegisterFinished);
|
||||
|
|
|
@ -114,7 +114,7 @@ void QobuzStreamURLRequest::GetStreamURL() {
|
|||
reply_->deleteLater();
|
||||
}
|
||||
|
||||
quint64 timestamp = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
quint64 timestamp = QDateTime::currentSecsSinceEpoch();
|
||||
|
||||
ParamList params_to_sign = ParamList() << Param(QStringLiteral("format_id"), QString::number(format()))
|
||||
<< Param(QStringLiteral("track_id"), QString::number(song_id_));
|
||||
|
|
|
@ -139,7 +139,7 @@ void ListenBrainzScrobbler::LoadSession() {
|
|||
s.endGroup();
|
||||
|
||||
if (!refresh_token_.isEmpty()) {
|
||||
qint64 time = expires_in_ - (QDateTime::currentDateTime().toSecsSinceEpoch() - static_cast<qint64>(login_time_));
|
||||
qint64 time = expires_in_ - (QDateTime::currentSecsSinceEpoch() - static_cast<qint64>(login_time_));
|
||||
if (time < 6) time = 6;
|
||||
refresh_login_timer_.setInterval(static_cast<int>(time * kMsecPerSec));
|
||||
refresh_login_timer_.start();
|
||||
|
@ -331,7 +331,7 @@ void ListenBrainzScrobbler::AuthenticateReplyFinished(QNetworkReply *reply) {
|
|||
if (json_obj.contains(QLatin1String("refresh_token"))) {
|
||||
refresh_token_ = json_obj[QLatin1String("refresh_token")].toString();
|
||||
}
|
||||
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
login_time_ = QDateTime::currentSecsSinceEpoch();
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
@ -452,7 +452,7 @@ void ListenBrainzScrobbler::UpdateNowPlaying(const Song &song) {
|
|||
|
||||
song_playing_ = song;
|
||||
scrobbled_ = false;
|
||||
timestamp_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
timestamp_ = QDateTime::currentSecsSinceEpoch();
|
||||
|
||||
if (!song.is_metadata_good() || !authenticated() || settings_->offline()) return;
|
||||
|
||||
|
@ -684,7 +684,7 @@ void ListenBrainzScrobbler::Error(const QString &error, const QVariant &debug) {
|
|||
|
||||
void ListenBrainzScrobbler::CheckScrobblePrevSong() {
|
||||
|
||||
qint64 duration = QDateTime::currentDateTime().toSecsSinceEpoch() - static_cast<qint64>(timestamp_);
|
||||
qint64 duration = QDateTime::currentSecsSinceEpoch() - static_cast<qint64>(timestamp_);
|
||||
if (duration < 0) duration = 0;
|
||||
|
||||
if (!scrobbled_ && song_playing_.is_metadata_good() && song_playing_.is_radio() && duration > 30) {
|
||||
|
|
|
@ -394,7 +394,7 @@ void ScrobblingAPI20::UpdateNowPlaying(const Song &song) {
|
|||
CheckScrobblePrevSong();
|
||||
|
||||
song_playing_ = song;
|
||||
timestamp_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
timestamp_ = QDateTime::currentSecsSinceEpoch();
|
||||
scrobbled_ = false;
|
||||
|
||||
if (!authenticated() || !song.is_metadata_good() || settings_->offline()) return;
|
||||
|
@ -980,7 +980,7 @@ QString ScrobblingAPI20::ErrorString(const ScrobbleErrorCode error) {
|
|||
|
||||
void ScrobblingAPI20::CheckScrobblePrevSong() {
|
||||
|
||||
qint64 duration = QDateTime::currentDateTime().toSecsSinceEpoch() - static_cast<qint64>(timestamp_);
|
||||
qint64 duration = QDateTime::currentSecsSinceEpoch() - static_cast<qint64>(timestamp_);
|
||||
if (duration < 0) duration = 0;
|
||||
|
||||
if (!scrobbled_ && song_playing_.is_metadata_good() && song_playing_.is_radio() && duration > 30) {
|
||||
|
|
|
@ -216,7 +216,7 @@ void SpotifyService::LoadSession() {
|
|||
s.endGroup();
|
||||
|
||||
if (!refresh_token_.isEmpty()) {
|
||||
qint64 time = static_cast<qint64>(expires_in_) - (QDateTime::currentDateTime().toSecsSinceEpoch() - static_cast<qint64>(login_time_));
|
||||
qint64 time = static_cast<qint64>(expires_in_) - (QDateTime::currentSecsSinceEpoch() - static_cast<qint64>(login_time_));
|
||||
if (time < 1) time = 1;
|
||||
refresh_login_timer_.setInterval(static_cast<int>(time * kMsecPerSec));
|
||||
refresh_login_timer_.start();
|
||||
|
@ -479,7 +479,7 @@ void SpotifyService::AccessTokenRequestFinished(QNetworkReply *reply) {
|
|||
refresh_token_ = json_obj[QLatin1String("refresh_token")].toString();
|
||||
}
|
||||
expires_in_ = json_obj[QLatin1String("expires_in")].toInt();
|
||||
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
login_time_ = QDateTime::currentSecsSinceEpoch();
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(SpotifySettingsPage::kSettingsGroup);
|
||||
|
|
|
@ -242,7 +242,7 @@ void TidalService::LoadSession() {
|
|||
s.endGroup();
|
||||
|
||||
if (!refresh_token_.isEmpty()) {
|
||||
qint64 time = static_cast<qint64>(expires_in_) - (QDateTime::currentDateTime().toSecsSinceEpoch() - static_cast<qint64>(login_time_));
|
||||
qint64 time = static_cast<qint64>(expires_in_) - (QDateTime::currentSecsSinceEpoch() - static_cast<qint64>(login_time_));
|
||||
if (time <= 0) {
|
||||
timer_refresh_login_->setInterval(200ms);
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ void TidalService::AuthorizationUrlReceived(const QUrl &url) {
|
|||
refresh_token_ = url_query.queryItemValue(QStringLiteral("refresh_token"));
|
||||
}
|
||||
expires_in_ = url_query.queryItemValue(QStringLiteral("expires_in")).toInt();
|
||||
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
login_time_ = QDateTime::currentSecsSinceEpoch();
|
||||
session_id_.clear();
|
||||
|
||||
Settings s;
|
||||
|
@ -480,7 +480,7 @@ void TidalService::AccessTokenRequestFinished(QNetworkReply *reply) {
|
|||
if (json_obj.contains(QLatin1String("refresh_token"))) {
|
||||
refresh_token_ = json_obj[QLatin1String("refresh_token")].toString();
|
||||
}
|
||||
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
login_time_ = QDateTime::currentSecsSinceEpoch();
|
||||
|
||||
if (json_obj.contains(QLatin1String("user")) && json_obj[QLatin1String("user")].isObject()) {
|
||||
QJsonObject obj_user = json_obj[QLatin1String("user")].toObject();
|
||||
|
|
Loading…
Reference in New Issue