Skip to content

Commit

Permalink
rename OnlineSettings module to OnlineConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
Aytackydln committed Sep 15, 2024
1 parent c53fcc6 commit 40beda9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
4 changes: 3 additions & 1 deletion Project-Aurora/Project-Aurora/AuroraApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using AuroraRgb.Settings;
using AuroraRgb.Settings.Controls;
using AuroraRgb.Utils;
using LibUsbDotNet;

namespace AuroraRgb;

Expand Down Expand Up @@ -41,7 +42,7 @@ public AuroraApp(bool isSilent)
_devicesModule.DeviceManager, ProcessesModule.ActiveProcessMonitor, ProcessesModule.RunningProcessMonitor,
_devicesModule
);
var onlineSettings = new OnlineSettings(ProcessesModule.RunningProcessMonitor);
var onlineSettings = new OnlineConfiguration(ProcessesModule.RunningProcessMonitor);
_layoutsModule = new LayoutsModule(RazerSdkModule.RzSdkManager, onlineSettings.LayoutsUpdate);

_modules =
Expand Down Expand Up @@ -133,6 +134,7 @@ public Task Shutdown()
Global.logger.Fatal(moduleException,"Failed closing module {@Module}", m);
}
});
UsbDevice.Exit();
return Task.WhenAll(tasks);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
Expand Down Expand Up @@ -144,7 +145,7 @@ private void UpdateStatic()
DeviceName.Text = _device.Device.DeviceName;
BtnOptions.IsEnabled = _device.Device.RegisteredVariables.Count != 0;

if (!OnlineSettings.DeviceTooltips.TryGetValue(_device.Device.DeviceName, out var tooltips))
if (!OnlineConfiguration.DeviceTooltips.TryGetValue(_device.Device.DeviceName, out var tooltips))
{
return;
}
Expand Down Expand Up @@ -220,7 +221,7 @@ private void SdkLink_Clicked(object? sender, MouseButtonEventArgs e)
{
if (_sdkLink != null)
{
System.Diagnostics.Process.Start("explorer", _sdkLink);
Process.Start("explorer", _sdkLink);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace AuroraRgb.Modules;

public sealed class OnlineSettings(Task<RunningProcessMonitor> runningProcessMonitor)
public sealed class OnlineConfiguration(Task<RunningProcessMonitor> runningProcessMonitor)
: AuroraModule
{
public static Dictionary<string, DeviceTooltips> DeviceTooltips { get; private set; } = new();
Expand All @@ -35,15 +35,14 @@ protected override async Task Initialize()
// means online settings already exists, loading can continue immediately
_layoutUpdateTaskSource.TrySetResult();
}

// reload settings as user unlocks
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;

await DownloadAndExtract();
_layoutUpdateTaskSource.TrySetResult();
//TODO update layouts
await Refresh();

// reload settings as user unlocks
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
(await runningProcessMonitor).ProcessStarted += OnRunningProcessesChanged;

if (Global.SensitiveData.Lat == 0 && Global.SensitiveData.Lon == 0)
Expand All @@ -56,7 +55,7 @@ protected override async Task Initialize()
}
catch (Exception e)
{
Global.logger.Error(e, "Failed getting geographic data");
Global.logger.Error(e, "[OnlineConfiguration] Failed getting geographic data");
}
}
}
Expand All @@ -65,11 +64,12 @@ private async Task DownloadAndExtract()
{
try
{
Global.logger.Information("[OnlineConfiguration] Waiting for internet access...");
await WaitGithubAccess(TimeSpan.FromSeconds(60));
}
catch (Exception e)
{
Global.logger.Error(e, "Skipped Online Settings update because of internet problem");
Global.logger.Error(e, "[OnlineConfiguration] Skipped Online Settings update because of internet problem");
return;
}

Expand All @@ -81,7 +81,7 @@ private async Task DownloadAndExtract()
}
catch (Exception e)
{
Global.logger.Error(e, "Error fetching online settings");
Global.logger.Error(e, "[OnlineConfiguration] Error fetching online settings");
return;
}

Expand All @@ -94,15 +94,15 @@ private async Task DownloadAndExtract()
return;
}

Global.logger.Information("Updating Online Settings");
Global.logger.Information("[OnlineConfiguration] Updating Online Settings");

try
{
await ExtractSettings();
}
catch (Exception e)
{
Global.logger.Error(e, "Error extracting online settings");
Global.logger.Error(e, "[OnlineConfiguration] Error extracting online settings");
}
}

Expand All @@ -114,7 +114,7 @@ private async Task Refresh()
}
catch (Exception e)
{
Global.logger.Error(e, "Failed to update conflicts");
Global.logger.Error(e, "[OnlineConfiguration] Failed to update conflicts");
}

try
Expand All @@ -123,7 +123,7 @@ private async Task Refresh()
}
catch (Exception e)
{
Global.logger.Error(e, "Failed to update device infos");
Global.logger.Error(e, "[OnlineConfiguration] Failed to update device infos");
}

try
Expand All @@ -132,7 +132,7 @@ private async Task Refresh()
}
catch (Exception e)
{
Global.logger.Error(e, "Failed to update razer mice info");
Global.logger.Error(e, "[OnlineConfiguration] Failed to update razer mice info");
}
}

Expand Down
5 changes: 2 additions & 3 deletions Project-Aurora/Project-Aurora/Nodes/Razer/RazerFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ protected RazerFetcher()
}

var productKeyString = GetDeviceProductKeyString(usbDevice);
var mouseHidInfo = OnlineSettings.RazerDeviceInfo.MouseHidInfos[productKeyString];
var mouseHidInfo = OnlineConfiguration.RazerDeviceInfo.MouseHidInfos[productKeyString];
var message = GetMessage(mouseHidInfo);

usbDevice.Open();
var report = GetReport(usbDevice, message);
usbDevice.Close();
UsbDevice.Exit();
_mutex.ReleaseMutex();

return report;
Expand All @@ -79,7 +78,7 @@ protected RazerFetcher()
private static UsbDevice? GetUsbDevice()
{
const int vendorId = 0x1532;
var mouseDictionary = OnlineSettings.RazerDeviceInfo.MouseHidInfos;
var mouseDictionary = OnlineConfiguration.RazerDeviceInfo.MouseHidInfos;

var usbDevice = UsbDevice.OpenUsbDevice(d =>
d.Vid == vendorId &&
Expand Down

0 comments on commit 40beda9

Please sign in to comment.