Skip to content

Commit

Permalink
Merge pull request #402 from Tichau/integration
Browse files Browse the repository at this point in the history
File Converter release v2.0.2
  • Loading branch information
Tichau authored Mar 11, 2024
2 parents 58228da + 4d05ddb commit 0bc1f55
Show file tree
Hide file tree
Showing 9 changed files with 652 additions and 63 deletions.
100 changes: 49 additions & 51 deletions Application/FileConverter/Application.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public partial class Application : System.Windows.Application
{
Major = 2,
Minor = 0,
Patch = 1,
Patch = 2,
};

private bool needToRunConversionThread;
Expand Down Expand Up @@ -226,7 +226,7 @@ private void Initialize()
// Retrieve arguments.
Debug.Log("Retrieve arguments...");
string[] args = Environment.GetCommandLineArgs();

// Log arguments.
for (int index = 0; index < args.Length; index++)
{
Expand All @@ -243,10 +243,7 @@ private void Initialize()
return;
}

ISettingsService settingsService = Ioc.Default.GetRequiredService<ISettingsService>();

// Parse arguments.
bool quitAfterStartup = false;
List<string> filePaths = new List<string>();
string conversionPresetName = null;
for (int index = 1; index < args.Length; index++)
Expand All @@ -265,60 +262,59 @@ private void Initialize()
switch (parameterTitle)
{
case "post-install-init":
ISettingsService settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
if (!settingsService.PostInstallationInitialization())
{
Debug.LogError(errorCode: 0x0F, $"Failed to execute post install initialization.");
}

quitAfterStartup = true;
break;
Application.AskForShutdown();
return;

case "register-shell-extension":
{
quitAfterStartup = true;

if (index >= args.Length - 1)
{
Debug.LogError(errorCode: 0x0B, $"Invalid format.");
break;
}
if (index >= args.Length - 1)
{
Debug.LogError(errorCode: 0x0B, $"Invalid format.");
break;
}

string shellExtensionPath = args[index + 1];
index++;
string shellExtensionPath = args[index + 1];
index++;

if (!Helpers.RegisterShellExtension(shellExtensionPath))
{
Debug.LogError(errorCode: 0x0C, $"Failed to register shell extension {shellExtensionPath}.");
}
if (!Helpers.RegisterShellExtension(shellExtensionPath))
{
Debug.LogError(errorCode: 0x0C, $"Failed to register shell extension {shellExtensionPath}.");
}

break;
}
Application.AskForShutdown();
return;
}

case "unregister-shell-extension":
{
quitAfterStartup = true;

if (index >= args.Length - 1)
{
Debug.LogError(errorCode: 0x0D, $"Invalid format.");
break;
}
if (index >= args.Length - 1)
{
Debug.LogError(errorCode: 0x0D, $"Invalid format.");
break;
}

string shellExtensionPath = args[index + 1];
index++;

if (!Helpers.UnregisterExtension(shellExtensionPath))
{
Debug.LogError(errorCode: 0x0E, $"Failed to unregister shell extension {shellExtensionPath}.");
}
string shellExtensionPath = args[index + 1];
index++;

break;
}
if (!Helpers.UnregisterExtension(shellExtensionPath))
{
Debug.LogError(errorCode: 0x0E, $"Failed to unregister shell extension {shellExtensionPath}.");
}

Application.AskForShutdown();
return;
}

case "version":
Console.WriteLine(ApplicationVersion.ToString());
quitAfterStartup = true;
break;
Application.AskForShutdown();
return;

case "settings":
this.showSettings = true;
Expand All @@ -327,9 +323,9 @@ private void Initialize()
case "conversion-preset":
if (index >= args.Length - 1)
{
quitAfterStartup = true;
Debug.LogError(errorCode: 0x01, $"Invalid format.");
break;
Application.AskForShutdown();
return;
}

conversionPresetName = args[index + 1];
Expand All @@ -339,9 +335,9 @@ private void Initialize()
case "input-files":
if (index >= args.Length - 1)
{
quitAfterStartup = true;
Debug.LogError(errorCode: 0x02, $"Invalid format.");
break;
Application.AskForShutdown();
return;
}

string fileListPath = args[index + 1];
Expand All @@ -358,8 +354,9 @@ private void Initialize()
}
catch (Exception exception)
{
quitAfterStartup = true;
Debug.LogError(errorCode: 0x03, $"Can't read input files list: {exception}");
Application.AskForShutdown();
return;
}

index++;
Expand All @@ -383,20 +380,21 @@ private void Initialize()
}
}

this.RunConversions(filePaths, conversionPresetName);
}

private void RunConversions(List<string> filePaths, string conversionPresetName)
{
ISettingsService settingsService = Ioc.Default.GetRequiredService<ISettingsService>();
if (settingsService.Settings == null)
{
Debug.LogError(errorCode: 0x04, "Can't load File Converter settings. The application will now shutdown, if you want to fix the problem yourself please edit or delete the file: C:\\Users\\UserName\\AppData\\Local\\FileConverter\\Settings.user.xml.");
quitAfterStartup = true;
}

if (quitAfterStartup)
{
Application.AskForShutdown();
return;
}

Debug.Assert(Debug.FirstErrorCode == 0, "An error happened during the initialization.");

// Check for upgrade.
if (settingsService.Settings.CheckUpgradeAtStartup)
{
Expand Down
1 change: 1 addition & 0 deletions Application/FileConverter/FileConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@
</Compile>
<EmbeddedResource Include="Properties\Resources.ar-EG.resx" />
<EmbeddedResource Include="Properties\Resources.de-DE.resx" />
<EmbeddedResource Include="Properties\Resources.he-IL.resx" />
<EmbeddedResource Include="Properties\Resources.hi-IN.resx" />
<EmbeddedResource Include="Properties\Resources.es-ES.resx" />
<EmbeddedResource Include="Properties\Resources.en.resx">
Expand Down
Loading

0 comments on commit 0bc1f55

Please sign in to comment.