Skip to content

Commit

Permalink
v3.8.5 Fixed network time setting
Browse files Browse the repository at this point in the history
  • Loading branch information
procount committed Mar 16, 2023
1 parent 24ba917 commit 1894e7a
Show file tree
Hide file tree
Showing 25 changed files with 3,007 additions and 2,997 deletions.
2 changes: 1 addition & 1 deletion recovery/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define CONFIG_H

/* Version number displayed in the title bar */
#define VERSION_NUMBER "3.8.4"
#define VERSION_NUMBER "3.8.5"

/* Color of the background */
// #define BACKGROUND_COLOR Qt::white
Expand Down
26 changes: 17 additions & 9 deletions recovery/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ MainWindow::MainWindow(const QString &drive, const QString &defaultDisplay, KSpl
_bootdrive(drive), _noobsconfig(noobsconfig), _numFilesToCheck(0), _eDownloadMode(MODE_INSTALL), _proc(NULL)
{
TRACE

timeset=false;
ui->setupUi(this);
setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
setContextMenuPolicy(Qt::NoContextMenu);
Expand Down Expand Up @@ -5064,8 +5066,9 @@ void MainWindow::on_actionRename_triggered()
void MainWindow::UpdateTime()
{

if (QDate::currentDate().year() < 2019)
if (!timeset)
{
qDebug() << "current date is "<< QDate::currentDate();
qDebug() << "Requesting current time";
QUrl url(BUILD_URL);
QNetworkRequest request(url);
Expand All @@ -5085,22 +5088,27 @@ void MainWindow::checkUpdateTime()

void MainWindow::setTime(QNetworkReply *reply)
{
/* Set our clock to server time if we currently have a date before 2019 */
/* Set our clock to server time if it is more than 1 day newer */
QByteArray dateStr = reply->rawHeader("Date");
if (!dateStr.isEmpty() && QDate::currentDate().year() < 2019)

if (!dateStr.isEmpty())
{
// Qt 4 does not have a standard function for parsing the Date header, but it does
// have one for parsing a Last-Modified header that uses the same date/time format, so just use that
QNetworkRequest dummyReq;
dummyReq.setRawHeader("Last-Modified", dateStr);
QDateTime parsedDate = dummyReq.header(dummyReq.LastModifiedHeader).toDateTime();

struct timeval tv;
tv.tv_sec = parsedDate.toTime_t();
tv.tv_usec = 0;
settimeofday(&tv, NULL);

qDebug() << "Time set to: " << parsedDate;
QDateTime now = QDateTime::currentDateTime().addDays(1);
if (parsedDate > now)
{
struct timeval tv;
tv.tv_sec = parsedDate.toTime_t();
tv.tv_usec = 0;
settimeofday(&tv, NULL);
timeset=true;
qDebug() << "Time set to: " << parsedDate;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion recovery/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class MainWindow : public QMainWindow
unsigned _waitforImages;
unsigned _processedImages;
QStringList _selectOsList;

bool timeset;
enum ModeTag _eDownloadMode;
uint _provision;

Expand Down
8 changes: 4 additions & 4 deletions recovery/multiimagewritethread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include "partitioninfo.h"
#include "util.h"

#define LOCAL_DBG_ON 1
#define LOCAL_DBG_FUNC 1
#define LOCAL_DBG_OUT 1
#define LOCAL_DBG_MSG 1
#define LOCAL_DBG_ON 0
#define LOCAL_DBG_FUNC 0
#define LOCAL_DBG_OUT 0
#define LOCAL_DBG_MSG 0

#include "mydebug.h"
#include <QDir>
Expand Down
Loading

0 comments on commit 1894e7a

Please sign in to comment.