2020-04-17 21:45:50 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// Aaru Data Preservation Suite
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : SettingsViewModel.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : GUI view models.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// View model and code for the settings dialog.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU General public License as
|
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
// GNU General public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU General public License
|
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-02-18 10:02:53 +00:00
|
|
|
|
// Copyright © 2011-2022 Natalia Portillo
|
2020-04-17 21:45:50 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
namespace Aaru.Gui.ViewModels.Dialogs;
|
|
|
|
|
|
|
2020-04-17 21:45:50 +01:00
|
|
|
|
using System.Reactive;
|
2020-04-16 20:40:25 +01:00
|
|
|
|
using Aaru.Gui.Views.Dialogs;
|
2020-04-10 22:33:27 +01:00
|
|
|
|
using Aaru.Settings;
|
2020-07-22 13:20:25 +01:00
|
|
|
|
using JetBrains.Annotations;
|
2020-04-10 22:33:27 +01:00
|
|
|
|
using ReactiveUI;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public sealed class SettingsViewModel : ViewModelBase
|
2020-04-10 22:33:27 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
readonly SettingsDialog _view;
|
|
|
|
|
|
bool _commandStatsChecked;
|
|
|
|
|
|
bool _deviceStatsChecked;
|
|
|
|
|
|
bool _filesystemStatsChecked;
|
|
|
|
|
|
bool _filterStatsChecked;
|
|
|
|
|
|
bool _gdprVisible;
|
|
|
|
|
|
bool _mediaImageStatsChecked;
|
|
|
|
|
|
bool _mediaScanStatsChecked;
|
|
|
|
|
|
bool _mediaStatsChecked;
|
|
|
|
|
|
bool _partitionStatsChecked;
|
|
|
|
|
|
bool _saveReportsGloballyChecked;
|
|
|
|
|
|
bool _saveStatsChecked;
|
|
|
|
|
|
bool _shareReportsChecked;
|
|
|
|
|
|
bool _shareStatsChecked;
|
|
|
|
|
|
int _tabControlSelectedIndex;
|
|
|
|
|
|
bool _verifyStatsChecked;
|
|
|
|
|
|
|
|
|
|
|
|
public SettingsViewModel(SettingsDialog view, bool gdprChange)
|
2020-04-10 22:33:27 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_view = view;
|
|
|
|
|
|
GdprVisible = gdprChange;
|
2022-03-07 07:36:44 +00:00
|
|
|
|
SaveReportsGloballyChecked = Settings.Current.SaveReportsGlobally;
|
|
|
|
|
|
ShareReportsChecked = Settings.Current.ShareReports;
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
if(Settings.Current.Stats != null)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
SaveStatsChecked = true;
|
2022-03-07 07:36:44 +00:00
|
|
|
|
ShareStatsChecked = Settings.Current.Stats.ShareStats;
|
|
|
|
|
|
CommandStatsChecked = Settings.Current.Stats.CommandStats;
|
|
|
|
|
|
DeviceStatsChecked = Settings.Current.Stats.DeviceStats;
|
|
|
|
|
|
FilesystemStatsChecked = Settings.Current.Stats.FilesystemStats;
|
|
|
|
|
|
FilterStatsChecked = Settings.Current.Stats.FilterStats;
|
|
|
|
|
|
MediaImageStatsChecked = Settings.Current.Stats.MediaImageStats;
|
|
|
|
|
|
MediaScanStatsChecked = Settings.Current.Stats.MediaScanStats;
|
|
|
|
|
|
PartitionStatsChecked = Settings.Current.Stats.PartitionStats;
|
|
|
|
|
|
MediaStatsChecked = Settings.Current.Stats.MediaStats;
|
|
|
|
|
|
VerifyStatsChecked = Settings.Current.Stats.VerifyStats;
|
2020-04-10 22:33:27 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
|
|
|
|
|
SaveStatsChecked = false;
|
|
|
|
|
|
|
|
|
|
|
|
CancelCommand = ReactiveCommand.Create(ExecuteCancelCommand);
|
|
|
|
|
|
SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand);
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(!_gdprVisible)
|
|
|
|
|
|
_tabControlSelectedIndex = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Show Preferences in macOS
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string Title => "Settings";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string GdprLabel => "GDPR";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string ReportsLabel => "Reports";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string StatisticsLabel => "Statistics";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string SaveLabel => "Save";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string CancelLabel => "Cancel";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string GdprText1 =>
|
|
|
|
|
|
@"In compliance with the European Union General Data Protection Regulation 2016/679 (GDPR),
|
2020-04-10 22:33:27 +01:00
|
|
|
|
we must give you the following information about Aaru and ask if you want to opt-in
|
|
|
|
|
|
in some information sharing.";
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-03-07 07:36:44 +00:00
|
|
|
|
public string GdprText2 => @"Disclaimer: Because Aaru is an open source software this information, and therefore,
|
2020-04-10 22:33:27 +01:00
|
|
|
|
compliance with GDPR only holds true if you obtained a certificated copy from its original
|
|
|
|
|
|
authors. In case of doubt, close Aaru now and ask in our IRC support channel.";
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string GdprText3 =>
|
|
|
|
|
|
@"For any information sharing your IP address may be stored in our server, in a way that is not
|
2020-04-10 22:33:27 +01:00
|
|
|
|
possible for any person, manual, or automated process, to link with your identity, unless
|
|
|
|
|
|
specified otherwise.";
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string ReportsGloballyText =>
|
|
|
|
|
|
@"With the 'device-report' command, Aaru creates a report of a device, that includes its
|
2020-04-10 22:33:27 +01:00
|
|
|
|
manufacturer, model, firmware revision and/or version, attached bus, size, and supported commands.
|
|
|
|
|
|
The serial number of the device is not stored in the report. If used with the debug parameter,
|
|
|
|
|
|
extra information about the device will be stored in the report. This information is known to contain
|
|
|
|
|
|
the device serial number in non-standard places that prevent the automatic removal of it on a handful
|
|
|
|
|
|
of devices. A human-readable copy of the report in XML format is always created in the same directory
|
|
|
|
|
|
where Aaru is being run from.";
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string SaveReportsGloballyText => "Save device reports in shared folder of your computer?";
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string ReportsText =>
|
|
|
|
|
|
@"Sharing a report with us will send it to our server, that's in the european union territory, where it
|
2020-07-22 13:20:25 +01:00
|
|
|
|
will be manually analyzed by an european union citizen to remove any trace of personal identification
|
2020-04-10 22:33:27 +01:00
|
|
|
|
from it. Once that is done, it will be shared in our stats website, https://www.aaru.app
|
|
|
|
|
|
These report will be used to improve Aaru support, and in some cases, to provide emulation of the
|
|
|
|
|
|
devices to other open-source projects. In any case, no information linking the report to you will be stored.";
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string ShareReportsText => "Share your device reports with us?";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string StatisticsText =>
|
|
|
|
|
|
@"Aaru can store some usage statistics. These statistics are limited to the number of times a
|
2020-04-10 22:33:27 +01:00
|
|
|
|
command is executed, a filesystem, partition, or device is used, the operating system version, and other.
|
|
|
|
|
|
In no case, any information besides pure statistical usage numbers is stored, and they're just joint to the
|
|
|
|
|
|
pool with no way of using them to identify you.";
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string SaveStatsText => "Save stats about your Aaru usage?";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string ShareStatsText => "Share your stats (anonymously)?";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string CommandStatsText => "Gather statistics about command usage?";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string DeviceStatsText => "Gather statistics about found devices?";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string FilesystemStatsText => "Gather statistics about found filesystems?";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string FilterStatsText => "Gather statistics about found file filters?";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string MediaImageStatsText => "Gather statistics about found media image formats?";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string MediaScanStatsText => "Gather statistics about scanned media?";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string PartitionStatsText => "Gather statistics about found partitioning schemes?";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string MediaStatsText => "Gather statistics about media types?";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string VerifyStatsText => "Gather statistics about media image verifications?";
|
|
|
|
|
|
|
|
|
|
|
|
public ReactiveCommand<Unit, Unit> CancelCommand { get; }
|
|
|
|
|
|
public ReactiveCommand<Unit, Unit> SaveCommand { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public bool GdprVisible
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _gdprVisible;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _gdprVisible, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool SaveReportsGloballyChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _saveReportsGloballyChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _saveReportsGloballyChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool ShareReportsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _shareReportsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _shareReportsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool SaveStatsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _saveStatsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _saveStatsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool ShareStatsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _shareStatsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _shareStatsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool CommandStatsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _commandStatsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _commandStatsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool DeviceStatsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _deviceStatsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _deviceStatsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool FilesystemStatsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _filesystemStatsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _filesystemStatsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool FilterStatsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _filterStatsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _filterStatsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool MediaImageStatsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _mediaImageStatsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _mediaImageStatsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool MediaScanStatsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _mediaScanStatsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _mediaScanStatsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool PartitionStatsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _partitionStatsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _partitionStatsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool MediaStatsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _mediaStatsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _mediaStatsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool VerifyStatsChecked
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _verifyStatsChecked;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _verifyStatsChecked, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public int TabControlSelectedIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _tabControlSelectedIndex;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _tabControlSelectedIndex, value);
|
|
|
|
|
|
}
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
void ExecuteSaveCommand()
|
|
|
|
|
|
{
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Settings.Current.SaveReportsGlobally = SaveReportsGloballyChecked;
|
|
|
|
|
|
Settings.Current.ShareReports = ShareReportsChecked;
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(SaveStatsChecked)
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Settings.Current.Stats = new StatsSettings
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
ShareStats = ShareStatsChecked,
|
|
|
|
|
|
CommandStats = CommandStatsChecked,
|
|
|
|
|
|
DeviceStats = DeviceStatsChecked,
|
|
|
|
|
|
FilesystemStats = FilesystemStatsChecked,
|
|
|
|
|
|
FilterStats = FilterStatsChecked,
|
|
|
|
|
|
MediaImageStats = MediaImageStatsChecked,
|
|
|
|
|
|
MediaScanStats = MediaScanStatsChecked,
|
|
|
|
|
|
PartitionStats = PartitionStatsChecked,
|
|
|
|
|
|
MediaStats = MediaStatsChecked,
|
|
|
|
|
|
VerifyStats = VerifyStatsChecked
|
|
|
|
|
|
};
|
|
|
|
|
|
else
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Settings.Current.Stats = null;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
Settings.Current.GdprCompliance = DicSettings.GDPR_LEVEL;
|
|
|
|
|
|
Settings.SaveSettings();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_view.Close();
|
2020-04-10 22:33:27 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
void ExecuteCancelCommand() => _view.Close();
|
2020-04-10 22:33:27 +01:00
|
|
|
|
}
|