Changeset 2451
- Timestamp:
- 3/12/2012 7:47:48 AM (15 months ago)
- Location:
- branches/eraser6/pluginsRewrite
- Files:
-
- 5 edited
-
Eraser.DefaultPlugins/ErasureTargets/FileSystemObjectErasureTarget.cs (modified) (7 diffs)
-
Eraser.DefaultPlugins/ErasureTargets/FolderErasureTargetConfigurer.cs (modified) (4 diffs)
-
Eraser.DefaultPlugins/ErasureTargets/RecycleBinErasureTargetConfigurer.cs (modified) (3 diffs)
-
Eraser.Plugins/IConfigurer.cs (modified) (2 diffs)
-
Eraser/TaskDragDropHelper.cs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/pluginsRewrite/Eraser.DefaultPlugins/ErasureTargets/FileSystemObjectErasureTarget.cs
r2382 r2451 42 42 /// </summary> 43 43 [Serializable] 44 public abstract class FileSystemObjectErasureTarget : ErasureTarget44 public abstract class FileSystemObjectErasureTarget : IErasureTarget 45 45 { 46 46 #region Serialization code … … 174 174 public string Path { get; set; } 175 175 176 public sealed override ErasureMethod EffectiveMethod176 public sealed override IErasureMethod EffectiveMethod 177 177 { 178 178 get … … 241 241 242 242 //Get the filesystem provider to handle the secure file erasures 243 FileSystem fsManager = Host.Instance.FileSystems[243 IFileSystem fsManager = Host.Instance.FileSystems[ 244 244 VolumeInfo.FromMountPoint(info.DirectoryName)]; 245 245 … … 249 249 { 250 250 //Update the task progress 251 ErasureMethod method = EffectiveMethod;251 IErasureMethod method = EffectiveMethod; 252 252 OnProgressChanged(this, new ProgressChangedEventArgs(progress, 253 253 new TaskProgressChangedEventArgs(info.FullName, 0, method.Passes))); … … 258 258 259 259 //Define the callback function for progress reporting. 260 ErasureMethod.ErasureMethodProgressFunction callback =260 IErasureMethod.ErasureMethodProgressFunction callback = 261 261 delegate(long lastWritten, long totalData, int currentPass) 262 262 { … … 303 303 /// <param name="info">The stream to erase.</param> 304 304 /// <param name="callback">The erasure progress callback.</param> 305 private void TryEraseStream( FileSystem fsManager,ErasureMethod method, StreamInfo info,306 ErasureMethod.ErasureMethodProgressFunction callback)305 private void TryEraseStream(IFileSystem fsManager, IErasureMethod method, StreamInfo info, 306 IErasureMethod.ErasureMethodProgressFunction callback) 307 307 { 308 308 for (int i = 0; ; ++i) … … 384 384 List<string> entries = new List<string>( 385 385 ManagerLibrary.Settings.PlausibleDeniabilityFiles); 386 Prng prng = Host.Instance.Prngs.ActivePrng;386 IPrng prng = Host.Instance.Prngs.ActivePrng; 387 387 do 388 388 { -
branches/eraser6/pluginsRewrite/Eraser.DefaultPlugins/ErasureTargets/FolderErasureTargetConfigurer.cs
r2368 r2451 33 33 34 34 using Eraser.Util; 35 using Eraser.Plugins; 35 36 using Eraser.Plugins.ExtensionPoints; 36 37 37 38 namespace Eraser.DefaultPlugins 38 39 { 39 public partial class FolderErasureTargetConfigurer : UserControl, IErasureTargetConfigurer 40 public partial class FolderErasureTargetConfigurer : UserControl, 41 IErasureTargetConfigurer, IDragAndDropConfigurer<IErasureTarget> 40 42 { 41 43 public FolderErasureTargetConfigurer() … … 47 49 #region IConfigurer<ErasureTarget> Members 48 50 49 public void LoadFrom( ErasureTarget target)51 public void LoadFrom(IErasureTarget target) 50 52 { 51 53 FolderErasureTarget folder = target as FolderErasureTarget; … … 60 62 } 61 63 62 public bool SaveTo( ErasureTarget target)64 public bool SaveTo(IErasureTarget target) 63 65 { 64 66 FolderErasureTarget folder = target as FolderErasureTarget; … … 143 145 #endregion 144 146 147 #region IDragAndDropConfigurer<IErasureTarget> Members 148 149 public ICollection<IErasureTarget> ProcessArgument(DragEventArgs e) 150 { 151 List<string> files = e.Data.GetDataPresent(DataFormats.FileDrop) ? 152 new List<string>((string[])e.Data.GetData(DataFormats.FileDrop, false)) : 153 new List<string>(); 154 155 List<IErasureTarget> result = new List<IErasureTarget>(); 156 foreach (string file in files) 157 { 158 if (File.Exists(file)) 159 { 160 FileErasureTarget target = new FileErasureTarget(); 161 target.Path = file; 162 result.Add(target); 163 } 164 } 165 166 return result; 167 } 168 169 #endregion 170 145 171 private void folderBrowse_Click(object sender, EventArgs e) 146 172 { -
branches/eraser6/pluginsRewrite/Eraser.DefaultPlugins/ErasureTargets/RecycleBinErasureTargetConfigurer.cs
r2368 r2451 25 25 using System.Text; 26 26 using System.Text.RegularExpressions; 27 using System.IO; 27 28 28 29 using Eraser.Util; … … 32 33 namespace Eraser.DefaultPlugins 33 34 { 34 class RecycleBinErasureTargetConfigurer : IErasureTargetConfigurer 35 class RecycleBinErasureTargetConfigurer : IErasureTargetConfigurer, 36 IDragAndDropConfigurer<IErasureTarget> 35 37 { 36 38 #region IConfigurer<ErasureTarget> Members 37 39 38 public void LoadFrom( ErasureTarget target)40 public void LoadFrom(IErasureTarget target) 39 41 { 40 42 } 41 43 42 public bool SaveTo( ErasureTarget target)44 public bool SaveTo(IErasureTarget target) 43 45 { 44 46 return true; … … 69 71 70 72 #endregion 73 74 #region IDragAndDropConfigurer<IErasureTarget> Members 75 76 public ICollection<IErasureTarget> ProcessArgument(System.Windows.Forms.DragEventArgs e) 77 { 78 //Then try to see if we have shell locations dropped on us. 79 if (e.Data.GetDataPresent("Shell IDList Array")) 80 { 81 MemoryStream stream = (MemoryStream)e.Data.GetData("Shell IDList Array"); 82 byte[] buffer = new byte[stream.Length]; 83 stream.Read(buffer, 0, buffer.Length); 84 ShellCIDA cida = new ShellCIDA(buffer); 85 86 if (cida.cidl > 0) 87 { 88 for (int i = 1; i <= cida.cidl; ++i) 89 { 90 if (cida.aoffset[i].Guid == Shell.KnownFolderIDs.RecycleBin) 91 { 92 return new IErasureTarget[] { new RecycleBinErasureTarget() }; 93 } 94 } 95 } 96 } 97 98 return new IErasureTarget[0]; 99 } 100 101 #endregion 71 102 } 72 103 } -
branches/eraser6/pluginsRewrite/Eraser.Plugins/IConfigurer.cs
r2356 r2451 24 24 using System.Linq; 25 25 using System.Text; 26 27 using System.Windows.Forms; 26 28 27 29 namespace Eraser.Plugins … … 69 71 bool ProcessArgument(string argument); 70 72 } 73 74 /// <summary> 75 /// Represents an object which is able to configure a given instance of 76 /// <typeparamref name="T"/> from a Drag-and-Drop operation. 77 /// </summary> 78 /// <typeparam name="T">The type to configure</typeparam> 79 public interface IDragAndDropConfigurer<T> : IConfigurer<T> 80 { 81 /// <summary> 82 /// Sets the configuration of the current configurer from the provided 83 /// Drag-and-Drop event argument. 84 /// </summary> 85 /// <param name="e">The event argument.</param> 86 /// <returns>A collection of T based on the drag-and-drop event.</returns> 87 ICollection<T> ProcessArgument(DragEventArgs e); 88 } 71 89 } -
branches/eraser6/pluginsRewrite/Eraser/TaskDragDropHelper.cs
r2445 r2451 31 31 using Eraser.Util; 32 32 using Eraser.Manager; 33 using Eraser.Plugins; 33 34 using Eraser.Plugins.ExtensionPoints; 34 35 … … 64 65 for (int i = 1; i <= cida.cidl; ++i) 65 66 { 66 /*if (!string.IsNullOrEmpty(cida.aoffset[i].Path))67 if (cida.aoffset[i].Guid == Shell.KnownFolderIDs.RecycleBin) 67 68 { 68 files.Add(cida.aoffset[i].Path); 69 } 70 else */if (cida.aoffset[i].Guid != Guid.Empty) 71 { 72 if (cida.aoffset[i].Guid == Shell.KnownFolderIDs.RecycleBin) 73 { 74 recycleBin = true; 75 } 69 recycleBin = true; 76 70 } 77 71 } … … 82 76 } 83 77 84 public static ICollection<IErasureTarget> GetTargets(ICollection<string> paths, bool recycleBin) 78 /// <summary> 79 /// Parses a list of locations dropped on the target, converting them to the appropriate 80 /// IErasureTarget instance. 81 /// </summary> 82 /// <param name="e">The event argument.</param> 83 /// <returns>A list of erasure targets which will erase all the files and directories 84 /// as described by the drag-and-drop operation.</returns> 85 public static ICollection<IErasureTarget> GetTargets(DragEventArgs e) 85 86 { 86 87 ICollection<IErasureTarget> result = new List<IErasureTarget>(); 87 foreach ( string path in paths)88 foreach (IErasureTarget target in Host.Instance.ErasureTargetFactories) 88 89 { 89 // If the path doesn't exist, skip the file90 if (!( File.Exists(path) || Directory.Exists(path)))90 //Skip targets not supporting IDragAndDropConfigurer 91 if (!(target.Configurer is IDragAndDropConfigurer<IErasureTarget>)) 91 92 continue; 92 93 93 FileSystemObjectErasureTarget target; 94 if ((File.GetAttributes(path) & FileAttributes.Directory) != 0) 95 target = new FolderErasureTarget(); 96 else 97 target = new FileErasureTarget(); 98 target.Path = path; 99 100 result.Add(target); 94 IDragAndDropConfigurer<IErasureTarget> configurer = 95 (IDragAndDropConfigurer<IErasureTarget>)target.Configurer; 96 foreach (IErasureTarget newTarget in configurer.ProcessArgument(e)) 97 result.Add(newTarget); 101 98 } 102 99 103 //Add the recycle bin if it was specified104 if (recycleBin)105 result.Add(new RecycleBinErasureTarget());106 107 //Return our result108 100 return result; 109 101 }
Note: See TracChangeset
for help on using the changeset viewer.
