Added support for marking/unmarking/detecting cracks.

This commit is contained in:
2017-05-18 17:56:28 +01:00
parent fe10000b3c
commit 910c400a21
15 changed files with 296 additions and 51 deletions

View File

@@ -1,3 +1,9 @@
2017-05-18 Natalia Portillo <claunia@claunia.com>
* DBOps.cs:
* Workers.cs:
Added support for marking/unmarking/detecting cracks.
2017-05-18 Natalia Portillo <claunia@claunia.com> 2017-05-18 Natalia Portillo <claunia@claunia.com>
* Workers.cs: * Workers.cs:

View File

@@ -76,6 +76,7 @@ namespace osrepodbmgr.Core
public DateTime LastAccessTimeUtc; public DateTime LastAccessTimeUtc;
public DateTime LastWriteTimeUtc; public DateTime LastWriteTimeUtc;
public FileAttributes Attributes; public FileAttributes Attributes;
public bool Crack;
} }
public struct DBFolder public struct DBFolder
@@ -371,7 +372,7 @@ namespace osrepodbmgr.Core
{ {
entries = new List<DBFile>(); entries = new List<DBFile>();
string sql = string.Format("SELECT * FROM files ORDER BY id LIMIT {0}, {1}", start, count); string sql = string.Format("SELECT * FROM files ORDER BY sha256 LIMIT {0}, {1}", start, count);
IDbCommand dbcmd = dbCon.CreateCommand(); IDbCommand dbcmd = dbCon.CreateCommand();
IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter(); IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();
@@ -728,6 +729,29 @@ namespace osrepodbmgr.Core
return true; return true;
} }
public bool ToggleCrack(string hash, bool crack)
{
IDbCommand dbcmd = dbCon.CreateCommand();
IDbTransaction trans = dbCon.BeginTransaction();
IDbDataParameter param1 = dbcmd.CreateParameter();
IDbDataParameter param2 = dbcmd.CreateParameter();
param1.ParameterName = "@hash";
param1.DbType = DbType.String;
param1.Value = hash;
param2.ParameterName = "@crack";
param2.DbType = DbType.Boolean;
param2.Value = crack;
dbcmd.Parameters.Add(param1);
dbcmd.Parameters.Add(param2);
dbcmd.CommandText = "UPDATE files SET crack = @crack WHERE sha256 = @hash";
dbcmd.ExecuteNonQuery();
trans.Commit();
dbcmd.Dispose();
return true;
}
} }
} }

View File

@@ -54,7 +54,7 @@ namespace osrepodbmgr.Core
public delegate void FailedDelegate(string text); public delegate void FailedDelegate(string text);
public delegate void FinishedWithoutErrorDelegate(); public delegate void FinishedWithoutErrorDelegate();
public delegate void FinishedWithTextDelegate(string text); public delegate void FinishedWithTextDelegate(string text);
public delegate void AddFileForOSDelegate(string filename, string hash, bool known); public delegate void AddFileForOSDelegate(string filename, string hash, bool known, bool isCrack);
public delegate void AddOSDelegate(DBEntry os, bool existsInRepo, string pathInRepo); public delegate void AddOSDelegate(DBEntry os, bool existsInRepo, string pathInRepo);
public delegate void AddFileDelegate(DBFile file); public delegate void AddFileDelegate(DBFile file);
public delegate void AddFilesDelegate(List<DBFile> file); public delegate void AddFilesDelegate(List<DBFile> file);
@@ -401,6 +401,11 @@ public static event AddFilesDelegate AddFiles;
dbFile.Path = relpath; dbFile.Path = relpath;
dbFile.Sha256 = hash; dbFile.Sha256 = hash;
// TODO: Add common cracker group names?
dbFile.Crack |= (relpath.ToLowerInvariant().Contains("crack") || // Typical crack
relpath.ToLowerInvariant().Contains("crack") || // Typical keygen
relpath.ToLowerInvariant().Contains("[k]"));
Context.hashes.Add(relpath, dbFile); Context.hashes.Add(relpath, dbFile);
counter++; counter++;
} }
@@ -543,7 +548,7 @@ public static event AddFilesDelegate AddFiles;
UpdateProgress(null, "Checking files in database", counter, Context.hashes.Count); UpdateProgress(null, "Checking files in database", counter, Context.hashes.Count);
if(AddFileForOS != null) if(AddFileForOS != null)
AddFileForOS(kvp.Key, kvp.Value.Sha256, dbCore.DBOps.ExistsFile(kvp.Value.Sha256)); AddFileForOS(kvp.Key, kvp.Value.Sha256, dbCore.DBOps.ExistsFile(kvp.Value.Sha256), kvp.Value.Crack);
counter++; counter++;
} }
@@ -627,7 +632,7 @@ public static event AddFilesDelegate AddFiles;
{ {
DBFile file = new DBFile DBFile file = new DBFile
{ {
Sha256 = kvp.Value.Sha256, ClamTime = null, Crack = false, Sha256 = kvp.Value.Sha256, ClamTime = null, Crack = kvp.Value.Crack,
Length = kvp.Value.Length, Virus = null, HasVirus = null, VirusTotalTime = null Length = kvp.Value.Length, Virus = null, HasVirus = null, VirusTotalTime = null
}; };
dbCore.DBOps.AddFile(file); dbCore.DBOps.AddFile(file);
@@ -1841,5 +1846,23 @@ public static event AddFilesDelegate AddFiles;
Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException)); Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException));
} }
} }
public static void ToggleCrack(string hash, bool crack)
{
try
{
dbCore.DBOps.ToggleCrack(hash, crack);
if(Finished != null)
Finished();
}
catch(Exception ex)
{
if(Debugger.IsAttached)
throw;
if(Failed != null)
Failed(string.Format("Exception {0}\n{1}", ex.Message, ex.InnerException));
}
}
} }
} }

