Skip to content

Commit

Permalink
Set TSL modified time to past (open-eid#1073)
Browse files Browse the repository at this point in the history
IB-7029

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored Jun 7, 2022
1 parent 20180ed commit da5859e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
29 changes: 16 additions & 13 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,18 @@ Application::Application( int &argc, char **argv )
d->signer = new QSigner(api, this);
QString cache = confValue(TSLCache).toString();
QDir().mkpath( cache );
QDateTime tslTime = QDateTime::currentDateTimeUtc().addDays(-7);
for(const QString &file: QDir(QStringLiteral(":/TSL/")).entryList())
{
const QString target = cache + "/" + file;
if(!QFile::exists(target) ||
readTSLVersion(":/TSL/" + file) > readTSLVersion(target))
QFile tl(cache + "/" + file);
if(!tl.exists() ||
readTSLVersion(":/TSL/" + file) > readTSLVersion(tl.fileName()))
{
QFile::remove(target);
QFile::copy(":/TSL/" + file, target);
QFile::setPermissions(target, QFile::Permissions(0x6444));
tl.remove();
QFile::copy(":/TSL/" + file, tl.fileName());
tl.setPermissions(QFile::Permissions(0x6444));
if(tl.open(QFile::Append))
tl.setFileTime(tslTime, QFileDevice::FileModificationTime);
}
}

Expand Down Expand Up @@ -612,17 +615,17 @@ QVariant Application::confValue( ConfParameter parameter, const QVariant &value
return r.isEmpty() ? value.toString() : QString::fromUtf8( r );
}

bool Application::event( QEvent *e )
bool Application::event(QEvent *event)
{
switch( int(e->type()) )
switch(int(event->type()))
{
case REOpenEvent::Type:
if( !activeWindow() )
parseArgs();
return true;
case QEvent::FileOpen:
{
QString fileName = static_cast<QFileOpenEvent*>(e)->file().normalized(QString::NormalizationForm_C);
QString fileName = static_cast<QFileOpenEvent*>(event)->file().normalized(QString::NormalizationForm_C);
QTimer::singleShot(0, [this, fileName] {
parseArgs({ fileName });
});
Expand All @@ -632,9 +635,9 @@ bool Application::event( QEvent *e )
// Load here because cocoa NSApplication overides events
case QEvent::ApplicationActivate:
initMacEvents();
return Common::event( e );
return Common::event(event);
#endif
default: return Common::event( e );
default: return Common::event(event);
}
}

Expand Down Expand Up @@ -931,11 +934,11 @@ void Application::migrateSettings()

}

bool Application::notify( QObject *o, QEvent *e )
bool Application::notify(QObject *object, QEvent *event)
{
try
{
return QApplication::notify( o, e );
return QApplication::notify(object, event);
}
catch( const digidoc::Exception &e )
{
Expand Down
4 changes: 2 additions & 2 deletions client/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Application final: public Common
#endif
void loadTranslation( const QString &lang );
QWidget* mainWindow();
bool notify( QObject *o, QEvent *e ) override;
bool notify(QObject *object, QEvent *event ) final;
void openHelp();
QSigner* signer() const;
int run();
Expand Down Expand Up @@ -95,7 +95,7 @@ private Q_SLOTS:

private:
void activate( QWidget *w );
bool event( QEvent *e ) override;
bool event(QEvent *event) final;
void migrateSettings();
static void showWarning(const QString &msg, const digidoc::Exception &e);
QWidget* uniqueRoot();
Expand Down

0 comments on commit da5859e

Please sign in to comment.