PDA

View Full Version : How to enable the offline storage feature?



djstava
30th January 2011, 10:38
I compile qt4.7.1 and demos/browser,and use the browser to test the html5 offline cache,but it doesn't work.

I add some statements in BrowserApplication::loadSettings() function like this:


defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseE nabled,true);
defaultSettings->setAttribute(QWebSettings::OfflineWebApplicationCa cheEnabled,true);
defaultSettings->setAttribute(QWebSettings::LocalStorageEnabled,tru e);
defaultSettings->setOfflineStoragePath("/root/offline");
defaultSettings->setOfflineWebApplicationCachePath("/root/offline");
defaultSettings->setLocalStoragePath("/root/offline");
defaultSettings->setOfflineStorageDefaultQuota(5*1024*1024);
defaultSettings->setOfflineWebApplicationCacheQuota(5*1024*1024);


I've no idea about the difference between OfflineStorage and OfflineWebApplicationCache.So,I add them both.

Any ideas?Thanks.

tbscope
30th January 2011, 10:41
Can you write to that path as a non root user?

djstava
30th January 2011, 14:24
Not work either.Is anything missing?
I compile qt for x11 with configure -debug.

tbscope
30th January 2011, 21:47
Can you please respond in full sentences and with context?
Otherwise it will be very hard for people to understand you.

What didn't work either?
Why do you think anything is missing?
What does compiling Qt with the -debug flag have to do with this?

I don't know where this path comes from, but most likely, you can not write to it from a normal user account.

djstava
31st January 2011, 02:36
Can you please respond in full sentences and with context?
Otherwise it will be very hard for people to understand you.

What didn't work either?
Why do you think anything is missing?
What does compiling Qt with the -debug flag have to do with this?

I don't know where this path comes from, but most likely, you can not write to it from a normal user account.

Sorry for that.
I login as root,so have the privillege to write the path /root/offline,and after I set this
in BrowserApplication::loadSettings()


defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseE nabled,true); defaultSettings->setAttribute(QWebSettings::OfflineWebApplicationCa cheEnabled,true);
defaultSettings->setAttribute(QWebSettings::LocalStorageEnabled,tru e);
defaultSettings->setOfflineStoragePath("/home/offline");
defaultSettings->setOfflineWebApplicationCachePath("/home/offline");
defaultSettings->setLocalStoragePath("/home/offline");
defaultSettings->setOfflineStorageDefaultQuota(5*1024*1024);
defaultSettings->setOfflineWebApplicationCacheQuota(5*1024*1024);

There is a db file named ApplicationCache.db in the dir /home/offline.that may mean offlineWebApplicationCache works,am I right?
I setup apache tomcat6.0,and use the chrome to test html5 cache,it's ok.According to the QT Reference Document QWebSettings Class,it should also support.
I want to know whether what I've done is right?Thank you.

djstava
31st January 2011, 05:24
It seems demobrowser can not use web application cache when it restarts.

Andrey Chernyshev
2nd February 2013, 20:47
I've got the offline storage working after I made:

webView->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
webView->settings()->enablePersistentStorage(QDir::homePath());

Other settings (setOfflineStorageDefaultQuota e.t.c.) seem to be optional.
(one may want to change homePath to something better :))

srav219
8th March 2013, 06:49
Hi,
I am trying to enable application cache(offline webstorage) by just with the following api settings()->enablePersistentStorage("C:\\dd\\");
With this api,I should see LocalStorage and ApplicationStorage folders in C:\dd .But I am seeing only LocalStorage folder in the C:\dd.

I have even tried with the below code
settings()->enablePersistentStorage("C:\\dd\\");
settings()->setOfflineWebApplicationCachePath("C:\\dd\\AppCache");
I dont see any AppCache folder in C:\dd directory

Can anyone help me what has gone wrong ...

wysota
8th March 2013, 10:54
Maybe it gets created on the first use.