View File

@@ -1,3 +1,11 @@
2017-05-18 Natalia Portillo <claunia@claunia.com>
* dlgAdd.xeto:
* frmMain.xeto:
* dlgAdd.xeto.cs:
* frmMain.xeto.cs:
Added support for marking/unmarking/detecting cracks.
2017-05-18 Natalia Portillo <claunia@claunia.com> 2017-05-18 Natalia Portillo <claunia@claunia.com>
* frmMain.xeto: * frmMain.xeto:

View File

@@ -100,7 +100,7 @@
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <StackLayoutItem Expand="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TabControl> <TabControl>
<TabPage Text="Files"> <TabPage Text="Files">
<GridView ID="treeFiles" /> <GridView ID="treeFiles" SelectionChanged="treeFilesSelectionChanged"/>
</TabPage> </TabPage>
<TabPage Text="OSes" ID="tabOSes" Visible="False"> <TabPage Text="OSes" ID="tabOSes" Visible="False">
<GridView ID="treeOSes" /> <GridView ID="treeOSes" />
@@ -126,6 +126,9 @@
<StackLayoutItem HorizontalAlignment="Left"> <StackLayoutItem HorizontalAlignment="Left">
<Button ID="btnRemoveFile" Click="OnBtnRemoveFileClicked" Visible="False">Remove</Button> <Button ID="btnRemoveFile" Click="OnBtnRemoveFileClicked" Visible="False">Remove</Button>
</StackLayoutItem> </StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Left">
<Button ID="btnToggleCrack" Click="OnBtnToggleCrackClicked" Visible="False">Mark as crack</Button>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Left"> <StackLayoutItem HorizontalAlignment="Left">
<Button ID="btnMetadata" Click="OnBtnMetadataClicked" Visible="False">Metadata</Button> <Button ID="btnMetadata" Click="OnBtnMetadataClicked" Visible="False">Metadata</Button>
</StackLayoutItem> </StackLayoutItem>

View File

@@ -60,6 +60,7 @@ namespace osrepodbmgr.Eto
public string path { get; set; } public string path { get; set; }
public string hash { get; set; } public string hash { get; set; }
public bool known { get; set; } public bool known { get; set; }
public bool iscrack { get; set; }
} }
#region XAML UI elements #region XAML UI elements
@@ -93,6 +94,7 @@ namespace osrepodbmgr.Eto
Button btnPack; Button btnPack;
Button btnClose; Button btnClose;
Button btnExit; Button btnExit;
Button btnToggleCrack;
#pragma warning restore 0649 #pragma warning restore 0649
#endregion XAML UI elements #endregion XAML UI elements
@@ -116,6 +118,11 @@ namespace osrepodbmgr.Eto
HeaderText = "Path" HeaderText = "Path"
}); });
treeFiles.Columns.Add(new GridColumn treeFiles.Columns.Add(new GridColumn
{
DataCell = new CheckBoxCell { Binding = Binding.Property<FileEntry, bool?>(r => r.iscrack) },
HeaderText = "Crack?"
});
treeFiles.Columns.Add(new GridColumn
{ {
DataCell = new TextBoxCell { Binding = Binding.Property<FileEntry, string>(r => r.hash) }, DataCell = new TextBoxCell { Binding = Binding.Property<FileEntry, string>(r => r.hash) },
HeaderText = "SHA256" HeaderText = "SHA256"
@@ -394,6 +401,7 @@ namespace osrepodbmgr.Eto
btnPack.Visible = true; btnPack.Visible = true;
btnPack.Enabled = true; btnPack.Enabled = true;
btnRemoveFile.Visible = true; btnRemoveFile.Visible = true;
btnToggleCrack.Visible = true;
txtFormat.ReadOnly = false; txtFormat.ReadOnly = false;
txtMachine.ReadOnly = false; txtMachine.ReadOnly = false;
@@ -465,11 +473,11 @@ namespace osrepodbmgr.Eto
}); });
} }
void AddFile(string filename, string hash, bool known) void AddFile(string filename, string hash, bool known, bool isCrack)
{ {
Application.Instance.Invoke(delegate Application.Instance.Invoke(delegate
{ {
fileView.Add(new FileEntry { path = filename, hash = hash, known = known }); fileView.Add(new FileEntry { path = filename, hash = hash, known = known, iscrack = isCrack });
btnPack.Enabled |= !known; btnPack.Enabled |= !known;
}); });
} }
@@ -502,6 +510,7 @@ namespace osrepodbmgr.Eto
btnPack.Visible = false; btnPack.Visible = false;
btnClose.Visible = false; btnClose.Visible = false;
btnRemoveFile.Visible = false; btnRemoveFile.Visible = false;
btnToggleCrack.Visible = false;
if(fileView != null) if(fileView != null)
fileView.Clear(); fileView.Clear();
if(osView != null) if(osView != null)
@@ -750,6 +759,7 @@ namespace osrepodbmgr.Eto
void AddToDatabase() void AddToDatabase()
{ {
btnRemoveFile.Enabled = false; btnRemoveFile.Enabled = false;
btnToggleCrack.Enabled = false;
btnPack.Enabled = false; btnPack.Enabled = false;
btnClose.Enabled = false; btnClose.Enabled = false;
prgProgress.Visible = true; prgProgress.Visible = true;
@@ -867,6 +877,7 @@ namespace osrepodbmgr.Eto
protected void OnBtnPackClicked(object sender, EventArgs e) protected void OnBtnPackClicked(object sender, EventArgs e)
{ {
btnRemoveFile.Enabled = false; btnRemoveFile.Enabled = false;
btnToggleCrack.Enabled = false;
btnPack.Enabled = false; btnPack.Enabled = false;
btnClose.Enabled = false; btnClose.Enabled = false;
prgProgress.Visible = true; prgProgress.Visible = true;
@@ -948,6 +959,7 @@ namespace osrepodbmgr.Eto
thdPackFiles.Abort(); thdPackFiles.Abort();
btnRemoveFile.Enabled = true; btnRemoveFile.Enabled = true;
btnToggleCrack.Enabled = true;
btnPack.Enabled = true; btnPack.Enabled = true;
btnClose.Enabled = true; btnClose.Enabled = true;
prgProgress.Visible = false; prgProgress.Visible = false;
@@ -1196,5 +1208,37 @@ namespace osrepodbmgr.Eto
fileView.Remove((FileEntry)treeFiles.SelectedItem); fileView.Remove((FileEntry)treeFiles.SelectedItem);
} }
} }
protected void OnBtnToggleCrackClicked(object sender, EventArgs e)
{
if(treeFiles.SelectedItem != null)
{
string name = ((FileEntry)treeFiles.SelectedItem).path;
bool known = ((FileEntry)treeFiles.SelectedItem).known;
DBOSFile osfile;
if(Context.hashes.TryGetValue(name, out osfile))
{
osfile.Crack = !osfile.Crack;
Context.hashes.Remove(name);
Context.hashes.Add(name, osfile);
((FileEntry)treeFiles.SelectedItem).iscrack = osfile.Crack;
fileView.Remove((FileEntry)treeFiles.SelectedItem);
fileView.Add(new FileEntry { path = name, hash = osfile.Sha256, known = known, iscrack = osfile.Crack });
}
}
}
void treeFilesSelectionChanged(object sender, EventArgs e)
{
if(treeFiles.SelectedItem != null)
{
if(((FileEntry)treeFiles.SelectedItem).iscrack)
btnToggleCrack.Text = "Mark as not crack";
else
btnToggleCrack.Text = "Mark as crack";
}
}
} }
} }

