private void searchRegistry() { if (worker.CancellationPending) { return; } TranslatingProgressHandler.setTranslatedMessage("AnalyzingLocalMachineRegistry"); outputLine("Local Machine Registry Entries: "); RegistryKey look_here = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE"); registryTraveller(look_here); if (worker.CancellationPending) { return; } TranslatingProgressHandler.setTranslatedMessage("AnalyzingCurrentUserRegistry"); outputLine("Current User Registry Entries: "); ProgressHandler.value++; look_here = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software"); registryTraveller(look_here); }
public static void loadXml() { TranslatingProgressHandler.setTranslatedMessage("LoadingGameXmls"); supress_duplicate_game_warnings = false; xml = new GameXmlFiles(); model.Clear(); if (xml.Entries.Count > 0) { TranslatingProgressHandler.setTranslatedMessage("LoadingGamesData"); foreach (GameSaveInfo.Game game in xml.Entries) { foreach (GameVersion version in game.Versions) { try { GameEntry entry; if (version is CustomGameVersion) { entry = new CustomGameEntry(version as CustomGameVersion); } else { entry = new GameEntry(version); } addGame(entry); } catch (Exception e) { TranslatingMessageHandler.SendException(e); } } } } }
protected virtual void doWork(object sender, DoWorkEventArgs e) { ProgressHandler.state = ProgressState.Indeterminate; if (!initialized) { TranslatingProgressHandler.setTranslatedMessage("LoadingSettings"); if (!settings.IsReady) { initialized = false; TranslatingMessageHandler.SendError("CriticalSettingsFailure"); return; } Core.locations.setup(); settings.PropertyChanged += new PropertyChangedEventHandler(settings_PropertyChanged); monitor = new Monitor.Monitor(); TranslatingProgressHandler.setTranslatedMessage("ValidatingBackupPath"); if (settings.IsBackupPathSet && (!PermissionsHelper.isReadable(settings.backup_path) || !PermissionsHelper.isWritable(settings.backup_path))) settings.clearBackupPath(); if (!locations.ready) return; //task = new Task.TaskHandler(); initialized = true; } //ProgressHandler.progress_state = ProgressState.Normal; }
private static void purgeRoots(object sender, DoWorkEventArgs e) { // if (TranslatingRequestHandler.Request(RequestType.Question, "PurgeConfirmation").Cancelled) { // e.Cancel = true; // return; // } ProgressHandler.saveMessage(); e.Result = false; foreach (GameEntry game in (System.Collections.IEnumerable)e.Argument) { TranslatingProgressHandler.setTranslatedMessage("Purging", game.Title); try { if (game.purge(false)) { e.Result = true; } else { break; } } catch (Exception ex) { TranslatingMessageHandler.SendError("PurgeError", ex, game.id.ToString()); } } StaticNotifyPropertyChanged("HasUnsubmittedGames"); ProgressHandler.restoreMessage(); }
//private bool already_setup = false; public void setup() { handlers = new Dictionary <HandlerType, ALocationHandler>(); TranslatingProgressHandler.setTranslatedMessage("DetectingSystemPaths"); ASystemLocationHandler system_handler = this.setupSystemHandler(); handlers.Add(HandlerType.System, system_handler); TranslatingProgressHandler.setTranslatedMessage("DetectingSteam"); ASteamLocationHandler steam_handler = this.setupSteamHandler(); handlers.Add(HandlerType.Steam, steam_handler); steam = steam_handler; TranslatingProgressHandler.setTranslatedMessage("DetectingPlayStation"); APlaystationLocationHandler playstation_handler = this.setupPlaystationHandler(); ps = playstation_handler; handlers.Add(HandlerType.PlayStation, playstation_handler); TranslatingProgressHandler.setTranslatedMessage("DetectingScummVM"); AScummVMLocationHandler scummvm_handler = this.setupScummVMHandler(); handlers.Add(HandlerType.ScummVM, scummvm_handler); }
protected void cancelBackup() { TranslatingProgressHandler.setTranslatedMessage("Cancelling"); if (backup != null && backup.IsBusy) { backup.CancelAsync(); } }
protected override void analyzerWork() { ProgressHandler.max += 3; base.analyzerWork(); if (Core.locations.uac_enabled) { TranslatingProgressHandler.setTranslatedMessage("DumpingVirtualStore"); outputLine(Environment.NewLine + "UAC Enabled" + Environment.NewLine); outputLine(Environment.NewLine + "VirtualStore Folders: "); string virtual_path; foreach (string user in Core.locations.getUsers(EnvironmentVariable.LocalAppData)) { LocationPath parse_me = new LocationPath(EnvironmentVariable.LocalAppData, "VirtualStore"); virtual_path = Path.Combine(Core.locations.getAbsoluteRoot(parse_me, user), "VirtualStore"); virtual_path = Path.Combine(virtual_path, path.FullDirPath.Substring(3)); if (Directory.Exists(virtual_path)) { travelFolder(virtual_path); } } } else { outputLine(Environment.NewLine + "UAC Disabled or not present" + Environment.NewLine); } try { TranslatingProgressHandler.setTranslatedMessage("AnalyzingRegistry"); ProgressHandler.value++; searchRegistry(); } catch (Exception ex) { outputLine("Error while attempting to search the registry:"); recordException(ex); } try { TranslatingProgressHandler.setTranslatedMessage("AnalyzingStartMenu"); ProgressHandler.value++; searchStartMenu(); } catch (Exception ex) { outputLine("Error while attempting to search the start menu:"); recordException(ex); } }
private void outputPsFolder(Location.EnvironmentVariable ev, string name) { List <string> paths = Core.locations.getPaths(ev); TranslatingProgressHandler.setTranslatedMessage("AnalyzingPlayStationSaves"); ProgressHandler.value++; outputLine(Environment.NewLine + "Dumping Detected " + name + " Folders: "); foreach (string path in paths) { try { travelFolder(path); } catch (Exception ex) { outputLine("Error while attempting to search the " + name + " folder:"); recordException(ex); } } }
public void startMonitoring(object sender, System.ComponentModel.DoWorkEventArgs e) { if (monitors.Count > 0) { stopMonitoring(); } if (!IsMonitored) { return; } if (!CheckBackuptPathForMonitor()) { return; } TranslatingProgressHandler.setTranslatedMessage("BackupUpForMonitor", this.Title); ProgressHandler.suppress_communication = true; BackupProgramHandler backup = new BackupProgramHandler(this, null, null, Core.locations); backup.RunWorkerAsync(); while (backup.IsBusy) { Thread.Sleep(100); } TranslatingProgressHandler.setTranslatedMessage("SettingUpMonitorFor", this.Title); ProgressHandler.suppress_communication = false; foreach (DetectedLocationPathHolder path in this.DetectedLocations.Values) { MonitorPath mon = new MonitorPath(this, path); monitors.Push(mon); mon.start(); } }
protected void scanForScumm(string save_path) { TranslatingProgressHandler.setTranslatedMessage("AnalyzingScummVM"); ProgressHandler.value++; outputLine(Environment.NewLine + "ScummVM Path Entries: "); AScummVMLocationHandler scummvm = Core.locations.getHandler(HandlerType.ScummVM) as AScummVMLocationHandler; foreach (string user in scummvm.Locations.Keys) { foreach (string name in scummvm.Locations[user].Keys) { string path = scummvm.Locations[user][name]; if (path.ToLower().Contains(save_path.ToLower())) { outputLine("Entry Name: " + name); outputLine("Entry Path: " + path); } } } }
public static void DetectBackups() { ProgressHandler.saveMessage(); model.Clear(); if (!Core.settings.IsBackupPathSet) { return; } ProgressHandler.state = ProgressState.Normal; string path = null; path = Core.settings.backup_path; FileInfo[] read_us = new DirectoryInfo(path).GetFiles("*.gb7"); ProgressHandler.value = 0; if (read_us.Length > 0) { ProgressHandler.max = read_us.Length; TranslatingProgressHandler.setTranslatedMessage("LoadingArchives", ProgressHandler.value.ToString(), read_us.Length.ToString()); foreach (FileInfo read_me in read_us) { ProgressHandler.value++; try { Archive add_me = new Archive(read_me); if (add_me != null) { model.AddWithSort(add_me); } } catch (Exception e) { TranslatingMessageHandler.SendException(e); } } } ProgressHandler.state = ProgressState.None; ProgressHandler.value = 0; ProgressHandler.restoreMessage(); }
private void run7z(bool send_progress) { if (this.Exists) { string status = ProgressHandler.message; int wait_max = 30; for (int count = 0; !canRead(ArchiveFile.FullName); count++) { TranslatingProgressHandler.setTranslatedMessage("ArchiveInUseWaiting", status.TrimEnd('.'), (count + 1).ToString(), wait_max.ToString()); Thread.Sleep(1000); if (count == wait_max - 1) { throw new TranslateableException("FileInUseTimeout", ArchiveFile.FullName, wait_max.ToString()); } } } try { zipper.Start(); string output = zipper.StandardOutput.ReadLine(); while (output != null) { if (send_progress) { if (output.StartsWith("Extracting") || output.StartsWith("Compressing")) { ProgressHandler.value++; } } output = zipper.StandardOutput.ReadLine(); } } catch (Exception e) { throw new TranslateableException("ExeRunError", e, ZipExecutable, zipper.StartInfo.Arguments, zipper.StartInfo.WorkingDirectory); } finally { try { zipper.Close(); } catch { } } }
public void downloadDataUpdates() { ProgressHandler.value = 0; ProgressHandler.max = Core.updater.Data.UpdateCount; try { while (Core.updater.Data.UpdateAvailable) { ProgressHandler.value++; TranslatingProgressHandler.setTranslatedMessage("UpdatingFile", Core.updater.Data.NextUpdateName); String file_path = Core.updater.Data.NextUpdatePath; Core.updater.Data.DownloadNextUpdate(); FileInfo file = new FileInfo(file_path); FileSecurity fSecurity = file.GetAccessControl(); fSecurity.AddAccessRule(new FileSystemAccessRule(@"Everyone", FileSystemRights.FullControl, InheritanceFlags.None, PropagationFlags.InheritOnly, AccessControlType.Allow)); file.SetAccessControl(fSecurity); } } catch (Exception e) { Logger.Logger.log(e); } }
protected override void analyzerWork() { outputLine("Game Name: " + game.Title); this.path = game.DetectedLocations.getMostAccurateLocation(); if (path.EV == EnvironmentVariable.VirtualStore) { string drive = Path.GetPathRoot(path.FullDirPath); string new_path = Path.Combine(drive, path.Path); this.path = Core.locations.interpretPath(new_path).getMostAccurateLocation(); } string[] folders = this.path.Path.Split(System.IO.Path.DirectorySeparatorChar); string found_path = null; for (int i = folders.Length - 1; i >= 0; i--) { string temp_path = folders[0]; for (int j = 1; j <= i; j++) { temp_path = Path.Combine(temp_path, folders[j]); } DirectoryInfo dir = new DirectoryInfo(Path.Combine(path.AbsoluteRoot, temp_path)); if (dir.GetFiles("*.exe").Length > 0) { found_path = temp_path; break; } } if (found_path != null) { path.ReplacePath(found_path); } outputLine("Operating System: "); outputLine(Environment.OSVersion.VersionString); ProgressHandler.max += 4; outputLine(); outputLine("Path: "); outputPath(path.FullDirPath); outputLine(); try { scanForScumm(path.FullDirPath); } catch (Exception ex) { outputLine("Error while attempting to cehck for ScummVM path entries:"); recordException(ex); } try { TranslatingProgressHandler.setTranslatedMessage("DumpingFolder"); ProgressHandler.value++; outputLine(Environment.NewLine + "Folder Dump: "); travelFolder(path.FullDirPath); } catch (Exception ex) { outputLine("Error while attempting to search the save folder:"); recordException(ex); } }
public static List <GameEntry> detectGames(List <GameID> these_games) { ProgressHandler.clearMessage(); ProgressHandler.state = ProgressState.Normal; List <GameEntry> detected_games = new List <GameEntry>(); Core.monitor.stop(); // if (model.Count == 0) { if (these_games == null || these_games.Count == 0 || model.Count == 0) { loadXml(); } // } int game_count; game_count = model.Count; if (these_games != null) { ProgressHandler.max = these_games.Count; } else { ProgressHandler.max = game_count; } ProgressHandler.value = 1; Dictionary <string, int> contribs = new Dictionary <string, int>(); string string_to_use = "DetectingGames"; if (Core.settings.MonitoredGames.Count > 0 && Core.AppMode == AppMode.Main) { string_to_use = "DetectingMonitoringGames"; } TranslatingProgressHandler.setTranslatedMessage(string_to_use); foreach (GameEntry game in model) { //if (_cancelling) // break; if (these_games != null && !these_games.Contains(game.id)) { continue; } ProgressHandler.suppress_communication = true; game.Detect(); if (game.IsMonitored && Core.AppMode == AppMode.Main) { game.startMonitoring(null, null); } ProgressHandler.suppress_communication = false; //foreach (string contrib in game.Contributors) { // if (contribs.ContainsKey(contrib)) // contribs[contrib]++; // else // contribs.Add(contrib, 1); //} //if (!force_redetect && game.IsDetected && !game.id.deprecated) // model.AddWithSort(game); detected_games.Add(game); ProgressHandler.value++; } //foreach (KeyValuePair<string, int> pair in contribs) { // contributors.AddWithSort(new ContributorHandler(pair.Key, pair.Value)); //} ProgressHandler.state = ProgressState.None; ProgressHandler.value = 0; game_count = detected_games_count; model.IsEnabled = true; if (game_count > 1) { TranslatingProgressHandler.setTranslatedMessage("GamesDetected", detected_games_count.ToString()); } else if (game_count > 0) { TranslatingProgressHandler.setTranslatedMessage("GameDetected"); } else { TranslatingProgressHandler.setTranslatedMessage("NoGamesDetected"); //GameHandler no_games = new GameHandler(new GameID(Strings.getGeneralString("NoGamesDetected"), GamePlatform.Multiple, null)); //no_games.title = Strings.getGeneralString("NoGamesDetected"); model.IsEnabled = false; } StaticNotifyPropertyChanged("GamesDetected"); return(detected_games); }
void BackupProgramHandler_DoWork(object sender, DoWorkEventArgs e) { if (Core.settings.IsBackupPathSet || archive_name_override != null) { if (archive_name_override != null) { output_path = Path.GetDirectoryName(archive_name_override); } else { output_path = Core.settings.backup_path; } IList <GameEntry> games; if (back_these_up != null && back_these_up.Count > 0) { games = back_these_up; } else { if (Games.detected_games_count == 0) { Games.detectGames(); } games = Games.DetectedGames.Items; } if (games.Count > 0) { ProgressHandler.value = 1; ProgressHandler.max = games.Count; TranslatingProgressHandler.setTranslatedMessage("GamesToBeBackedUpCount", games.Count.ToString()); foreach (GameEntry game in games) { if (CancellationPending) { return; } //if(archive_name_override!=null) //all_users_archive = new ArchiveHandler(new FileInfo(archive_name_override),game.id); if (games.Count == 1) { TranslatingProgressHandler.setTranslatedMessage("BackingUpSingleGame", game.Title); } else { TranslatingProgressHandler.setTranslatedMessage("BackingUpMultipleGames", game.Title, ProgressHandler.value.ToString(), games.Count.ToString()); } List <DetectedFile> files; if (only_these_files != null && only_these_files.Count > 0) { files = only_these_files; } else { files = game.Saves.Flatten(); ; } Archive override_archive = null; try { DictionaryList <Archive, DetectedFile> backup_files = new DictionaryList <Archive, DetectedFile>(); foreach (DetectedFile file in files) { ArchiveID archive_id; Archive archive; if (CancellationPending) { return; } archive_id = new ArchiveID(game.id, file); if (archive_name_override != null) { if (override_archive == null) { file.Type = null; } override_archive = new Archive(new FileInfo(archive_name_override), new ArchiveID(game.id, file)); archive = override_archive; } else { if (Archives.Get(archive_id) == null) { Archives.Add(new Archive(output_path, new ArchiveID(game.id, file))); } archive = Archives.Get(archive_id); } backup_files.Add(archive, file); } if (CancellationPending) { return; } foreach (KeyValuePair <Archive, List <DetectedFile> > backup_file in backup_files) { if (override_archive == null) { backup_file.Key.backup(backup_file.Value, false, false); } else { backup_file.Key.backup(backup_file.Value, true, false); } } } catch (Exception ex) { TranslatingMessageHandler.SendException(ex); } finally { ProgressHandler.value++; } } } else { TranslatingMessageHandler.SendError("NothingToBackup"); } } else { TranslatingMessageHandler.SendError("BackupPathNotSet"); } }
private void cancelButton_Click(object sender, RoutedEventArgs e) { TranslatingProgressHandler.setTranslatedMessage("Stopping"); this.Close(); }
public RestoreResult restore(DirectoryInfo destination, List <string> only_these) { cancel_restore = false; TranslatingProgressHandler.setTranslatedMessage("CheckingDestination"); // The files get extracted to the temp folder, so this sets up our ability to read them DirectoryInfo from_here = new DirectoryInfo(TempFolder); // If it's a destination that doesn't yet exist if (!destination.Exists) { try { destination.Create(); // This sets the permissions on the folder to be for everyone DirectorySecurity everyone = destination.GetAccessControl(); string everyones_name = @"Everyone"; everyone.AddAccessRule(new FileSystemAccessRule(everyones_name, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow)); destination.SetAccessControl(everyone); } catch { // This is if the folder creation fails // It means we have to run as admin, but we check here if we already are if (!SecurityHandler.amAdmin()) { // If we aren't we elevate ourselves RestoreResult res = restoreElevation(destination.FullName); if (res != RestoreResult.Success) { return(res); } } else { throw new TranslateableException("UnableToCreateOutputFolder", destination.FullName); } } } if (cancel_restore) { return(RestoreResult.Cancel); } TranslatingProgressHandler.setTranslatedMessage("ExtractingArchive"); ProgressHandler.state = ProgressState.Indeterminate; if (only_these == null) { ProgressHandler.max = file_count; extract(true); } else { ProgressHandler.max = only_these.Count; extract(only_these, true); } ProgressHandler.value = 0; ProgressHandler.state = ProgressState.Normal; // Clean up the masgau archive ID if (File.Exists(Path.Combine(TempFolder, "masgau.xml"))) { File.Delete(Path.Combine(TempFolder, "masgau.xml")); } if (cancel_restore) { return(RestoreResult.Cancel); } TranslatingProgressHandler.setTranslatedMessage("CopyingFilesToDestination"); if (!canWrite(destination)) { Directory.Delete(TempFolder, true); RestoreResult res = restoreElevation(destination.FullName); if (res != RestoreResult.Success) { return(res); } cancel_restore = true; } if (cancel_restore) { return(RestoreResult.Cancel); } copyFolders(from_here, destination, true); if (cancel_restore) { return(RestoreResult.Cancel); } purgeTemp(); ProgressHandler.state = ProgressState.None; return(RestoreResult.Success); }
protected override void doWork(object sender, System.ComponentModel.DoWorkEventArgs e) { base.doWork(sender, e); path_candidates = new SimpleModel <LocationPath>(); user_candidates = new SimpleModel <string>(); ProgressHandler.state = ProgressState.Indeterminate; try { if (archive == null) { } } catch (Exception ex) { TranslatingMessageHandler.SendException(ex); } if (ArgArchives.Count > 0) { archive = new Archive(new FileInfo(ArgArchives.Dequeue())); } if (archive == null) { throw new TranslateableException("NoRestoreFileSelected"); } TranslatingProgressHandler.setTranslatedMessage("DetectingGameForRestoration"); if (!archive.Exists) { throw new TranslateableException("FileNotFound", archive.ArchivePath); } GameID selected_game = archive.id.Game; string backup_owner = archive.id.Owner; string archive_type = archive.id.Type; try { game_data = Games.detectGame(selected_game); } catch (Exception ex) { TranslatingMessageHandler.SendException(ex); } NotifyPropertyChanged("GameNotDetected"); if (game_data != null) { // This adds hypothetical locations foreach (LocationPath location in game_data.Locations.Paths) { if (game_data.DetectionRequired) { break; } filterPathCandidates(location); } // This add already found locations foreach (DetectedLocationPathHolder location in game_data.DetectedLocations) { location.IsSelected = true; switch (location.EV) { case EnvironmentVariable.ProgramFiles: case EnvironmentVariable.ProgramFilesX86: // This adds a fake VirtualStore folder, just in case if (Core.locations.uac_enabled) { DetectedLocationPathHolder temp = new DetectedLocationPathHolder(location, Core.locations.getFolder(EnvironmentVariable.LocalAppData, location.owner), location.owner); temp.ReplacePath(Path.Combine("VirtualStore", location.FullDirPath.Substring(3))); temp.EV = EnvironmentVariable.LocalAppData; addPathCandidate(temp); } addPathCandidate(location); break; default: addPathCandidate(location); break; } } //if (archive.id.Game.OS!=null&&archive.id.Game.OS.StartsWith("PS")) { // foreach (string drive in Core.locations.ps.GetDriveCandidates()) { // DetectedLocationPathHolder loc = new DetectedLocationPathHolder(EnvironmentVariable.Drive, drive, null); // addPathCandidate(loc); // } //} } if (archive.id.OriginalEV != EnvironmentVariable.None && archive.id.OriginalRelativePath != null) { LocationPath path = new LocationPath(archive.id.OriginalEV, archive.id.OriginalRelativePath); filterPathCandidates(path); } if (archive.id.OriginalLocation != null) { DetectedLocations locs = Core.locations.interpretPath(archive.id.OriginalLocation); DetectedLocationPathHolder loc = locs.getMostAccurateLocation(); if (loc != null) { addPathCandidate(loc); } } if (path_candidates.Count == 1) { multiple_paths = false; NotifyPropertyChanged("only_path"); } else if (path_candidates.Count > 1) { multiple_paths = true; } else { throw new TranslateableException("NoRestorePathsDetected", this.archive.id.ToString()); } }