Skip to content

Commit

Permalink
Merge pull request #8 from SeaDevTeam/bugFix3
Browse files Browse the repository at this point in the history
Encrypted json settings
  • Loading branch information
NoobNotFound authored Jul 7, 2022
2 parents 622aae7 + 931b9b9 commit d6c3407
Show file tree
Hide file tree
Showing 20 changed files with 1,018 additions and 1,057 deletions.
2 changes: 1 addition & 1 deletion Package/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Identity
Name="SeaDevs.Launcher.UWP"
Publisher="CN=SeaDev Team"
Version="0.4.5.0" />
Version="0.4.7.0" />

<Properties>
<DisplayName>SD Launcher</DisplayName>
Expand Down
2 changes: 1 addition & 1 deletion Package/Package.wapproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
<AppInstallerUri>C:\</AppInstallerUri>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
</PropertyGroup>
Expand Down
120 changes: 65 additions & 55 deletions SDLauncher UWP/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Toolkit.Uwp.Helpers;
using CmlLib.Core.Auth;
using Microsoft.Toolkit.Uwp.Helpers;
using SDLauncher_UWP.Helpers;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -37,9 +38,9 @@ public App()
this.InitializeComponent();
this.Suspending += OnSuspending;
}
SettingsDataManager settings = new SettingsDataManager();
public static event EventHandler<AppServiceTriggerDetails> AppServiceConnected = delegate { };
public static AppServiceConnection Connection { get; private set; }
public bool Loaded = false;
public BackgroundTaskDeferral AppServiceDeferral { get; private set; }

/// <summary>
Expand All @@ -49,43 +50,60 @@ public App()
/// <param name="e">Details about the launch request and process.</param>
protected async override void OnLaunched(LaunchActivatedEventArgs e)
{
if (!SystemInformation.Instance.IsFirstRun)
if (SystemInformation.Instance.IsFirstRun)
{
try
{
await ApplicationData.Current.RoamingFolder.GetFileAsync("settings.xml");
}
catch
{
await settings.CreateSettingsFile(false);
}
try
{
await settings.LoadSettingsFile();
}
catch
{
vars.CurrentRam = 2048;
try
{
await settings.CreateSettingsFile(false);
await settings.LoadSettingsFile();
}
catch { }
}
ApplicationData.Current.RoamingSettings.Values["IsInAppSettings"] = false.ToString();
}
bool IsInAppSettings = false;
try
{
IsInAppSettings = bool.Parse(ApplicationData.Current.RoamingSettings.Values["IsInAppSettings"] as string);
}
catch
{
ApplicationData.Current.RoamingSettings.Values["IsInAppSettings"] = false.ToString();
}
if (IsInAppSettings == false)
{
await SettingsManager.LoadSettings();
}
else
{
vars.CurrentRam = 2048;
try
SettingsManager.DeserializeSettings(ApplicationData.Current.RoamingSettings.Values["InAppSettings"] as string);
}
Frame rootFrame = Window.Current.Content as Frame;
if (vars.autoLog && vars.Accounts != null)
{
foreach (var item in vars.Accounts)
{
await settings.CreateSettingsFile(false);
await settings.LoadSettingsFile();
if (item.Last)
{
if (item.Type != null)
{
if (item.Type == "Offline")
{
if (item.UserName == null)
{
vars.session = null;
}
else
{
vars.session = MSession.GetOfflineSession(item.UserName);
}
}
else
{
if (item.UserName != null && item.AccessToken != null && item.UUID != null)
{
vars.session = new MSession(item.UserName, item.AccessToken, item.UUID);
}
}
}
vars.CurrentAccountCount = item.Count;
}
}
catch { }
Loaded = true;
}
Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
Expand Down Expand Up @@ -148,28 +166,7 @@ protected async override void OnActivated(IActivatedEventArgs args)
if (args.Kind == ActivationKind.CommandLineLaunch)
{

if (!SystemInformation.Instance.IsFirstRun)
{
try
{
await ApplicationData.Current.RoamingFolder.GetFileAsync("settings.xml");
}
catch
{
await settings.CreateSettingsFile(false);
}
await settings.LoadSettingsFile();
}
else
{
vars.CurrentRam = 2048;
try
{
await settings.CreateSettingsFile(false);
await settings.LoadSettingsFile();
}
catch { }
}
await SettingsManager.LoadSettings();
Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
Expand All @@ -192,7 +189,20 @@ protected async override void OnActivated(IActivatedEventArgs args)
}
private async void App_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
{
await settings.CreateSettingsFile(false);
e.Handled = true;
if (!vars.closing && Loaded)
{
vars.closing = true;
if (bool.Parse(ApplicationData.Current.RoamingSettings.Values["IsInAppSettings"] as string) == false)
{
await SettingsManager.SaveSettings();
}
else
{
ApplicationData.Current.RoamingSettings.Values["InAppSettings"] = await SettingsManager.SerializeSettings();
}
}
Application.Current.Exit();
}

/// <summary>
Expand Down
Loading

0 comments on commit d6c3407

Please sign in to comment.