[GB.QT4.WEBKIT]
* NEW: WebSettings.Cache.Path now must be located inside the '~/.cache' directory. * NEW: WebSettings.Cache.Clear() is a new method to clear the cache. git-svn-id: svn://localhost/gambas/trunk@6445 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
3438c89f85
commit
04f054c93e
@ -23,6 +23,8 @@
|
||||
|
||||
#define __CWEBSETTINGS_CPP
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <QNetworkDiskCache>
|
||||
#include <QNetworkProxy>
|
||||
|
||||
@ -189,6 +191,18 @@ BEGIN_PROPERTY(WebSettingsCache_Path)
|
||||
GB.ReturnString(_cache_path);
|
||||
else
|
||||
{
|
||||
QString path = QSTRING_PROP();
|
||||
QString root = QString(GB.System.Home());
|
||||
|
||||
if (root.at(root.length() - 1) != '/')
|
||||
root += '/';
|
||||
root += ".cache/";
|
||||
if (!path.startsWith(root))
|
||||
{
|
||||
GB.Error("Cache directory must be located inside ~/.cache");
|
||||
return;
|
||||
}
|
||||
|
||||
GB.StoreString(PROP(GB_STRING), &_cache_path);
|
||||
set_cache(_cache_enabled);
|
||||
}
|
||||
@ -204,6 +218,21 @@ BEGIN_PROPERTY(WebSettingsCache_Enabled)
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
static void remove_file(const char *path)
|
||||
{
|
||||
if (unlink(path))
|
||||
rmdir(path);
|
||||
}
|
||||
|
||||
BEGIN_METHOD_VOID(WebSettingsCache_Clear)
|
||||
|
||||
if (!_cache_path || !*_cache_path)
|
||||
return;
|
||||
|
||||
GB.BrowseDirectory(_cache_path, NULL, remove_file);
|
||||
|
||||
END_METHOD
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -373,6 +402,7 @@ GB_DESC CWebSettingsCacheDesc[] =
|
||||
|
||||
GB_STATIC_PROPERTY("Enabled", "b", WebSettingsCache_Enabled),
|
||||
GB_STATIC_PROPERTY("Path", "s", WebSettingsCache_Path),
|
||||
GB_STATIC_METHOD("Clear", NULL, WebSettingsCache_Clear, NULL),
|
||||
|
||||
GB_END_DECLARE
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user