Browse Source

Remove usage of deprecated functions

Also use proper type for storing date/time data
adaptive-webui-19844
Chocobo1 7 years ago
parent
commit
fdf3ebbb6c
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 2
      src/gui/properties/speedplotview.h
  2. 2
      src/gui/properties/speedwidget.cpp
  3. 4
      src/webui/api/authcontroller.cpp
  4. 2
      src/webui/api/authcontroller.h
  5. 8
      src/webui/webapplication.cpp
  6. 4
      src/webui/webapplication.h

2
src/gui/properties/speedplotview.h

@ -69,7 +69,7 @@ public: @@ -69,7 +69,7 @@ public:
struct PointData
{
uint x;
qint64 x;
int y[NB_GRAPHS];
};

2
src/gui/properties/speedwidget.cpp

@ -137,7 +137,7 @@ void SpeedWidget::update() @@ -137,7 +137,7 @@ void SpeedWidget::update()
const BitTorrent::SessionStatus &btStatus = BitTorrent::Session::instance()->status();
SpeedPlotView::PointData point;
point.x = QDateTime::currentDateTime().toTime_t();
point.x = QDateTime::currentMSecsSinceEpoch() / 1000;
point.y[SpeedPlotView::UP] = btStatus.uploadRate;
point.y[SpeedPlotView::DOWN] = btStatus.downloadRate;
point.y[SpeedPlotView::PAYLOAD_UP] = btStatus.payloadUploadRate;

4
src/webui/api/authcontroller.cpp

@ -78,7 +78,7 @@ void AuthController::logoutAction() @@ -78,7 +78,7 @@ void AuthController::logoutAction()
bool AuthController::isBanned() const
{
const uint now = QDateTime::currentDateTime().toTime_t();
const qint64 now = QDateTime::currentMSecsSinceEpoch() / 1000;
const FailedLogin failedLogin = m_clientFailedLogins.value(sessionManager()->clientId());
bool isBanned = (failedLogin.bannedAt > 0);
@ -103,6 +103,6 @@ void AuthController::increaseFailedAttempts() @@ -103,6 +103,6 @@ void AuthController::increaseFailedAttempts()
if (failedLogin.failedAttemptsCount == MAX_AUTH_FAILED_ATTEMPTS) {
// Max number of failed attempts reached
// Start ban period
failedLogin.bannedAt = QDateTime::currentDateTime().toTime_t();
failedLogin.bannedAt = QDateTime::currentMSecsSinceEpoch() / 1000;
}
}

2
src/webui/api/authcontroller.h

@ -53,7 +53,7 @@ private: @@ -53,7 +53,7 @@ private:
struct FailedLogin
{
int failedAttemptsCount = 0;
uint bannedAt = 0;
qint64 bannedAt = 0;
};
mutable QHash<QString, FailedLogin> m_clientFailedLogins;
};

8
src/webui/webapplication.cpp

@ -547,7 +547,7 @@ void WebApplication::sessionInitialize() @@ -547,7 +547,7 @@ void WebApplication::sessionInitialize()
if (!sessionId.isEmpty()) {
m_currentSession = m_sessions.value(sessionId);
if (m_currentSession) {
const uint now = QDateTime::currentDateTime().toTime_t();
const qint64 now = QDateTime::currentMSecsSinceEpoch() / 1000;
if ((now - m_currentSession->m_timestamp) > INACTIVE_TIME) {
// session is outdated - removing it
delete m_sessions.take(sessionId);
@ -605,7 +605,7 @@ void WebApplication::sessionStart() @@ -605,7 +605,7 @@ void WebApplication::sessionStart()
Q_ASSERT(!m_currentSession);
// remove outdated sessions
const uint now = QDateTime::currentDateTime().toTime_t();
const qint64 now = QDateTime::currentMSecsSinceEpoch() / 1000;
foreach (const auto session, m_sessions) {
if ((now - session->timestamp()) > INACTIVE_TIME)
delete m_sessions.take(session->id());
@ -737,7 +737,7 @@ QString WebSession::id() const @@ -737,7 +737,7 @@ QString WebSession::id() const
return m_sid;
}
uint WebSession::timestamp() const
qint64 WebSession::timestamp() const
{
return m_timestamp;
}
@ -754,5 +754,5 @@ void WebSession::setData(const QString &id, const QVariant &data) @@ -754,5 +754,5 @@ void WebSession::setData(const QString &id, const QVariant &data)
void WebSession::updateTimestamp()
{
m_timestamp = QDateTime::currentDateTime().toTime_t();
m_timestamp = QDateTime::currentMSecsSinceEpoch() / 1000;
}

4
src/webui/webapplication.h

@ -59,7 +59,7 @@ public: @@ -59,7 +59,7 @@ public:
explicit WebSession(const QString &sid);
QString id() const override;
uint timestamp() const;
qint64 timestamp() const;
QVariant getData(const QString &id) const override;
void setData(const QString &id, const QVariant &data) override;
@ -68,7 +68,7 @@ private: @@ -68,7 +68,7 @@ private:
void updateTimestamp();
const QString m_sid;
uint m_timestamp;
qint64 m_timestamp;
QVariantHash m_data;
};

Loading…
Cancel
Save