Skip to content

Commit

Permalink
Minor improvements to settings management
Browse files Browse the repository at this point in the history
  • Loading branch information
felipedaragon committed Feb 7, 2023
1 parent 7e80d69 commit 57d3d0a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packs/Resources/dialog_about.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<img filename="%iconfilename%" style="width:32px;height:32px;behavior:file-icon;-icon-size:'large';"><br><br>
<b>Syhunt &reg; %appname%</b><br><br>
%ver%<br><br>
Copyright &copy; 2021 Syhunt Application Security Company<br><br>
Copyright &copy; 2022 Syhunt Application Security Company<br><br>
URL: <a #abtlink href="#">%appurl%</a><br><br>
Made possible by the <a #crmlink href="#">Chromium</a> project and other open source projects.<br><br>
<hr width="100%">
Expand Down
2 changes: 2 additions & 0 deletions packs/Resources/dialog_prefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ function M:EditCustom(t)
if self.confirmed == true then
-- tells the browser that the settings have changed
prefs.update()
-- save the new settings to the disk
prefs.save()
else
-- dialog closed or cancel clicked; keep previous settings
prefs.load(self.backup)
Expand Down
17 changes: 15 additions & 2 deletions packs/Resources/dialog_prefs.tis
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,24 @@
Sandcat.PrefsSet(cid,value);
}
}
function update_option_string(e,value) {
var cid = e.attributes["cid"];
var atype = e.attributes["type"];
if (cid != undefined) {
if (value == null) {
if (atype != "number") {
value = "";
}
}
Sandcat.Debug("Updating option "+cid+" with new value: "+value);
Sandcat.PrefsSet(cid,value);
}
}
function handle_controlevent(evt) {
switch(evt.type)
{
case Event.EDIT_VALUE_CHANGED: update_option(this,this.value); return true;
case Event.SELECT_SELECTION_CHANGED: update_option(this,this.value); return true;
case Event.EDIT_VALUE_CHANGED: update_option_string(this,this.value); return true;
case Event.SELECT_SELECTION_CHANGED: update_option_string(this,this.value); return true;
case Event.BUTTON_STATE_CHANGED: update_option(this,this.value); return true;
}
}
Expand Down
5 changes: 5 additions & 0 deletions packs/Resources/histview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ function M:ImportURLLogFileItem(list, line, fileext)
item.url = self:MakeValidURL(line)
self:AddURLLogItemToList(list, item)
end
if fileext == '.list' then
item = {}
item.url = self:MakeValidURL(line)
self:AddURLLogItemToList(list, item)
end
if fileext == '.csv' then
local csv = ctk.string.loop:new()
csv.commatext = line
Expand Down
Binary file modified src/Sandcat.res
Binary file not shown.
15 changes: 9 additions & 6 deletions src/core/uSettings.pas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
unit uSettings;
{
Sandcat Settings Manager
Copyright (c) 2011-2014, Syhunt Informatica
Copyright (c) 2011-2023, Syhunt Informatica
License: 3-clause BSD license
See https://github.com/felipedaragon/sandcat/ for details.
}
Expand Down Expand Up @@ -95,7 +95,7 @@ procedure OnbeforeCmdLine(const processType: ustring;
implementation

uses uMain, uMisc, uConst, CatChromium, CatChromiumLib, CatUI, CatTime,
CatStrings, CatFiles, CatHTTP;
CatStrings, CatFiles, CatHTTP, CatHashes;

procedure OnbeforeCmdLine(const processType: ustring;
const commandLine: ICefCommandLine);
Expand Down Expand Up @@ -197,12 +197,15 @@ procedure TSandcatSettings.OnbeforeCmdLineWACEF(const processType: ustring;
end;

// Returns the filename of a site preferences file. This is a JSON file that
// can be used for storing user preferences for each specific host:port
// can be used for storing user preferences for each specific URL
function TSandcatSettings.GetSitePrefsFilename(const url: string): string;
var p:TURLparts;
begin
result := Format('%s [%s].json', [ExtractURLHost(url),
IntToStr(ExtractURLPort(url))]);
result := CleanFilename(result);
p := CrackURL(url);
result := Format('%s [%s]', [p.Host, inttostr(p.Port)]);
if (p.Path<>emptystr) and (p.path <>'/') then
result := result+' ['+MD5Hash(p.Path)+']';
result := CleanFilename(result)+'.json';
result := GetSandcatDir(SCDIR_CONFIGSITE, true) + result;
end;

Expand Down
7 changes: 4 additions & 3 deletions src/lua/LAPI_App.pas
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function app_seticonfromfile(L: plua_State): Integer; cdecl;
implementation

uses uMain, uConst, uSettings, uExtensions, CatStrings, CatListEditor, pLua,
uZones, LAPI, CatFiles, CatUI;
uZones, LAPI, CatFiles, CatUI, CatStringLoop;

type
TAppInfoType = (info_abouturl, info_cachedir, info_ceflibrary, info_configdir,
Expand Down Expand Up @@ -354,11 +354,12 @@ function app_showsavedialog(L: plua_State): Integer; cdecl;
f := replacestr(f, '\\', '\');
sd := tsavedialog.Create(SandBrowser);
sd.InitialDir := emptystr;
sd.DefaultExt := lua_tostring(L, 2); // eg 'cfg'
sd.FileName := f;
sd.DefaultExt := lua_tostring(L, 2); // eg 'cfg'
sd.Options := sd.Options + [ofoverwriteprompt];
// showmessage(lua_tostring(L,1));
sd.Filter := lua_tostring(L, 1);
sd.FilterIndex := GetDialogFilterIndexByExt(sd.filter,sd.DefaultExt);
// showmessage(lua_tostring(L,1));
// eg filter format: 'Sandcat Configuration File (*.xcfg)|*.xcfg'
if sd.execute then
lua_pushstring(L, sd.FileName)
Expand Down

0 comments on commit 57d3d0a

Please sign in to comment.