コード例 #1
0
ファイル: OptionsWindow.axaml.cs プロジェクト: prueker/MPF
 /// <summary>
 /// Handler for RedumpLoginTestButton Click event
 /// </summary>
 private void OnRedumpTestClick(object sender, RoutedEventArgs e)
 {
     using (RedumpWebClient wc = new RedumpWebClient())
     {
         if (wc.Login(this.Find <TextBox>("RedumpUsernameTextBox").Text, this.Find <TextBox>("RedumpPasswordTextBox").Text))
         {
             new Window()
             {
                 Title                 = "Success",
                 Content               = "Redump login credentials accepted!",
                 SizeToContent         = SizeToContent.WidthAndHeight,
                 WindowStartupLocation = WindowStartupLocation.CenterScreen,
             }.ShowDialog(this);
         }
         else
         {
             new Window()
             {
                 Title                 = "Failure",
                 Content               = "Redump login credentials denied!",
                 SizeToContent         = SizeToContent.WidthAndHeight,
                 WindowStartupLocation = WindowStartupLocation.CenterScreen,
             }.ShowDialog(this);
         }
     }
 }
コード例 #2
0
        public static void Main(string[] args)
        {
            // Try processing the standalone arguments
            if (ProcessStandaloneArguments(args))
                return;

            // Try processing the common arguments
            (bool success, MediaType mediaType, RedumpSystem? knownSystem) = ProcessCommonArguments(args);
            if (!success)
                return;

            // Loop through and process options
            (Options options, string path, int startIndex) = OptionsLoader.LoadFromArguments(args, startIndex: 2);

            // Make new Progress objects
            var resultProgress = new Progress<Result>();
            resultProgress.ProgressChanged += ProgressUpdated;
            var protectionProgress = new Progress<ProtectionProgress>();
            protectionProgress.ProgressChanged += ProgressUpdated;

            // Validate the supplied credentials
            (bool? _, string message) = RedumpWebClient.ValidateCredentials(options?.RedumpUsername, options?.RedumpPassword);
            if (!string.IsNullOrWhiteSpace(message))
                Console.WriteLine(message);

            // Loop through all the rest of the args
            for (int i = startIndex; i < args.Length; i++)
            {
                // Check for a file
                if (!File.Exists(args[i].Trim('"')))
                {
                    DisplayHelp($"{args[i].Trim('"')} does not exist");
                    return;
                }

                // Get the full file path
                string filepath = Path.GetFullPath(args[i].Trim('"'));

                // Now populate an environment
                Drive drive = null;
                if (!string.IsNullOrWhiteSpace(path))
                    drive = Drive.Create(null, path);

                var env = new DumpEnvironment(options, "", filepath, drive, knownSystem, mediaType, null);

                // Finally, attempt to do the output dance
                var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress).ConfigureAwait(false).GetAwaiter().GetResult();
                Console.WriteLine(result.Message);
            }
        }
