1
0
mirror of https://github.com/xCryptic/MegaKeep.git synced 2024-11-21 17:42:30 +01:00

Cleaned code, Updated .Net Framework and Updated Readme

thanks to the contributors jogerj & CrazyOldWizard
This commit is contained in:
Cryptic 2021-01-18 22:22:03 -05:00
parent b76965bf63
commit efc0889d78
6 changed files with 40 additions and 32 deletions

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MegaKeep.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="MegaKeep.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<userSettings>
<MegaKeep.Properties.Settings>
<setting name="Location" serializeAs="String">
<value />
<value/>
</setting>
</MegaKeep.Properties.Settings>
</userSettings>
</configuration>
</configuration>

View File

@ -12,24 +12,23 @@ namespace MegaKeep
{
private string _local = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
private string[] commandlineArgs = { };
public MegaKeep()
{
InitializeComponent();
}
public MegaKeep(string[] args)
{
InitializeComponent();
if (args.Length > 0)
if (args.Length == 0)
return;
commandlineArgs = args;
var txtFileIndex = Array.IndexOf(args, "--txtFile") + 1;
var txtFile = args[txtFileIndex];
if (File.Exists(txtFile))
{
commandlineArgs = args;
var txtFileIndex = Array.IndexOf(args, "--txtFile") + 1;
var txtFile = args[txtFileIndex];
if (File.Exists(txtFile))
{
Properties.Settings.Default.Location = txtFile;
Properties.Settings.Default.Save();
txtPath.Text = txtFile;
}
Properties.Settings.Default.Location = txtFile;
Properties.Settings.Default.Save();
txtPath.Text = txtFile;
}
}
@ -40,7 +39,7 @@ namespace MegaKeep
// first make sure megacmd is found
if (!File.Exists(_local + "\\MEGAcmd\\mega-login.bat"))
{
Log("mega-login.bat was not found, please install it to the default dirctory: https://mega.nz/cmd");
Log("mega-login.bat was not found, please install it to the default directory: https://mega.nz/cmd");
return;
}
@ -67,7 +66,8 @@ namespace MegaKeep
// run the processes in a task so it doesn't freeze the ui
await Task.Run(() => Work(lines));
if (commandlineArgs.Contains("--cli"))// if running in cli mode, closes window after running work.
if (commandlineArgs.Contains("--cli")) // if running in cli mode, closes window after running work
this.Close();
}
@ -86,7 +86,7 @@ namespace MegaKeep
}
};
Log("Logging in to " + user + "...");
Log("Logging into " + user + "...");
login.Start();
var result = login.StandardOutput.ReadToEnd();
@ -95,7 +95,7 @@ namespace MegaKeep
if (login.HasExited)
return result;
else
return "Unable to exit the process";
return "Unable to exit the process";
}
private string Logout()
@ -127,7 +127,6 @@ namespace MegaKeep
if (res == "Logging out..." + Environment.NewLine)
{
// success
result = "Success";
break;
}
@ -148,6 +147,7 @@ namespace MegaKeep
foreach (var line in lines)
{
var info = line.Split(':');
// check line format
if (info.Length != 2)
{
@ -155,6 +155,7 @@ namespace MegaKeep
Log("Colon (:) seperator not found. Error: " + line);
continue;
}
var user = info[0];
var pass = info[1];
@ -174,7 +175,7 @@ namespace MegaKeep
// login was successful
Log("Login succeeded. Logging out...");
}
else if (loginResult.Contains("Login failed"))
else if (loginResult.Contains("Failed"))
{
Log("Failed: " + loginResult);
break; // just move on to the next account
@ -234,7 +235,7 @@ namespace MegaKeep
private void Log(string txt)
{
this.Invoke((MethodInvoker) delegate
this.Invoke((MethodInvoker)delegate
{
var time = "[" + DateTime.Now.ToString("hh:mm:ss tt") + "] ";
@ -246,9 +247,8 @@ namespace MegaKeep
{
// if started with arg "--cli" simulate button click in UI
if (commandlineArgs.Contains("--cli"))
{
btnRun.PerformClick();
}
txtPath.Text = Properties.Settings.Default.Location;
}

View File

@ -8,10 +8,11 @@
<OutputType>WinExe</OutputType>
<RootNamespace>MegaKeep</RootNamespace>
<AssemblyName>MegaKeep</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>

View File

@ -19,7 +19,7 @@ namespace MegaKeep.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {

View File

@ -12,7 +12,7 @@ namespace MegaKeep.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

View File

@ -15,6 +15,13 @@ You must have MEGAcmd installed and running on your machine. You can download th
Create a text file (.txt) of all your mega accounts and passwords in a `user:pass` format with one account per line. Then locate that file and run the program.
## Command Line
You are also able to start the program via command line.
`--cli` will auto-click the run button and run whatever file is already loaded
`--txtFile "C:\path\to\txtfile.txt"` will load the text file into the program
## Contributing
When making a pull request, please provide a thorough explanation of what you added/fixed. Suggestions are welcome in the form of issues.