Skip to content

Commit

Permalink
[GMH] Melhorias na autenticação com dropbox
Browse files Browse the repository at this point in the history
- Passado a utilizar oauth para realizar login
- Simplificações de código
- Inclusões de comentários nas intefaces
- Renomear algumas classes
  • Loading branch information
luca16s committed Oct 14, 2024
1 parent b97f0e1 commit 5d6e9e5
Show file tree
Hide file tree
Showing 25 changed files with 347 additions and 224 deletions.
15 changes: 15 additions & 0 deletions GameManagementHelper.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "iso.gmh.dropbox", "iso.gmh.
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{43BE6FEE-5A6A-4B8D-91BA-573D6B20CD22}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iso.gmh.steam", "iso.gmh.steam\iso.gmh.steam.csproj", "{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -57,11 +59,24 @@ Global
{C397732E-9D13-412E-B108-A936E2EC386A}.Release|x64.Build.0 = Release|x64
{C397732E-9D13-412E-B108-A936E2EC386A}.Release|x86.ActiveCfg = Release|Any CPU
{C397732E-9D13-412E-B108-A936E2EC386A}.Release|x86.Build.0 = Release|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Debug|x64.ActiveCfg = Debug|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Debug|x64.Build.0 = Debug|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Debug|x86.ActiveCfg = Debug|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Debug|x86.Build.0 = Debug|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Release|Any CPU.Build.0 = Release|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Release|x64.ActiveCfg = Release|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Release|x64.Build.0 = Release|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Release|x86.ActiveCfg = Release|Any CPU
{0B3213E6-17CB-4DA1-8E85-FB26A16C3AF1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B5B1BCEE-BD03-4AC2-BB81-E8ACB47BCC7E}
SolutionGuid = {CDC55326-F82A-4416-9DC2-206C5AE2BD3C}
EndGlobalSection
EndGlobal
25 changes: 23 additions & 2 deletions iso.gmh.core/Interfaces/IBackupStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,34 @@

public interface IBackupStrategy
{
/// <summary>
/// Retorna a extensão do arquivo a ser salvo.
/// </summary>
/// <returns>
/// Texto com a extensão do arquivo.
/// </returns>
string GetFileExtension();

/// <summary>
/// Prepara o backup de um jogo selecionado.
/// </summary>
/// <param name="game">
/// Jogo ao qual o backup será feito.
/// </param>
void PrepareBackup(
GameInformationModel gameInformation
Game game
);

/// <summary>
/// Gera o backup do jogo selecionado.
/// </summary>
/// <param name="game">
/// Jogo ao qual o backup será feito.
/// </param>
/// <returns>
/// Retorna a stream do jogo após o backup realizado.
/// </returns>
FileStream GenerateBackup(
GameInformationModel gameInformation
Game game
);
}
80 changes: 74 additions & 6 deletions iso.gmh.core/Interfaces/ICloudOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,83 @@

public interface ICloudOperations
{
Task<bool> DeleteSave(string path);
/// <summary>
/// Apaga arquivo do serviço de armazenamento na nuvem.
/// </summary>
/// <param name="path">
/// Local do arquivo a ser apagado.
/// </param>
/// <returns>
/// True caso tenha apagado e Falso caso não tenha sido apagado.
/// </returns>
Task<bool> DeleteSave(
string path
);

Task<bool> CreateFolder(string path);
/// <summary>
/// Cria uma pasta no serviço de armazenamento na nuvem.
/// </summary>
/// <param name="path">
/// </param>
/// <returns>
/// </returns>
Task<bool> CreateFolder(
string path
);

Task<bool> CheckFolderExistence(string folderName);
/// <summary>
/// Valida se no serviço de armazenamento na nuvem já existe uma pasta com mesmo nome.
/// </summary>
/// <param name="folderName">
/// Nome da pasta.
/// </param>
/// <returns>
/// True se existente e Falso se não existe.
/// </returns>
Task<bool> CheckFolderExistence(
string folderName
);

Task<bool> DownloadSaveData(GameInformationModel gameInformation);
/// <summary>
/// Realiza o download do save no serviço da nuvem.
/// </summary>
/// <param name="game">
/// Jogo selecionado.
/// </param>
/// <returns>
/// True se o save pode ser recuperado e Falso caso não tenha sido recuperado.
/// </returns>
Task<bool> DownloadSaveData(
Game game
);

Task<bool> UploadSaveData(GameInformationModel gameInformation, bool overwriteSave);
/// <summary>
/// Realiza o upload do save para o serviço de armazenamento na nuvem.
/// </summary>
/// <param name="game">
/// Jogo selecionado.
/// </param>
/// <param name="overwrite">
/// Indica se save pode ser sobrescrito.
/// </param>
/// <returns>
/// True caso tenha sido salvo e Falso caso não tenha sido salvo.
/// </returns>
Task<bool> UploadSaveData(
Game game,
bool overwrite = false
);

Task<IEnumerable<(string name, string path)>> GetSavesList(GameInformationModel gameInformation);
/// <summary>
/// Busca a lista de saves armazenados no serviço da nuvem.
/// </summary>
/// <param name="game">
/// Jogo selecionado.
/// </param>
/// <returns>
/// Lista de arquivos salvos.
/// </returns>
Task<IEnumerable<(string name, string path)>> GetSavesList(
Game game
);
}
23 changes: 20 additions & 3 deletions iso.gmh.core/Interfaces/IConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,26 @@

public interface IConnection<TClient> where TClient : class
{
public TClient Client { get; }
public TClient Client { get; set; }

Task ConnectAsync(Secrets secrets);
/// <summary>
/// Realiza a conexão do o serviço de nuvem.
/// </summary>
/// <param name="secrets">
/// User secrets para conexão.
/// </param>
/// <returns>
/// O client conectado.
/// </returns>
Task<TClient> ConnectAsync(
Secrets secrets
);

Task<UserModel> GetUserInformation();
/// <summary>
/// Busca as informações do usuário.
/// </summary>
/// <returns>
/// Informações do Usuário.
/// </returns>
Task<User> GetUserInformation();
}
4 changes: 3 additions & 1 deletion iso.gmh.core/Interfaces/IFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

public interface IFactory<T, out TReturn>
{
TReturn Create(T type);
TReturn Create(
T type
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

using KapiCoreLib.Extensions;

public class GameInformationModel
public class Game
{
private readonly GameInformationModelValidatons ValidationRules = new();

Expand Down
15 changes: 15 additions & 0 deletions iso.gmh.core/Models/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace iso.gmh.Core.Models;

using System.Text.Json.Serialization;

public class User(
string userName,
string email
)
{
[JsonPropertyName("givenName")]
public string UserName { get; set; } = userName;

[JsonPropertyName("userPrincipalName")]
public string Email { get; set; } = email;
}
21 changes: 0 additions & 21 deletions iso.gmh.core/Models/UserModel.cs

This file was deleted.

4 changes: 2 additions & 2 deletions iso.gmh.core/Services/BakBackupStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class BakBackupStrategy : IBackupStrategy
{
public string GetFileExtension() => ESaveType.BAK.Description();

public FileStream GenerateBackup(GameInformationModel gameInformation)
public FileStream GenerateBackup(Game gameInformation)
{
if (gameInformation == null)
return null;
Expand All @@ -32,7 +32,7 @@ public FileStream GenerateBackup(GameInformationModel gameInformation)
return new FileStream(Path.Combine(Path.GetTempPath(), saveName), FileMode.Open, FileAccess.Read);
}

public void PrepareBackup(GameInformationModel gameInformation)
public void PrepareBackup(Game gameInformation)
{
if (gameInformation == null)
return;
Expand Down
4 changes: 2 additions & 2 deletions iso.gmh.core/Services/ZipBackupStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ZipBackupStrategy : IBackupStrategy
{
public string GetFileExtension() => ESaveType.ZIP.Description();

public FileStream GenerateBackup(GameInformationModel gameInformation)
public FileStream GenerateBackup(Game gameInformation)
{
if (gameInformation == null)
return null;
Expand All @@ -28,7 +28,7 @@ public FileStream GenerateBackup(GameInformationModel gameInformation)
return new FileStream(Path.Combine(Path.GetTempPath(), saveName), FileMode.Open, FileAccess.Read);
}

public void PrepareBackup(GameInformationModel gameInformation)
public void PrepareBackup(Game gameInformation)
{
if (gameInformation == null)
return;
Expand Down
2 changes: 1 addition & 1 deletion iso.gmh.core/Validations/GameInformationModelValidatons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using iso.gmh.Core.Models;
using iso.gmh.Core.Utils;

public class GameInformationModelValidatons : AbstractValidator<GameInformationModel>
public class GameInformationModelValidatons : AbstractValidator<Game>
{
public GameInformationModelValidatons()
{
Expand Down
8 changes: 4 additions & 4 deletions iso.gmh.core/iso.gmh.core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifiers>win-x86</RuntimeIdentifiers>
<Authors>Îakaré Software'oka</Authors>
<Product>Game Management Helper</Product>
Expand Down Expand Up @@ -40,13 +40,13 @@
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139">
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.143">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
Expand Down
Loading

0 comments on commit 5d6e9e5

Please sign in to comment.