View File

@@ -32,7 +32,7 @@
<TabPage Text="Files" ID="tabFiles"> <TabPage Text="Files" ID="tabFiles">
<StackLayout Orientation="Vertical"> <StackLayout Orientation="Vertical">
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch"> <StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
<GridView ID="treeFiles" Enabled="False" /> <GridView ID="treeFiles" Enabled="False" SelectionChanged="treeFilesSelectionChanged"/>
</StackLayoutItem> </StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch"> <StackLayoutItem HorizontalAlignment="Stretch">
<Label ID="lblProgressFiles1" Visible="False">lblProgress</Label> <Label ID="lblProgressFiles1" Visible="False">lblProgress</Label>
@@ -49,7 +49,7 @@
<StackLayoutItem HorizontalAlignment="Center"> <StackLayoutItem HorizontalAlignment="Center">
<StackLayout Orientation="Horizontal"> <StackLayout Orientation="Horizontal">
<Button x:Name="btnStopFiles" Click="OnBtnStopFilesClicked" Visible="False">Stop</Button> <Button x:Name="btnStopFiles" Click="OnBtnStopFilesClicked" Visible="False">Stop</Button>
<Button x:Name="btnMarkAsCrack" Click="OnBtnMarkAsCrackClicked" Visible="False">Mark as crack</Button> <Button x:Name="btnToggleCrack" Click="OnBtnToggleCrackClicked" Visible="False">Mark as crack</Button>
<Button x:Name="btnScanWithClamd" Click="OnBtnScanWithClamdClicked" Visible="False">Scan with clamd</Button> <Button x:Name="btnScanWithClamd" Click="OnBtnScanWithClamdClicked" Visible="False">Scan with clamd</Button>
<Button x:Name="btnCheckInVirusTotal" Click="OnBtnCheckInVirusTotalClicked" Visible="False">Check with VirusTotal</Button> <Button x:Name="btnCheckInVirusTotal" Click="OnBtnCheckInVirusTotalClicked" Visible="False">Check with VirusTotal</Button>
<Button x:Name="btnPopulateFiles" Click="OnBtnPopulateFilesClicked">Populate</Button> <Button x:Name="btnPopulateFiles" Click="OnBtnPopulateFilesClicked">Populate</Button>

View File

