remove unncessary sha1 dictionary, use new notification management
This commit is contained in:
@@ -33,21 +33,21 @@
|
|||||||
<PackageReference Include="DalamudPackager" Version="2.1.12" />
|
<PackageReference Include="DalamudPackager" Version="2.1.12" />
|
||||||
<PackageReference Include="Downloader" Version="3.0.6" />
|
<PackageReference Include="Downloader" Version="3.0.6" />
|
||||||
<PackageReference Include="lz4net" Version="1.0.15.93" />
|
<PackageReference Include="lz4net" Version="1.0.15.93" />
|
||||||
<PackageReference Include="Meziantou.Analyzer" Version="2.0.145">
|
<PackageReference Include="Meziantou.Analyzer" Version="2.0.146">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.11" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="7.0.11" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
<PackageReference Include="Penumbra.Api" Version="1.0.14" />
|
<PackageReference Include="Penumbra.Api" Version="1.0.14" />
|
||||||
<PackageReference Include="Penumbra.String" Version="1.0.4" />
|
<PackageReference Include="Penumbra.String" Version="1.0.4" />
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
|
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.3" />
|
||||||
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.20.0.85982">
|
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.21.0.86780">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.32.1" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.4.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public sealed class PairManager : DisposableMediatorSubscriberBase
|
|||||||
var msg = !string.IsNullOrEmpty(note)
|
var msg = !string.IsNullOrEmpty(note)
|
||||||
? $"{note} ({pair.UserData.AliasOrUID}) is now online"
|
? $"{note} ({pair.UserData.AliasOrUID}) is now online"
|
||||||
: $"{pair.UserData.AliasOrUID} is now online";
|
: $"{pair.UserData.AliasOrUID} is now online";
|
||||||
Mediator.Publish(new NotificationMessage("User online", msg, NotificationType.Info, 5000));
|
Mediator.Publish(new NotificationMessage("User online", msg, NotificationType.Info, TimeSpan.FromSeconds(5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pair.CreateCachedPlayer(dto);
|
pair.CreateCachedPlayer(dto);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
|
|
||||||
public Plugin(DalamudPluginInterface pluginInterface, ICommandManager commandManager, IDataManager gameData,
|
public Plugin(DalamudPluginInterface pluginInterface, ICommandManager commandManager, IDataManager gameData,
|
||||||
IFramework framework, IObjectTable objectTable, IClientState clientState, ICondition condition, IChatGui chatGui,
|
IFramework framework, IObjectTable objectTable, IClientState clientState, ICondition condition, IChatGui chatGui,
|
||||||
IGameGui gameGui, IDtrBar dtrBar, IPluginLog pluginLog, ITargetManager targetManager)
|
IGameGui gameGui, IDtrBar dtrBar, IPluginLog pluginLog, ITargetManager targetManager, INotificationManager notificationManager)
|
||||||
{
|
{
|
||||||
_hostBuilderRunTask = new HostBuilder()
|
_hostBuilderRunTask = new HostBuilder()
|
||||||
.UseContentRoot(pluginInterface.ConfigDirectory.FullName)
|
.UseContentRoot(pluginInterface.ConfigDirectory.FullName)
|
||||||
@@ -150,7 +150,7 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
s.GetRequiredService<ServerConfigurationManager>(), s.GetRequiredService<CacheMonitor>(), s.GetRequiredService<ApiController>(),
|
s.GetRequiredService<ServerConfigurationManager>(), s.GetRequiredService<CacheMonitor>(), s.GetRequiredService<ApiController>(),
|
||||||
s.GetRequiredService<MareMediator>(), s.GetRequiredService<MareConfigService>()));
|
s.GetRequiredService<MareMediator>(), s.GetRequiredService<MareConfigService>()));
|
||||||
collection.AddScoped((s) => new NotificationService(s.GetRequiredService<ILogger<NotificationService>>(),
|
collection.AddScoped((s) => new NotificationService(s.GetRequiredService<ILogger<NotificationService>>(),
|
||||||
s.GetRequiredService<MareMediator>(), pluginInterface.UiBuilder, chatGui, s.GetRequiredService<MareConfigService>()));
|
s.GetRequiredService<MareMediator>(), notificationManager, chatGui, s.GetRequiredService<MareConfigService>()));
|
||||||
collection.AddScoped((s) => new UiSharedService(s.GetRequiredService<ILogger<UiSharedService>>(), s.GetRequiredService<IpcManager>(), s.GetRequiredService<ApiController>(),
|
collection.AddScoped((s) => new UiSharedService(s.GetRequiredService<ILogger<UiSharedService>>(), s.GetRequiredService<IpcManager>(), s.GetRequiredService<ApiController>(),
|
||||||
s.GetRequiredService<CacheMonitor>(), s.GetRequiredService<FileDialogManager>(), s.GetRequiredService<MareConfigService>(), s.GetRequiredService<DalamudUtilService>(),
|
s.GetRequiredService<CacheMonitor>(), s.GetRequiredService<FileDialogManager>(), s.GetRequiredService<MareConfigService>(), s.GetRequiredService<DalamudUtilService>(),
|
||||||
pluginInterface, s.GetRequiredService<Dalamud.Localization>(), s.GetRequiredService<ServerConfigurationManager>(), s.GetRequiredService<MareMediator>()));
|
pluginInterface, s.GetRequiredService<Dalamud.Localization>(), s.GetRequiredService<ServerConfigurationManager>(), s.GetRequiredService<MareMediator>()));
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public record TransientResourceChangedMessage(IntPtr Address) : MessageBase;
|
|||||||
public record HaltScanMessage(string Source) : MessageBase;
|
public record HaltScanMessage(string Source) : MessageBase;
|
||||||
public record ResumeScanMessage(string Source) : MessageBase;
|
public record ResumeScanMessage(string Source) : MessageBase;
|
||||||
public record NotificationMessage
|
public record NotificationMessage
|
||||||
(string Title, string Message, NotificationType Type, uint TimeShownOnScreen = 3000) : MessageBase;
|
(string Title, string Message, NotificationType Type, TimeSpan? TimeShownOnScreen = null) : MessageBase;
|
||||||
public record CreateCacheForObjectMessage(GameObjectHandler ObjectToCreateFor) : MessageBase;
|
public record CreateCacheForObjectMessage(GameObjectHandler ObjectToCreateFor) : MessageBase;
|
||||||
public record ClearCacheForObjectMessage(GameObjectHandler ObjectToCreateFor) : MessageBase;
|
public record ClearCacheForObjectMessage(GameObjectHandler ObjectToCreateFor) : MessageBase;
|
||||||
public record CharacterDataCreatedMessage(CharacterData CharacterData) : SameThreadMessage;
|
public record CharacterDataCreatedMessage(CharacterData CharacterData) : SameThreadMessage;
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ namespace MareSynchronos.Services;
|
|||||||
|
|
||||||
public class NotificationService : DisposableMediatorSubscriberBase
|
public class NotificationService : DisposableMediatorSubscriberBase
|
||||||
{
|
{
|
||||||
|
private readonly INotificationManager _notificationManager;
|
||||||
private readonly IChatGui _chatGui;
|
private readonly IChatGui _chatGui;
|
||||||
private readonly MareConfigService _configurationService;
|
private readonly MareConfigService _configurationService;
|
||||||
private readonly UiBuilder _uiBuilder;
|
|
||||||
|
|
||||||
public NotificationService(ILogger<NotificationService> logger, MareMediator mediator, UiBuilder uiBuilder, IChatGui chatGui, MareConfigService configurationService) : base(logger, mediator)
|
public NotificationService(ILogger<NotificationService> logger, MareMediator mediator, INotificationManager notificationManager, IChatGui chatGui, MareConfigService configurationService) : base(logger, mediator)
|
||||||
{
|
{
|
||||||
_uiBuilder = uiBuilder;
|
_notificationManager = notificationManager;
|
||||||
_chatGui = chatGui;
|
_chatGui = chatGui;
|
||||||
_configurationService = configurationService;
|
_configurationService = configurationService;
|
||||||
|
|
||||||
@@ -108,6 +108,13 @@ public class NotificationService : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
private void ShowToast(NotificationMessage msg)
|
private void ShowToast(NotificationMessage msg)
|
||||||
{
|
{
|
||||||
_uiBuilder.AddNotification(msg.Message ?? string.Empty, "[Mare Synchronos] " + msg.Title, msg.Type, msg.TimeShownOnScreen);
|
_notificationManager.AddNotification(new Dalamud.Interface.ImGuiNotification.Notification()
|
||||||
|
{
|
||||||
|
Content = msg.Message ?? string.Empty,
|
||||||
|
Title = msg.Title,
|
||||||
|
Type = msg.Type,
|
||||||
|
Minimized = false,
|
||||||
|
InitialDuration = msg.TimeShownOnScreen ?? TimeSpan.FromSeconds(3)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ public class PluginWarningNotificationService
|
|||||||
{
|
{
|
||||||
_mediator.Publish(new NotificationMessage("Missing plugins for " + playerName,
|
_mediator.Publish(new NotificationMessage("Missing plugins for " + playerName,
|
||||||
$"Received data for {playerName} that contained information for plugins you have not installed. Install {string.Join(", ", missingPluginsForData)} to experience their character fully.",
|
$"Received data for {playerName} that contained information for plugins you have not installed. Install {string.Join(", ", missingPluginsForData)} to experience their character fully.",
|
||||||
NotificationType.Warning, 10000));
|
NotificationType.Warning, TimeSpan.FromSeconds(10)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,8 @@ using MareSynchronos.Services;
|
|||||||
using MareSynchronos.Services.Mediator;
|
using MareSynchronos.Services.Mediator;
|
||||||
using MareSynchronos.WebAPI;
|
using MareSynchronos.WebAPI;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using SixLabors.ImageSharp;
|
||||||
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
|
|
||||||
namespace MareSynchronos.UI;
|
namespace MareSynchronos.UI;
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ public static class Crypto
|
|||||||
{
|
{
|
||||||
#pragma warning disable SYSLIB0021 // Type or member is obsolete
|
#pragma warning disable SYSLIB0021 // Type or member is obsolete
|
||||||
|
|
||||||
private static readonly Dictionary<string, string> _hashListSHA1 = new(StringComparer.Ordinal);
|
|
||||||
private static readonly Dictionary<(string, ushort), string> _hashListPlayersSHA256 = new();
|
private static readonly Dictionary<(string, ushort), string> _hashListPlayersSHA256 = new();
|
||||||
private static readonly Dictionary<string, string> _hashListSHA256 = new(StringComparer.Ordinal);
|
private static readonly Dictionary<string, string> _hashListSHA256 = new(StringComparer.Ordinal);
|
||||||
private static readonly SHA256CryptoServiceProvider _sha256CryptoProvider = new();
|
private static readonly SHA256CryptoServiceProvider _sha256CryptoProvider = new();
|
||||||
private static readonly SHA1CryptoServiceProvider _sha1CryptoProvider = new();
|
|
||||||
|
|
||||||
public static string GetFileHash(this string filePath)
|
public static string GetFileHash(this string filePath)
|
||||||
{
|
{
|
||||||
@@ -19,11 +17,6 @@ public static class Crypto
|
|||||||
return BitConverter.ToString(cryptoProvider.ComputeHash(File.ReadAllBytes(filePath))).Replace("-", "", StringComparison.Ordinal);
|
return BitConverter.ToString(cryptoProvider.ComputeHash(File.ReadAllBytes(filePath))).Replace("-", "", StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetHash(this string stringToHash)
|
|
||||||
{
|
|
||||||
return GetOrComputeHashSHA1(stringToHash);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetHash256(this (string, ushort) playerToHash)
|
public static string GetHash256(this (string, ushort) playerToHash)
|
||||||
{
|
{
|
||||||
if (_hashListPlayersSHA256.TryGetValue(playerToHash, out var hash))
|
if (_hashListPlayersSHA256.TryGetValue(playerToHash, out var hash))
|
||||||
@@ -46,14 +39,5 @@ public static class Crypto
|
|||||||
return _hashListSHA256[stringToCompute] =
|
return _hashListSHA256[stringToCompute] =
|
||||||
BitConverter.ToString(_sha256CryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(stringToCompute))).Replace("-", "", StringComparison.Ordinal);
|
BitConverter.ToString(_sha256CryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(stringToCompute))).Replace("-", "", StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetOrComputeHashSHA1(string stringToCompute)
|
|
||||||
{
|
|
||||||
if (_hashListSHA1.TryGetValue(stringToCompute, out var hash))
|
|
||||||
return hash;
|
|
||||||
|
|
||||||
return _hashListSHA1[stringToCompute] =
|
|
||||||
BitConverter.ToString(_sha1CryptoProvider.ComputeHash(Encoding.UTF8.GetBytes(stringToCompute))).Replace("-", "", StringComparison.Ordinal);
|
|
||||||
}
|
|
||||||
#pragma warning restore SYSLIB0021 // Type or member is obsolete
|
#pragma warning restore SYSLIB0021 // Type or member is obsolete
|
||||||
}
|
}
|
||||||
@@ -83,11 +83,11 @@ public partial class ApiController
|
|||||||
switch (messageSeverity)
|
switch (messageSeverity)
|
||||||
{
|
{
|
||||||
case MessageSeverity.Error:
|
case MessageSeverity.Error:
|
||||||
Mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Error, 7500));
|
Mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Error, TimeSpan.FromSeconds(7.5)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MessageSeverity.Warning:
|
case MessageSeverity.Warning:
|
||||||
Mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Warning, 7500));
|
Mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Warning, TimeSpan.FromSeconds(7.5)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MessageSeverity.Information:
|
case MessageSeverity.Information:
|
||||||
@@ -96,7 +96,7 @@ public partial class ApiController
|
|||||||
_doNotNotifyOnNextInfo = false;
|
_doNotNotifyOnNextInfo = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Mediator.Publish(new NotificationMessage("Info from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Info, 5000));
|
Mediator.Publish(new NotificationMessage("Info from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Info, TimeSpan.FromSeconds(5)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
|
|||||||
Mediator.Publish(new NotificationMessage("Modified Game Files detected",
|
Mediator.Publish(new NotificationMessage("Modified Game Files detected",
|
||||||
"Mare has detected modified game files in your FFXIV installation. You will be able to connect, but the synchronization functionality might be (partially) broken. " +
|
"Mare has detected modified game files in your FFXIV installation. You will be able to connect, but the synchronization functionality might be (partially) broken. " +
|
||||||
"Exit the game and repair it through XIVLauncher to get rid of this message.",
|
"Exit the game and repair it through XIVLauncher to get rid of this message.",
|
||||||
Dalamud.Interface.Internal.Notifications.NotificationType.Error));
|
Dalamud.Interface.Internal.Notifications.NotificationType.Error, TimeSpan.FromSeconds(15)));
|
||||||
}
|
}
|
||||||
|
|
||||||
await LoadIninitialPairs().ConfigureAwait(false);
|
await LoadIninitialPairs().ConfigureAwait(false);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class ForeverRetryPolicy : IRetryPolicy
|
|||||||
{
|
{
|
||||||
if (!_sentDisconnected)
|
if (!_sentDisconnected)
|
||||||
{
|
{
|
||||||
_mediator.Publish(new NotificationMessage("Connection lost", "Connection lost to server", NotificationType.Warning, 5000));
|
_mediator.Publish(new NotificationMessage("Connection lost", "Connection lost to server", NotificationType.Warning, TimeSpan.FromSeconds(10)));
|
||||||
_mediator.Publish(new DisconnectedMessage());
|
_mediator.Publish(new DisconnectedMessage());
|
||||||
}
|
}
|
||||||
_sentDisconnected = true;
|
_sentDisconnected = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user