コード例 #3
0
 /// <summary>
 /// Test Redump credentials for validity
 /// </summary>
 private void OnRedumpTestClick(object sender, EventArgs e)
 {
     using (RedumpWebClient wc = new RedumpWebClient())
     {
         if (wc.Login(RedumpUsernameTextBox.Text, RedumpPasswordBox.Password))
         {
             System.Windows.MessageBox.Show("Redump login credentials accepted!", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else
         {
             System.Windows.MessageBox.Show("Redump login credentials denied!", "Failure", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }
コード例 #4
0
 /// <summary>
 /// Test Redump login credentials
 /// </summary>
 private void TestRedumpLogin()
 {
     (bool?success, string message) = RedumpWebClient.ValidateCredentials(Parent.RedumpUsernameTextBox.Text, Parent.RedumpPasswordBox.Password);
     if (success == true)
     {
         CustomMessageBox.Show(Parent, message, "Success", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     else if (success == false)
     {
         CustomMessageBox.Show(Parent, message, "Failure", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else
     {
         CustomMessageBox.Show(Parent, message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
コード例 #5
0
 /// <summary>
 /// Test Redump login credentials
 /// </summary>
 private void TestRedumpLogin()
 {
     using (RedumpWebClient wc = new RedumpWebClient())
     {
         bool?loggedIn = wc.Login(Parent.RedumpUsernameTextBox.Text, Parent.RedumpPasswordBox.Password);
         if (loggedIn == true)
         {
             CustomMessageBox.Show(Parent, "Redump login credentials accepted!", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else if (loggedIn == false)
         {
             CustomMessageBox.Show(Parent, "Redump login credentials denied!", "Failure", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         else
         {
             CustomMessageBox.Show(Parent, "Error validating credentials!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }
コード例 #6
0
ファイル: Tools.cs プロジェクト: prueker/MPF
        /// <summary>
        /// Check for a new MPF version
        /// </summary>
        /// <returns>
        /// Bool representing if the values are different.
        /// String representing the message to display the the user.
        /// String representing the new release URL.
        /// </returns>
        public static (bool different, string message, string url) CheckForNewVersion()
        {
            // Get current assembly version
            string version = GetCurrentVersion();

            // Get the latest tag from GitHub
            using (var client = new RedumpWebClient())
            {
                (string tag, string url) = client.GetRemoteVersionAndUrl();
                bool different = version != tag;

                string message = $"Local version: {version}"
                                 + $"{Environment.NewLine}Remote version: {tag}"
                                 + (different
                        ? $"{Environment.NewLine}The update URL has been added copied to your clipboard"
                        : $"{Environment.NewLine}You have the newest version!");

                return(different, message, url);
            }
        }
コード例 #7
0
ファイル: Tools.cs プロジェクト: acdvorak/MPF
        /// <summary>
        /// Check for a new MPF version
        /// </summary>
        /// <returns>
        /// Bool representing if the values are different.
        /// String representing the message to display the the user.
        /// String representing the new release URL.
        /// </returns>
        public static (bool different, string message, string url) CheckForNewVersion()
        {
            // Get current assembly version
            var    assemblyVersion = Assembly.GetEntryAssembly().GetName().Version;
            string version         = $"{assemblyVersion.Major}.{assemblyVersion.Minor}" + (assemblyVersion.Build != 0 ? $".{assemblyVersion.Build}" : string.Empty);

            // Get the latest tag from GitHub
            using (var client = new RedumpWebClient())
            {
                (string tag, string url) = client.GetRemoteVersionAndUrl();
                bool different = version != tag;

                string message = $"Local version: {version}"
                                 + $"{Environment.NewLine}Remote version: {tag}"
                                 + (different
                        ? $"{Environment.NewLine}The update URL has been added copied to your clipboard"
                        : $"{Environment.NewLine}You have the newest version!");

                return(different, message, url);
            }
        }
コード例 #8
0
        public static void Main(string[] args)
        {
            // Help options
            if (args.Length == 0 || args[0] == "-h" || args[0] == "-?")
            {
                DisplayHelp();
                return;
            }

            // List options
            if (args[0] == "-lm" || args[0] == "--listmedia")
            {
                ListMediaTypes();
                Console.ReadLine();
                return;
            }
            else if (args[0] == "-lp" || args[0] == "--listprograms")
            {
                ListPrograms();
                Console.ReadLine();
                return;
            }
            else if (args[0] == "-ls" || args[0] == "--listsystems")
            {
                ListSystems();
                Console.ReadLine();
                return;
            }

            // Normal operation check
            if (args.Length < 3)
            {
                DisplayHelp("Invalid number of arguments");
                return;
            }

            // Check the MediaType
            var mediaType = EnumConverter.ToMediaType(args[0].Trim('"'));
            if (mediaType == MediaType.NONE)
            {
                DisplayHelp($"{args[0]} is not a recognized media type");
                return;
            }

            // Check the RedumpSystem
            var knownSystem = Extensions.ToRedumpSystem(args[1].Trim('"'));
            if (knownSystem == null)
            {
                DisplayHelp($"{args[1]} is not a recognized system");
                return;
            }

            // Default values
            string username = null, password = null;
            string internalProgram = "DiscImageCreator";
            string path = string.Empty;
            bool scan = false, compress = false;

            // Loop through and process options
            int startIndex = 2;
            for (; startIndex < args.Length; startIndex++)
            {
                // Redump login
                if (args[startIndex].StartsWith("-c=") || args[startIndex].StartsWith("--credentials="))
                {
                    string[] credentials = args[startIndex].Split('=')[1].Split(';');
                    username = credentials[0];
                    password = credentials[1];
                }
                else if (args[startIndex] == "-c" || args[startIndex] == "--credentials")
                {
                    username = args[startIndex + 1];
                    password = args[startIndex + 2];
                    startIndex += 2;
                }

                // Use specific program
                else if (args[startIndex].StartsWith("-u=") || args[startIndex].StartsWith("--use="))
                {
                    internalProgram = args[startIndex].Split('=')[1];
                }
                else if (args[startIndex] == "-u" || args[startIndex] == "--use")
                {
                    internalProgram = args[startIndex + 1];
                    startIndex++;
                }

                // Use a device path for physical checks
                else if (args[startIndex].StartsWith("-p=") || args[startIndex].StartsWith("--path="))
                {
                    path = args[startIndex].Split('=')[1];
                }
                else if (args[startIndex] == "-p" || args[startIndex] == "--path")
                {
                    path = args[startIndex + 1];
                    startIndex++;
                }

                // Scan for protection (requires device path)
                else if (args[startIndex].StartsWith("-s") || args[startIndex].StartsWith("--scan"))
                {
                    scan = true;
                }

                // Compress log and extraneous files
                else if (args[startIndex].StartsWith("-z") || args[startIndex].StartsWith("--zip"))
                {
                    compress = true;
                }

                // Default, we fall out
                else
                {
                    break;
                }
            }

            // Make new Progress objects
            var resultProgress = new Progress<Result>();
            resultProgress.ProgressChanged += ProgressUpdated;
            var protectionProgress = new Progress<ProtectionProgress>();
            protectionProgress.ProgressChanged += ProgressUpdated;

            // If credentials are invalid, alert the user
            if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password))
            {
                using (RedumpWebClient wc = new RedumpWebClient())
                {
                    bool? loggedIn = wc.Login(username, password);
                    if (loggedIn == true)
                        Console.WriteLine("Redump username and password accepted!");
                    else if (loggedIn == false)
                        Console.WriteLine("Redump username and password denied!");
                    else
                        Console.WriteLine("An error occurred validating your crendentials!");
                }
            }

            // Loop through all the rest of the args
            for (int i = startIndex; i < args.Length; i++)
            {
                // Check for a file
                if (!File.Exists(args[i].Trim('"')))
                {
                    DisplayHelp($"{args[i].Trim('"')} does not exist");
                    return;
                }

                // Get the full file path
                string filepath = Path.GetFullPath(args[i].Trim('"'));

                // Now populate an environment
                var options = new Options
                {
                    InternalProgram = EnumConverter.ToInternalProgram(internalProgram),
                    ScanForProtection = scan && !string.IsNullOrWhiteSpace(path),
                    PromptForDiscInformation = false,
                    ShowDiscEjectReminder = false,
                    CompressLogFiles = compress,

                    RedumpUsername = username,
                    RedumpPassword = password,
                };

                Drive drive = null;
                if (!string.IsNullOrWhiteSpace(path))
                    drive = new Drive(null, new DriveInfo(path));

                var env = new DumpEnvironment(options, "", filepath, drive, knownSystem, mediaType, null);

                // Finally, attempt to do the output dance
                var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress).ConfigureAwait(false).GetAwaiter().GetResult();
                Console.WriteLine(result.Message);
            }
        }