@@ -65,7 +65,7 @@ namespace osrepodbmgr.Eto
Label lblProgressFiles2; Label lblProgressFiles2;
ProgressBar prgProgressFiles2; ProgressBar prgProgressFiles2;
Button btnStopFiles; Button btnStopFiles;
Button btnMarkAsCrack; Button btnToggleCrack;
Button btnScanWithClamd; Button btnScanWithClamd;
Button btnCheckInVirusTotal; Button btnCheckInVirusTotal;
Button btnPopulateFiles; Button btnPopulateFiles;
@@ -620,8 +620,19 @@ namespace osrepodbmgr.Eto
} }
} }
protected void OnBtnMarkAsCrackClicked(object sender, EventArgs e) protected void OnBtnToggleCrackClicked(object sender, EventArgs e)
{ {
if(treeFiles.SelectedItem != null)
{
DBFile file = (DBFile)treeFiles.SelectedItem;
bool crack = !file.Crack;
Workers.ToggleCrack(file.Sha256, crack);
lstFiles.Remove(file);
file.Crack = crack;
lstFiles.Add(file);
}
} }
protected void OnBtnScanWithClamdClicked(object sender, EventArgs e) protected void OnBtnScanWithClamdClicked(object sender, EventArgs e)
@@ -635,7 +646,6 @@ namespace osrepodbmgr.Eto
protected void OnBtnPopulateFilesClicked(object sender, EventArgs e) protected void OnBtnPopulateFilesClicked(object sender, EventArgs e)
{ {
// TODO: Implement // TODO: Implement
btnMarkAsCrack.Enabled = false;
btnScanWithClamd.Enabled = false; btnScanWithClamd.Enabled = false;
btnCheckInVirusTotal.Enabled = false; btnCheckInVirusTotal.Enabled = false;
@@ -739,7 +749,7 @@ namespace osrepodbmgr.Eto
lblProgressFiles2.Visible = false; lblProgressFiles2.Visible = false;
prgProgressFiles1.Visible = false; prgProgressFiles1.Visible = false;
prgProgressFiles2.Visible = false; prgProgressFiles2.Visible = false;
btnMarkAsCrack.Visible = true; btnToggleCrack.Visible = true;
btnScanWithClamd.Visible = true; btnScanWithClamd.Visible = true;
btnCheckInVirusTotal.Visible = true; btnCheckInVirusTotal.Visible = true;
btnStopFiles.Visible = false; btnStopFiles.Visible = false;
@@ -749,5 +759,16 @@ namespace osrepodbmgr.Eto
tabOSes.Enabled = true; tabOSes.Enabled = true;
}); });
} }
void treeFilesSelectionChanged(object sender, EventArgs e)
{
if(treeFiles.SelectedItem != null)
{
if(((DBFile)treeFiles.SelectedItem).Crack)
btnToggleCrack.Text = "Mark as not crack";
else
btnToggleCrack.Text = "Mark as crack";
}
}
} }
} }

View File

@@ -1,3 +1,13 @@
2017-05-18 Natalia Portillo <claunia@claunia.com>
* dlgAdd.cs:
* frmMain.cs:
* gtk-gui/dlgAdd.cs:
* gtk-gui/gui.stetic:
* gtk-gui/generated.cs:
* gtk-gui/osrepodbmgr.frmMain.cs:
Added support for marking/unmarking/detecting cracks.
2017-05-18 Natalia Portillo <claunia@claunia.com> 2017-05-18 Natalia Portillo <claunia@claunia.com>
* dlgAdd.cs: * dlgAdd.cs:

View File

