Skip to content

Commit 186c985

Browse files
authored
Merge pull request #27 from hjaltisan/journeyId
JourneyId in the installer
2 parents f58606e + 928def0 commit 186c985

File tree

8 files changed

+208
-19
lines changed

8 files changed

+208
-19
lines changed

src/libs/installer/eve_launcher/application.pb.cc

Lines changed: 66 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/libs/installer/eve_launcher/application.pb.h

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/libs/installer/eventlogger.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <QRandomGenerator>
1111
#include <QUuid>
1212
#include <QDebug>
13+
#include <QRegularExpression>
1314

1415
EventLogger::EventLogger()
1516
{
@@ -37,6 +38,32 @@ EventLogger::EventLogger()
3738
m_session = QString(QLatin1String("ls")) + QString(QLatin1String(hasher.result().toHex()));
3839

3940
m_httpThreadController = new HttpThreadController();
41+
42+
// Get the journeyId from the installer filename
43+
QUuid journeyId;
44+
QString appName = QInstaller::getInstallerFileName().split(QLatin1String("/")).last();
45+
if (appName.length() > 35)
46+
{
47+
QString pattern = QLatin1String("[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}");
48+
QRegularExpression re(pattern, QRegularExpression::CaseInsensitiveOption);
49+
QRegularExpressionMatch match = re.match(appName);
50+
if (match.hasMatch()) {
51+
qDebug() << "framework | EventLogger::EventLogger | JourneyId found in filename:" << match.captured(0);
52+
journeyId = QUuid::fromString(match.captured(0));
53+
qDebug() << "framework | EventLogger::EventLogger | JourneyId:" << journeyId.toString(QUuid::WithoutBraces);
54+
}
55+
}
56+
57+
// If journey Id was found, or we weren't able to create a QUuid from it, we create a new one instead
58+
if (journeyId.isNull())
59+
{
60+
qDebug() << "framework | EventLogger::EventLogger | No JourneyId provided, one will be created instead";
61+
journeyId = QUuid::createUuid();
62+
qDebug() << "framework | EventLogger::EventLogger | JourneyId:" << journeyId.toString(QUuid::WithoutBraces);
63+
}
64+
65+
m_journeyId = journeyId.toRfc4122();
66+
QInstaller::setJourneyId(m_journeyId);
4067
}
4168

4269
EventLogger::~EventLogger()
@@ -235,6 +262,9 @@ eve_launcher::application::EventMetadata* EventLogger::getEventMetadata()
235262
data->set_allocated_operating_system_uuid(new std::string(m_operatingSystemUuid.data(), size_t(m_operatingSystemUuid.size())));
236263
}
237264

265+
// Set the journey
266+
data->set_allocated_journey(new std::string(m_journeyId.data(), size_t(m_journeyId.size())));
267+
238268
return data;
239269
}
240270

src/libs/installer/eventlogger.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class EventLogger : QObject
7474
QString m_session;
7575
QByteArray m_sessionId;
7676
QByteArray m_operatingSystemUuid;
77+
QByteArray m_journeyId;
7778
QPointer<HttpThreadController> m_httpThreadController;
7879

7980
explicit EventLogger();

src/libs/installer/packagemanagergui.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "productkeycheck.h"
4242
#include "repositorycategory.h"
4343
#include "componentselectionpage_p.h"
44+
#include "qsettingswrapper.h"
4445

4546
#include "sysinfo.h"
4647

@@ -3530,6 +3531,15 @@ void PerformInstallationPage::installationStarted()
35303531
void PerformInstallationPage::installationFinished()
35313532
{
35323533
m_performInstallationForm->stopUpdateProgress();
3534+
3535+
// Store the journey Id in registry
3536+
qDebug() << "framework | PerformInstallationPage::installationFinished | Storing JourneyId to registry";
3537+
QByteArray journeyId = QInstaller::getJourneyId();
3538+
QString path = QLatin1String("HKEY_CURRENT_USER\\SOFTWARE\\CCP\\EVE\\");
3539+
QSettingsWrapper settings(path, QSettingsWrapper::NativeFormat);
3540+
settings.setValue(QLatin1String("InstallerJourneyId"), journeyId);
3541+
qDebug() << "framework | PerformInstallationPage::installationFinished | JourneyId stored to registry";
3542+
35333543
if (!isAutoSwitching()) {
35343544
m_performInstallationForm->scrollDetailsToTheEnd();
35353545
m_performInstallationForm->setDetailsButtonEnabled(false);

src/libs/installer/utils.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,30 @@ QString QInstaller::getProvidedTelemetryEndpoint()
273273
return telemetryUrl;
274274
}
275275

276+
static QString installerFileName;
277+
278+
void QInstaller::setInstallerFileName(const QString& fileName)
279+
{
280+
installerFileName = fileName;
281+
}
282+
283+
QString QInstaller::getInstallerFileName()
284+
{
285+
return installerFileName;
286+
}
287+
288+
static QByteArray journeyId;
289+
290+
void QInstaller::setJourneyId(const QByteArray& id)
291+
{
292+
journeyId = id;
293+
}
294+
295+
QByteArray QInstaller::getJourneyId()
296+
{
297+
return journeyId;
298+
}
299+
276300
std::ostream &QInstaller::operator<<(std::ostream &os, const QString &string)
277301
{
278302
return os << qPrintable(string);

0 commit comments

Comments
 (0)