diff options
| author | 2017-08-23 00:08:07 -0400 | |
|---|---|---|
| committer | 2017-08-25 23:10:02 -0400 | |
| commit | 9f0da33c3349df47580d93fcd25346be4d2b94a7 (patch) | |
| tree | d981fbe3cf164598a2459cc02d74e8e9fa8df191 /src | |
| parent | default_ini: Use correct telemetry endpoint URL. (diff) | |
| download | yuzu-9f0da33c3349df47580d93fcd25346be4d2b94a7.tar.gz yuzu-9f0da33c3349df47580d93fcd25346be4d2b94a7.tar.xz yuzu-9f0da33c3349df47580d93fcd25346be4d2b94a7.zip | |
qt: Add an option to view/regenerate telemetry ID.
Diffstat (limited to '')
| -rw-r--r-- | src/citra_qt/configuration/configure_web.cpp | 14 | ||||
| -rw-r--r-- | src/citra_qt/configuration/configure_web.h | 2 | ||||
| -rw-r--r-- | src/core/telemetry_session.cpp | 19 | ||||
| -rw-r--r-- | src/core/telemetry_session.h | 12 |
4 files changed, 40 insertions, 7 deletions
diff --git a/src/citra_qt/configuration/configure_web.cpp b/src/citra_qt/configuration/configure_web.cpp index fff466aaa..8715fb018 100644 --- a/src/citra_qt/configuration/configure_web.cpp +++ b/src/citra_qt/configuration/configure_web.cpp | |||
| @@ -4,11 +4,15 @@ | |||
| 4 | 4 | ||
| 5 | #include "citra_qt/configuration/configure_web.h" | 5 | #include "citra_qt/configuration/configure_web.h" |
| 6 | #include "core/settings.h" | 6 | #include "core/settings.h" |
| 7 | #include "core/telemetry_session.h" | ||
| 7 | #include "ui_configure_web.h" | 8 | #include "ui_configure_web.h" |
| 8 | 9 | ||
| 9 | ConfigureWeb::ConfigureWeb(QWidget* parent) | 10 | ConfigureWeb::ConfigureWeb(QWidget* parent) |
| 10 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureWeb>()) { | 11 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureWeb>()) { |
| 11 | ui->setupUi(this); | 12 | ui->setupUi(this); |
| 13 | connect(ui->button_regenerate_telemetry_id, &QPushButton::clicked, this, | ||
| 14 | &ConfigureWeb::refreshTelemetryID); | ||
| 15 | |||
| 12 | this->setConfiguration(); | 16 | this->setConfiguration(); |
| 13 | } | 17 | } |
| 14 | 18 | ||
| @@ -30,8 +34,8 @@ void ConfigureWeb::setConfiguration() { | |||
| 30 | ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry); | 34 | ui->toggle_telemetry->setChecked(Settings::values.enable_telemetry); |
| 31 | ui->edit_username->setText(QString::fromStdString(Settings::values.citra_username)); | 35 | ui->edit_username->setText(QString::fromStdString(Settings::values.citra_username)); |
| 32 | ui->edit_token->setText(QString::fromStdString(Settings::values.citra_token)); | 36 | ui->edit_token->setText(QString::fromStdString(Settings::values.citra_token)); |
| 33 | 37 | ui->label_telemetry_id->setText("Telemetry ID: 0x" + | |
| 34 | updateWeb(); | 38 | QString::number(Core::GetTelemetryId(), 16).toUpper()); |
| 35 | } | 39 | } |
| 36 | 40 | ||
| 37 | void ConfigureWeb::applyConfiguration() { | 41 | void ConfigureWeb::applyConfiguration() { |
| @@ -41,4 +45,8 @@ void ConfigureWeb::applyConfiguration() { | |||
| 41 | Settings::Apply(); | 45 | Settings::Apply(); |
| 42 | } | 46 | } |
| 43 | 47 | ||
| 44 | void ConfigureWeb::updateWeb() {} | 48 | void ConfigureWeb::refreshTelemetryID() { |
| 49 | const u64 new_telemetry_id{Core::RegenerateTelemetryId()}; | ||
| 50 | ui->label_telemetry_id->setText("Telemetry ID: 0x" + | ||
| 51 | QString::number(new_telemetry_id, 16).toUpper()); | ||
| 52 | } | ||
diff --git a/src/citra_qt/configuration/configure_web.h b/src/citra_qt/configuration/configure_web.h index 2c37b8f90..20bc254b9 100644 --- a/src/citra_qt/configuration/configure_web.h +++ b/src/citra_qt/configuration/configure_web.h | |||
| @@ -21,7 +21,7 @@ public: | |||
| 21 | void applyConfiguration(); | 21 | void applyConfiguration(); |
| 22 | 22 | ||
| 23 | public slots: | 23 | public slots: |
| 24 | void updateWeb(); | 24 | void refreshTelemetryID(); |
| 25 | 25 | ||
| 26 | private: | 26 | private: |
| 27 | void setConfiguration(); | 27 | void setConfiguration(); |
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 61ba78457..d0f257f58 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp | |||
| @@ -38,21 +38,21 @@ static u64 GenerateTelemetryId() { | |||
| 38 | return telemetry_id; | 38 | return telemetry_id; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | static u64 GetTelemetryId() { | 41 | u64 GetTelemetryId() { |
| 42 | u64 telemetry_id{}; | 42 | u64 telemetry_id{}; |
| 43 | static const std::string& filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; | 43 | static const std::string& filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; |
| 44 | 44 | ||
| 45 | if (FileUtil::Exists(filename)) { | 45 | if (FileUtil::Exists(filename)) { |
| 46 | FileUtil::IOFile file(filename, "rb"); | 46 | FileUtil::IOFile file(filename, "rb"); |
| 47 | if (!file.IsOpen()) { | 47 | if (!file.IsOpen()) { |
| 48 | LOG_ERROR(WebService, "failed to open telemetry_id: %s", filename.c_str()); | 48 | LOG_ERROR(Core, "failed to open telemetry_id: %s", filename.c_str()); |
| 49 | return {}; | 49 | return {}; |
| 50 | } | 50 | } |
| 51 | file.ReadBytes(&telemetry_id, sizeof(u64)); | 51 | file.ReadBytes(&telemetry_id, sizeof(u64)); |
| 52 | } else { | 52 | } else { |
| 53 | FileUtil::IOFile file(filename, "wb"); | 53 | FileUtil::IOFile file(filename, "wb"); |
| 54 | if (!file.IsOpen()) { | 54 | if (!file.IsOpen()) { |
| 55 | LOG_ERROR(WebService, "failed to open telemetry_id: %s", filename.c_str()); | 55 | LOG_ERROR(Core, "failed to open telemetry_id: %s", filename.c_str()); |
| 56 | return {}; | 56 | return {}; |
| 57 | } | 57 | } |
| 58 | telemetry_id = GenerateTelemetryId(); | 58 | telemetry_id = GenerateTelemetryId(); |
| @@ -62,6 +62,19 @@ static u64 GetTelemetryId() { | |||
| 62 | return telemetry_id; | 62 | return telemetry_id; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | u64 RegenerateTelemetryId() { | ||
| 66 | const u64 new_telemetry_id{GenerateTelemetryId()}; | ||
| 67 | static const std::string& filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; | ||
| 68 | |||
| 69 | FileUtil::IOFile file(filename, "wb"); | ||
| 70 | if (!file.IsOpen()) { | ||
| 71 | LOG_ERROR(Core, "failed to open telemetry_id: %s", filename.c_str()); | ||
| 72 | return {}; | ||
| 73 | } | ||
| 74 | file.WriteBytes(&new_telemetry_id, sizeof(u64)); | ||
| 75 | return new_telemetry_id; | ||
| 76 | } | ||
| 77 | |||
| 65 | TelemetrySession::TelemetrySession() { | 78 | TelemetrySession::TelemetrySession() { |
| 66 | #ifdef ENABLE_WEB_SERVICE | 79 | #ifdef ENABLE_WEB_SERVICE |
| 67 | backend = std::make_unique<WebService::TelemetryJson>(); | 80 | backend = std::make_unique<WebService::TelemetryJson>(); |
diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.h index cf53835c3..65613daae 100644 --- a/src/core/telemetry_session.h +++ b/src/core/telemetry_session.h | |||
| @@ -35,4 +35,16 @@ private: | |||
| 35 | std::unique_ptr<Telemetry::VisitorInterface> backend; ///< Backend interface that logs fields | 35 | std::unique_ptr<Telemetry::VisitorInterface> backend; ///< Backend interface that logs fields |
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | /** | ||
| 39 | * Gets TelemetryId, a unique identifier used for the user's telemetry sessions. | ||
| 40 | * @returns The current TelemetryId for the session. | ||
| 41 | */ | ||
| 42 | u64 GetTelemetryId(); | ||
| 43 | |||
| 44 | /** | ||
| 45 | * Regenerates TelemetryId, a unique identifier used for the user's telemetry sessions. | ||
| 46 | * @returns The new TelemetryId that was generated. | ||
| 47 | */ | ||
| 48 | u64 RegenerateTelemetryId(); | ||
| 49 | |||
| 38 | } // namespace Core | 50 | } // namespace Core |