@@ -62,17 +62,20 @@ public partial class dlgAdd : Dialog
Context.CheckUnar(); Context.CheckUnar();
CellRendererText filenameCell = new CellRendererText(); CellRendererText filenameCell = new CellRendererText();
CellRendererToggle crackCell = new CellRendererToggle();
CellRendererText hashCell = new CellRendererText(); CellRendererText hashCell = new CellRendererText();
CellRendererToggle dbCell = new CellRendererToggle(); CellRendererToggle dbCell = new CellRendererToggle();
TreeViewColumn filenameColumn = new TreeViewColumn("Path", filenameCell, "text", 0, "background", 3, "foreground", 4); TreeViewColumn filenameColumn = new TreeViewColumn("Path", filenameCell, "text", 0, "background", 3, "foreground", 4);
TreeViewColumn crackColumn = new TreeViewColumn("Crack?", crackCell, "active", 5);
TreeViewColumn hashColumn = new TreeViewColumn("SHA256", hashCell, "text", 1, "background", 3, "foreground", 4); TreeViewColumn hashColumn = new TreeViewColumn("SHA256", hashCell, "text", 1, "background", 3, "foreground", 4);
TreeViewColumn dbColumn = new TreeViewColumn("Known?", dbCell, "active", 2); TreeViewColumn dbColumn = new TreeViewColumn("Known?", dbCell, "active", 2);
fileView = new ListStore(typeof(string), typeof(string), typeof(bool), typeof(string), typeof(string)); fileView = new ListStore(typeof(string), typeof(string), typeof(bool), typeof(string), typeof(string), typeof(bool));
treeFiles.Model = fileView; treeFiles.Model = fileView;
treeFiles.AppendColumn(filenameColumn); treeFiles.AppendColumn(filenameColumn);
treeFiles.AppendColumn(crackColumn);
treeFiles.AppendColumn(hashColumn); treeFiles.AppendColumn(hashColumn);
treeFiles.AppendColumn(dbColumn); treeFiles.AppendColumn(dbColumn);
@@ -129,6 +132,8 @@ public partial class dlgAdd : Dialog
treeOSes.AppendColumn(filesColumn); treeOSes.AppendColumn(filesColumn);
treeOSes.AppendColumn(netinstallColumn); treeOSes.AppendColumn(netinstallColumn);
treeOSes.AppendColumn(pathColumn); treeOSes.AppendColumn(pathColumn);
treeFiles.Selection.Changed += treeFilesSelectionChanged;
} }
void UnarChangeStatus() void UnarChangeStatus()
@@ -353,6 +358,7 @@ public partial class dlgAdd : Dialog
btnPack.Visible = true; btnPack.Visible = true;
btnPack.Sensitive = true; btnPack.Sensitive = true;
btnRemoveFile.Visible = true; btnRemoveFile.Visible = true;
btnToggleCrack.Visible = true;
txtFormat.IsEditable = true; txtFormat.IsEditable = true;
txtMachine.IsEditable = true; txtMachine.IsEditable = true;
@@ -424,12 +430,12 @@ public partial class dlgAdd : Dialog
}); });
} }
void AddFile(string filename, string hash, bool known) void AddFile(string filename, string hash, bool known, bool isCrack)
{ {
Application.Invoke(delegate Application.Invoke(delegate
{ {
string color = known ? "green" : "red"; string color = known ? "green" : "red";
fileView.AppendValues(filename, hash, known, color, "black"); fileView.AppendValues(filename, hash, known, color, "black", isCrack);
btnPack.Sensitive |= !known; btnPack.Sensitive |= !known;
}); });
} }
@@ -465,6 +471,7 @@ public partial class dlgAdd : Dialog
btnPack.Visible = false; btnPack.Visible = false;
btnClose.Visible = false; btnClose.Visible = false;
btnRemoveFile.Visible = false; btnRemoveFile.Visible = false;
btnToggleCrack.Visible = false;
if(fileView != null) if(fileView != null)
fileView.Clear(); fileView.Clear();
if(osView != null) if(osView != null)
@@ -732,6 +739,7 @@ public partial class dlgAdd : Dialog
void AddToDatabase() void AddToDatabase()
{ {
btnRemoveFile.Sensitive = false; btnRemoveFile.Sensitive = false;
btnToggleCrack.Sensitive = false;
btnPack.Sensitive = false; btnPack.Sensitive = false;
btnClose.Sensitive = false; btnClose.Sensitive = false;
prgProgress.Visible = true; prgProgress.Visible = true;
@@ -856,6 +864,7 @@ public partial class dlgAdd : Dialog
protected void OnBtnPackClicked(object sender, EventArgs e) protected void OnBtnPackClicked(object sender, EventArgs e)
{ {
btnRemoveFile.Sensitive = false; btnRemoveFile.Sensitive = false;
btnToggleCrack.Sensitive = false;
btnPack.Sensitive = false; btnPack.Sensitive = false;
btnClose.Sensitive = false; btnClose.Sensitive = false;
prgProgress.Visible = true; prgProgress.Visible = true;
@@ -948,6 +957,7 @@ public partial class dlgAdd : Dialog
thdPulseProgress.Abort(); thdPulseProgress.Abort();
btnRemoveFile.Sensitive = true; btnRemoveFile.Sensitive = true;
btnToggleCrack.Sensitive = true;
btnPack.Sensitive = true; btnPack.Sensitive = true;
btnClose.Sensitive = true; btnClose.Sensitive = true;
prgProgress.Visible = false; prgProgress.Visible = false;
@@ -1250,4 +1260,38 @@ public partial class dlgAdd : Dialog
fileView.Remove(ref fileIter); fileView.Remove(ref fileIter);
} }
} }
protected void OnBtnToggleCrackClicked(object sender, EventArgs e)
{
TreeIter fileIter;
if(treeFiles.Selection.GetSelected(out fileIter))
{
string name = (string)fileView.GetValue(fileIter, 0);
bool known = (bool)fileView.GetValue(fileIter, 2);
string color = (string)fileView.GetValue(fileIter, 3);
DBOSFile osfile;
if(Context.hashes.TryGetValue(name, out osfile))
{
osfile.Crack = !osfile.Crack;
Context.hashes.Remove(name);
Context.hashes.Add(name, osfile);
fileView.Remove(ref fileIter);
fileView.AppendValues(name, osfile.Sha256, known, color, "black", osfile.Crack);
}
}
}
void treeFilesSelectionChanged(object sender, EventArgs e)
{
TreeIter fileIter;
if(treeFiles.Selection.GetSelected(out fileIter))
{
if((bool)fileView.GetValue(fileIter, 5))
btnToggleCrack.Label = "Mark as not crack";
else
btnToggleCrack.Label = "Mark as crack";
}
}
} }

View File

