Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "QSmartCard.h"
#include "DigiDoc.h"
#include "Settings.h"
#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
#include "MacMenuBar.h"
#else
class MacMenuBar {};
Expand Down Expand Up @@ -174,7 +174,7 @@ class DigidocConf final: public digidoc::XmlConfCurrent
Settings::PROXY_PASS, [this] { return digidoc::XmlConfCurrent::proxyPass(); });
}

#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
std::string TSLCache() const final
{
return Application::groupContainerPath().toStdString();
Expand Down Expand Up @@ -384,7 +384,7 @@ Application::Application( int &argc, char **argv )
#ifdef NDEBUG
setLibraryPaths({ applicationDirPath() });
#endif
#elif defined(Q_OS_MAC)
#elifdef Q_OS_MACOS
qputenv("OPENSSL_CONF", applicationDirPath().toUtf8() + "../Resources/openssl.cnf");
#ifdef NDEBUG
setLibraryPaths({ applicationDirPath() + "/../PlugIns" });
Expand All @@ -393,7 +393,7 @@ Application::Application( int &argc, char **argv )

QStringList args = arguments();
args.removeFirst();
#ifndef Q_OS_MAC
#ifndef Q_OS_MACOS
d->lockFile = Common::acquireInstanceLock(args);
if(!d->lockFile)
return;
Expand Down Expand Up @@ -422,6 +422,7 @@ Application::Application( int &argc, char **argv )
QFont f(QStringLiteral("Roboto, Helvetica"));
f.setPixelSize(14);
QToolTip::setFont(f);
Common::setLanguage(Settings::LANGUAGE);

#ifdef CONFIG_URL
d->conf = new Configuration(this);
Expand Down Expand Up @@ -514,7 +515,7 @@ Application::Application( int &argc, char **argv )
connect(&d->lastWindowTimer, &QTimer::timeout, this, []{ if(topLevelWindows().isEmpty()) quit(); });
connect(this, &Application::lastWindowClosed, this, [&]{ d->lastWindowTimer.start(10s); });

#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
initMacServices();
d->bar = std::make_unique<MacMenuBar>();
d->bar->fileMenu()->addAction( d->newClientAction );
Expand All @@ -530,8 +531,7 @@ Application::Application( int &argc, char **argv )
d->cryptoManager = new QCryptoManager();
updateTSLCache(QDateTime::currentDateTimeUtc().addDays(-7));

digidoc::initialize(applicationName().toUtf8().constData(), QStringLiteral("%1/%2 (%3)")
.arg(applicationName(), applicationVersion(), Common::applicationOs()).toUtf8().constData(),
digidoc::initialize(applicationName().toUtf8().constData(), Common::userAgent().constData(),
[](const digidoc::Exception *ex) {
qDebug() << "TSL loading finished";
Q_EMIT qApp->TSLLoadingFinished();
Expand All @@ -549,7 +549,7 @@ Application::Application( int &argc, char **argv )
}

QMetaObject::invokeMethod(this, [this] {
#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
if(!Settings::PLUGINS.isSet())
{
auto *dlg = WarningDialog::create()
Expand Down Expand Up @@ -586,7 +586,7 @@ Application::~Application()
for(QWidget *top: topLevelWidgets())
top->close();

#ifndef Q_OS_MAC
#ifndef Q_OS_MACOS
if(!d->lockFile)
{
delete d;
Expand All @@ -612,18 +612,18 @@ Application::~Application()
}
}

#ifndef Q_OS_MAC
#ifndef Q_OS_MACOS
void Application::addRecent( const QString & ) {}
#endif

void Application::browse( const QUrl &url )
{
QUrl u = url;
u.setScheme(QStringLiteral("file"));
#if defined(Q_OS_WIN)
#ifdef Q_OS_WIN
if(QProcess::startDetached(QStringLiteral("explorer"), {QStringLiteral("/select,"), QDir::toNativeSeparators(u.toLocalFile())}))
return;
#elif defined(Q_OS_MAC)
#elifdef Q_OS_MACOS
if(QProcess::startDetached(QStringLiteral("open"), {QStringLiteral("-R"), u.toLocalFile()}))
return;
#endif
Expand All @@ -632,7 +632,7 @@ void Application::browse( const QUrl &url )

void Application::closeWindow()
{
#ifndef Q_OS_MAC
#ifndef Q_OS_MACOS
if(auto *w = qobject_cast<MainWindow*>(activeWindow()))
w->close();
else
Expand Down Expand Up @@ -713,6 +713,7 @@ void Application::loadTranslation( const QString &lang )
if( d->lang == lang )
return;
Settings::LANGUAGE = d->lang = lang;
Common::setLanguage(lang);

if(lang == QLatin1String("en")) QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom));
else QLocale::setDefault(QLocale(QLocale::Estonian, QLocale::Estonia));
Expand All @@ -724,7 +725,7 @@ void Application::loadTranslation( const QString &lang )
if(d->helpAction) d->helpAction->setText(tr("DigiDoc4 Client Help"));
}

#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
void Application::mailTo( const QUrl &url )
{
QUrlQuery q(url);
Expand Down Expand Up @@ -885,7 +886,7 @@ uint Application::readTSLVersion(const QString &path)

int Application::run()
{
#ifndef Q_OS_MAC
#ifndef Q_OS_MACOS
if(!d->lockFile) return 0;
#endif
return exec();
Expand Down Expand Up @@ -944,7 +945,7 @@ void Application::showClient(QStringList files, bool crypto, bool sign, bool new
}
#endif
}
#ifdef Q_OS_MAC
#ifdef Q_OS_MACOS
// Required for restoring minimized window on macOS
w->setWindowState(Qt::WindowActive);
#endif
Expand Down
4 changes: 2 additions & 2 deletions client/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Application final: public QApplication
static uint readTSLVersion(const QString &path);
static void showClient(QStringList params = {}, bool crypto = false, bool sign = false, bool newWindow = false);
static void updateTSLCache(const QDateTime &tslTime);
#if defined(Q_OS_MAC)
#ifdef Q_OS_MACOS
struct ProxyCredentials
{
ProxyCredentials(QString host, QString port, QString user, QString password);
Expand Down Expand Up @@ -101,7 +101,7 @@ private Q_SLOTS:
static void msgHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg);
static void parseArgs(QStringList args);
static void showWarning(const QString &title, const digidoc::Exception &e);
#if defined(Q_OS_MAC)
#ifdef Q_OS_MACOS
static void initMacServices();
#endif

Expand Down
7 changes: 4 additions & 3 deletions client/CheckConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ bool CheckConnection::check(const QUrl &url)
{
QNetworkAccessManager nam;
QEventLoop e;
QNetworkReply *reply = nam.head(QNetworkRequest(url));
QNetworkRequest request(url);
request.setRawHeader("User-Agent", Common::userAgent());
QNetworkReply *reply = nam.head(request);
QObject::connect(reply, &QNetworkReply::sslErrors, reply,
QOverload<const QList<QSslError> &>::of(&QNetworkReply::ignoreSslErrors));
QObject::connect(reply, &QNetworkReply::finished, &e, &QEventLoop::quit);
Expand Down Expand Up @@ -92,8 +94,7 @@ class LimitedNAM final: public QNetworkAccessManager
QNetworkAccessManager* CheckConnection::setupNAM(QNetworkRequest &req, const QByteArray &add)
{
req.setSslConfiguration(sslConfiguration(add));
req.setRawHeader("User-Agent", QStringLiteral("%1/%2 (%3)")
.arg(Application::applicationName(), Application::applicationVersion(), Common::applicationOs()).toUtf8());
req.setRawHeader("User-Agent", Common::userAgent());
auto *nam = new LimitedNAM();
QObject::connect(nam, &QNetworkAccessManager::sslErrors, nam, [](QNetworkReply *reply, const QList<QSslError> &errors) {
QList<QSslError> ignore;
Expand Down
12 changes: 2 additions & 10 deletions client/DigiDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,7 @@ bool DigiDoc::extend()
QWidget *parent = parentWidget();
try {
ExtendSigner signer;
signer.setUserAgent(QStringLiteral("%1/%2 (%3) Devices: %4").arg(
QCoreApplication::applicationName(),
QCoreApplication::applicationVersion(),
Common::applicationOs(),
Common::drivers().join(',')).toUtf8().constData());
signer.setUserAgent(Common::userAgent(true).constData());
qApp->waitForTSL(fileName());
QString current = m_fileName;
size_t extendCount = 0;
Expand Down Expand Up @@ -794,11 +790,7 @@ bool DigiDoc::sign(const QString &city, const QString &state, const QString &zip
roles.push_back(to(role));
signer->setSignerRoles(roles);
signer->setProfile(Settings::DEFAULT_LTA ? "time-stamp-archive" : "time-stamp");
signer->setUserAgent(QStringLiteral("%1/%2 (%3) Devices: %4").arg(
QCoreApplication::applicationName(),
QCoreApplication::applicationVersion(),
Common::applicationOs(),
Common::drivers().join(',')).toUtf8().constData());
signer->setUserAgent(Common::userAgent(true).constData());
qApp->waitForTSL( fileName() );
digidoc::Signature *s = b->sign(signer);
return modified = waitFor([&] {
Expand Down
3 changes: 1 addition & 2 deletions client/SslCertificate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ SslCertificate::Validity SslCertificate::validateOnline() const

// Get issuer
QNetworkRequest r(urls.values(SslCertificate::ad_CAIssuers).first());
r.setRawHeader("User-Agent", QStringLiteral("%1/%2 (%3)")
.arg(QCoreApplication::applicationName(), QCoreApplication::applicationVersion(), Common::applicationOs()).toUtf8());
r.setRawHeader("User-Agent", Common::userAgent());
r.setTransferTimeout(15000);
QNetworkReply *repl = m.get(r);
waitForSignal(&m, &QNetworkAccessManager::finished);
Expand Down
2 changes: 1 addition & 1 deletion common
Loading