@@ -135,7 +135,8 @@ namespace osrepodbmgr
treeFiles.AppendColumn(vtottimeColumn); treeFiles.AppendColumn(vtottimeColumn);
treeFiles.AppendColumn(virusColumn); treeFiles.AppendColumn(virusColumn);
treeFiles.Selection.Mode = SelectionMode.Multiple; treeFiles.Selection.Mode = SelectionMode.Single;
treeFiles.Selection.Changed += treeFilesSelectionChanged;
thdPulseProgress = new Thread(() => thdPulseProgress = new Thread(() =>
{ {
@@ -627,8 +628,26 @@ namespace osrepodbmgr
} }
} }
protected void OnBtnMarkAsCrackClicked(object sender, EventArgs e) protected void OnBtnToggleCrackClicked(object sender, EventArgs e)
{ {
TreeIter fileIter;
if(treeFiles.Selection.GetSelected(out fileIter))
{
string hash = (string)fileView.GetValue(fileIter, 0);
long length = (long)fileView.GetValue(fileIter, 1);
bool crack = !(bool)fileView.GetValue(fileIter, 2);
bool hasvirus = (bool)fileView.GetValue(fileIter, 3);
string clamtime = (string)fileView.GetValue(fileIter, 4);
string vttime = (string)fileView.GetValue(fileIter, 5);
string virus = (string)fileView.GetValue(fileIter, 6);
string color = (string)fileView.GetValue(fileIter, 7);
bool viruschecked = (bool)fileView.GetValue(fileIter, 9);
Workers.ToggleCrack(hash, crack);
fileView.Remove(ref fileIter);
fileView.AppendValues(hash, length, crack, hasvirus, clamtime, vttime, virus, color, "black", viruschecked);
}
} }
protected void OnBtnScanWithClamdClicked(object sender, EventArgs e) protected void OnBtnScanWithClamdClicked(object sender, EventArgs e)
@@ -642,7 +661,6 @@ namespace osrepodbmgr
protected void OnBtnPopulateFilesClicked(object sender, EventArgs e) protected void OnBtnPopulateFilesClicked(object sender, EventArgs e)
{ {
// TODO: Implement // TODO: Implement
btnMarkAsCrack.Sensitive = false;
btnScanWithClamd.Sensitive = false; btnScanWithClamd.Sensitive = false;
btnCheckInVirusTotal.Sensitive = false; btnCheckInVirusTotal.Sensitive = false;
@@ -795,7 +813,7 @@ namespace osrepodbmgr
lblProgressFiles2.Visible = false; lblProgressFiles2.Visible = false;
prgProgressFiles1.Visible = false; prgProgressFiles1.Visible = false;
prgProgressFiles2.Visible = false; prgProgressFiles2.Visible = false;
btnMarkAsCrack.Visible = true; btnToggleCrack.Visible = true;
btnScanWithClamd.Visible = true; btnScanWithClamd.Visible = true;
btnCheckInVirusTotal.Visible = true; btnCheckInVirusTotal.Visible = true;
btnStopFiles.Visible = false; btnStopFiles.Visible = false;
@@ -805,5 +823,17 @@ namespace osrepodbmgr
notebook1.GetNthPage(0).Sensitive = true; notebook1.GetNthPage(0).Sensitive = true;
}); });
} }
void treeFilesSelectionChanged(object sender, EventArgs e)
{
TreeIter fileIter;
if(treeFiles.Selection.GetSelected(out fileIter))
{
if((bool)fileView.GetValue(fileIter, 2))
btnToggleCrack.Label = "Mark as not crack";
else
btnToggleCrack.Label = "Mark as crack";
}
}
} }
} }

View File

@@ -111,6 +111,8 @@ public partial class dlgAdd
private global::Gtk.Button btnMetadata; private global::Gtk.Button btnMetadata;
private global::Gtk.Button btnToggleCrack;
private global::Gtk.Button btnRemoveFile; private global::Gtk.Button btnRemoveFile;
private global::Gtk.Button btnDialog; private global::Gtk.Button btnDialog;
@@ -641,6 +643,18 @@ public partial class dlgAdd
w57.Expand = false; w57.Expand = false;
w57.Fill = false; w57.Fill = false;
// Container child hbox1.Gtk.Box+BoxChild // Container child hbox1.Gtk.Box+BoxChild
this.btnToggleCrack = new global::Gtk.Button();
this.btnToggleCrack.CanFocus = true;
this.btnToggleCrack.Name = "btnToggleCrack";
this.btnToggleCrack.UseUnderline = true;
this.btnToggleCrack.Label = global::Mono.Unix.Catalog.GetString("Mark as crack");
this.hbox1.Add(this.btnToggleCrack);
global::Gtk.Box.BoxChild w58 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.btnToggleCrack]));
w58.PackType = ((global::Gtk.PackType)(1));
w58.Position = 7;
w58.Expand = false;
w58.Fill = false;
// Container child hbox1.Gtk.Box+BoxChild
this.btnRemoveFile = new global::Gtk.Button(); this.btnRemoveFile = new global::Gtk.Button();
this.btnRemoveFile.CanFocus = true; this.btnRemoveFile.CanFocus = true;
this.btnRemoveFile.Name = "btnRemoveFile"; this.btnRemoveFile.Name = "btnRemoveFile";
@@ -648,19 +662,19 @@ public partial class dlgAdd
this.btnRemoveFile.UseUnderline = true; this.btnRemoveFile.UseUnderline = true;
this.btnRemoveFile.Label = "gtk-remove"; this.btnRemoveFile.Label = "gtk-remove";
this.hbox1.Add(this.btnRemoveFile); this.hbox1.Add(this.btnRemoveFile);
global::Gtk.Box.BoxChild w58 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.btnRemoveFile])); global::Gtk.Box.BoxChild w59 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.btnRemoveFile]));
w58.PackType = ((global::Gtk.PackType)(1)); w59.PackType = ((global::Gtk.PackType)(1));
w58.Position = 7; w59.Position = 8;
w58.Expand = false;
w58.Fill = false;
w1.Add(this.hbox1);
global::Gtk.Box.BoxChild w59 = ((global::Gtk.Box.BoxChild)(w1[this.hbox1]));
w59.Position = 12;
w59.Expand = false; w59.Expand = false;
w59.Fill = false; w59.Fill = false;
w1.Add(this.hbox1);
global::Gtk.Box.BoxChild w60 = ((global::Gtk.Box.BoxChild)(w1[this.hbox1]));
w60.Position = 12;
w60.Expand = false;
w60.Fill = false;
// Internal child dlgAdd.ActionArea // Internal child dlgAdd.ActionArea
global::Gtk.HButtonBox w60 = this.ActionArea; global::Gtk.HButtonBox w61 = this.ActionArea;
w60.Name = "__gtksharp_108_Stetic_TopLevelDialog_ActionArea"; w61.Name = "__gtksharp_108_Stetic_TopLevelDialog_ActionArea";
// Container child __gtksharp_108_Stetic_TopLevelDialog_ActionArea.Gtk.ButtonBox+ButtonBoxChild // Container child __gtksharp_108_Stetic_TopLevelDialog_ActionArea.Gtk.ButtonBox+ButtonBoxChild
this.btnDialog = new global::Gtk.Button(); this.btnDialog = new global::Gtk.Button();
this.btnDialog.CanFocus = true; this.btnDialog.CanFocus = true;
@@ -668,9 +682,9 @@ public partial class dlgAdd
this.btnDialog.UseUnderline = true; this.btnDialog.UseUnderline = true;
this.btnDialog.Label = global::Mono.Unix.Catalog.GetString("GtkButton"); this.btnDialog.Label = global::Mono.Unix.Catalog.GetString("GtkButton");
this.AddActionWidget(this.btnDialog, 0); this.AddActionWidget(this.btnDialog, 0);
global::Gtk.ButtonBox.ButtonBoxChild w61 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w60[this.btnDialog])); global::Gtk.ButtonBox.ButtonBoxChild w62 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w61[this.btnDialog]));
w61.Expand = false; w62.Expand = false;
w61.Fill = false; w62.Fill = false;
if((this.Child != null)) if((this.Child != null))
{ {
this.Child.ShowAll(); this.Child.ShowAll();
@@ -685,11 +699,13 @@ public partial class dlgAdd
this.btnPack.Hide(); this.btnPack.Hide();
this.btnStop.Hide(); this.btnStop.Hide();
this.btnMetadata.Hide(); this.btnMetadata.Hide();
this.btnToggleCrack.Hide();
this.btnRemoveFile.Hide(); this.btnRemoveFile.Hide();
w60.Hide(); w61.Hide();
this.Show(); this.Show();
this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent); this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent);
this.btnRemoveFile.Clicked += new global::System.EventHandler(this.OnBtnRemoveFileClicked); this.btnRemoveFile.Clicked += new global::System.EventHandler(this.OnBtnRemoveFileClicked);
this.btnToggleCrack.Clicked += new global::System.EventHandler(this.OnBtnToggleCrackClicked);
this.btnMetadata.Clicked += new global::System.EventHandler(this.OnBtnMetadataClicked); this.btnMetadata.Clicked += new global::System.EventHandler(this.OnBtnMetadataClicked);
this.btnStop.Clicked += new global::System.EventHandler(this.OnBtnStopClicked); this.btnStop.Clicked += new global::System.EventHandler(this.OnBtnStopClicked);
this.btnFolder.Clicked += new global::System.EventHandler(this.OnBtnFolderClicked); this.btnFolder.Clicked += new global::System.EventHandler(this.OnBtnFolderClicked);

View File

@@ -24,8 +24,7 @@ namespace Stetic
{ {
return res; return res;
} }
else else {
{
int sz; int sz;
int sy; int sy;
global::Gtk.Icon.SizeLookup(size, out sz, out sy); global::Gtk.Icon.SizeLookup(size, out sz, out sy);
@@ -39,8 +38,7 @@ namespace Stetic
{ {
return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size); return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size);
} }
else else {
{
Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz); Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz);
Gdk.GC gc = new Gdk.GC(pmap); Gdk.GC gc = new Gdk.GC(pmap);
gc.RgbFgColor = new Gdk.Color(255, 255, 255); gc.RgbFgColor = new Gdk.Color(255, 255, 255);

View File

@@ -704,6 +704,24 @@
<property name="Fill">False</property> <property name="Fill">False</property>
</packing> </packing>
</child> </child>
<child>
<widget class="Gtk.Button" id="btnToggleCrack">
<property name="MemberName" />
<property name="Visible">False</property>
<property name="CanFocus">True</property>
<property name="Type">TextOnly</property>
<property name="Label" translatable="yes">Mark as crack</property>
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnBtnToggleCrackClicked" />
</widget>
<packing>
<property name="PackType">End</property>
<property name="Position">7</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
<child> <child>
<widget class="Gtk.Button" id="btnRemoveFile"> <widget class="Gtk.Button" id="btnRemoveFile">
<property name="MemberName" /> <property name="MemberName" />
@@ -717,7 +735,7 @@
</widget> </widget>
<packing> <packing>
<property name="PackType">End</property> <property name="PackType">End</property>
<property name="Position">7</property> <property name="Position">8</property>
<property name="AutoSize">True</property> <property name="AutoSize">True</property>
<property name="Expand">False</property> <property name="Expand">False</property>
<property name="Fill">False</property> <property name="Fill">False</property>
@@ -12768,14 +12786,14 @@ QNX/QNX/20090229/source.zip</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="Gtk.Button" id="btnMarkAsCrack"> <widget class="Gtk.Button" id="btnToggleCrack">
<property name="MemberName" /> <property name="MemberName" />
<property name="Visible">False</property> <property name="Visible">False</property>
<property name="CanFocus">True</property> <property name="CanFocus">True</property>
<property name="Type">TextOnly</property> <property name="Type">TextOnly</property>
<property name="Label" translatable="yes">Mark as crack</property> <property name="Label" translatable="yes">Mark as crack</property>
<property name="UseUnderline">True</property> <property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnBtnMarkAsCrackClicked" /> <signal name="Clicked" handler="OnBtnToggleCrackClicked" />
</widget> </widget>
<packing> <packing>
<property name="PackType">End</property> <property name="PackType">End</property>

View File

@@ -72,7 +72,7 @@ namespace osrepodbmgr
private global::Gtk.Button btnScanWithClamd; private global::Gtk.Button btnScanWithClamd;
private global::Gtk.Button btnMarkAsCrack; private global::Gtk.Button btnToggleCrack;
private global::Gtk.Button btnStopFiles; private global::Gtk.Button btnStopFiles;
@@ -389,13 +389,13 @@ namespace osrepodbmgr
w32.Expand = false; w32.Expand = false;
w32.Fill = false; w32.Fill = false;
// Container child hbox6.Gtk.Box+BoxChild // Container child hbox6.Gtk.Box+BoxChild
this.btnMarkAsCrack = new global::Gtk.Button(); this.btnToggleCrack = new global::Gtk.Button();
this.btnMarkAsCrack.CanFocus = true; this.btnToggleCrack.CanFocus = true;
this.btnMarkAsCrack.Name = "btnMarkAsCrack"; this.btnToggleCrack.Name = "btnToggleCrack";
this.btnMarkAsCrack.UseUnderline = true; this.btnToggleCrack.UseUnderline = true;
this.btnMarkAsCrack.Label = global::Mono.Unix.Catalog.GetString("Mark as crack"); this.btnToggleCrack.Label = global::Mono.Unix.Catalog.GetString("Mark as crack");
this.hbox6.Add(this.btnMarkAsCrack); this.hbox6.Add(this.btnToggleCrack);
global::Gtk.Box.BoxChild w33 = ((global::Gtk.Box.BoxChild)(this.hbox6[this.btnMarkAsCrack])); global::Gtk.Box.BoxChild w33 = ((global::Gtk.Box.BoxChild)(this.hbox6[this.btnToggleCrack]));
w33.PackType = ((global::Gtk.PackType)(1)); w33.PackType = ((global::Gtk.PackType)(1));
w33.Position = 3; w33.Position = 3;
w33.Expand = false; w33.Expand = false;
@@ -451,7 +451,7 @@ namespace osrepodbmgr
this.prgProgressFiles2.Hide(); this.prgProgressFiles2.Hide();
this.btnCheckInVirusTotal.Hide(); this.btnCheckInVirusTotal.Hide();
this.btnScanWithClamd.Hide(); this.btnScanWithClamd.Hide();
this.btnMarkAsCrack.Hide(); this.btnToggleCrack.Hide();
this.btnStopFiles.Hide(); this.btnStopFiles.Hide();
this.Show(); this.Show();
this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent); this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent);
@@ -464,7 +464,7 @@ namespace osrepodbmgr
this.btnSettings.Clicked += new global::System.EventHandler(this.OnBtnSettingsClicked); this.btnSettings.Clicked += new global::System.EventHandler(this.OnBtnSettingsClicked);
this.btnQuit.Clicked += new global::System.EventHandler(this.OnBtnQuitClicked); this.btnQuit.Clicked += new global::System.EventHandler(this.OnBtnQuitClicked);
this.btnStopFiles.Clicked += new global::System.EventHandler(this.OnBtnStopFilesClicked); this.btnStopFiles.Clicked += new global::System.EventHandler(this.OnBtnStopFilesClicked);
this.btnMarkAsCrack.Clicked += new global::System.EventHandler(this.OnBtnMarkAsCrackClicked); this.btnToggleCrack.Clicked += new global::System.EventHandler(this.OnBtnToggleCrackClicked);
this.btnScanWithClamd.Clicked += new global::System.EventHandler(this.OnBtnScanWithClamdClicked); this.btnScanWithClamd.Clicked += new global::System.EventHandler(this.OnBtnScanWithClamdClicked);
this.btnCheckInVirusTotal.Clicked += new global::System.EventHandler(this.OnBtnCheckInVirusTotalClicked); this.btnCheckInVirusTotal.Clicked += new global::System.EventHandler(this.OnBtnCheckInVirusTotalClicked);
this.btnPopulateFiles.Clicked += new global::System.EventHandler(this.OnBtnPopulateFilesClicked); this.btnPopulateFiles.Clicked += new global::System.EventHandler(this.OnBtnPopulateFilesClicked);