summaryrefslogtreecommitdiffstats
path: root/rbutil
diff options
context:
space:
mode:
authorAntoine Cellerier <dionoea@videolan.org>2007-09-14 22:16:22 +0000
committerAntoine Cellerier <dionoea@videolan.org>2007-09-14 22:16:22 +0000
commit554f0c3771ecee9a183fa07d6e44483205b87d8a (patch)
tree408acf273ef3c697b810dda985b93a6b7777cefb /rbutil
parente6b8347a4d6fab01d77914ae2e7daf5635152d69 (diff)
downloadrockbox-554f0c3771ecee9a183fa07d6e44483205b87d8a.tar.gz
rockbox-554f0c3771ecee9a183fa07d6e44483205b87d8a.tar.bz2
rockbox-554f0c3771ecee9a183fa07d6e44483205b87d8a.zip
If caching is disabled, still cache theme info and images in a temporary directory (which will be deleted once rbutil is closed) to prevent downling them every time the theme selection changes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14704 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/rbutilqt/installthemes.cpp19
-rw-r--r--rbutil/rbutilqt/installthemes.h7
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro2
-rw-r--r--rbutil/rbutilqt/uninstall.cpp39
-rw-r--r--rbutil/rbutilqt/uninstall.h2
-rw-r--r--rbutil/rbutilqt/utils.cpp45
-rw-r--r--rbutil/rbutilqt/utils.h29
7 files changed, 106 insertions, 37 deletions
diff --git a/rbutil/rbutilqt/installthemes.cpp b/rbutil/rbutilqt/installthemes.cpp
index ba6b7f9f5a..15a74f915c 100644
--- a/rbutil/rbutilqt/installthemes.cpp
+++ b/rbutil/rbutilqt/installthemes.cpp
@@ -23,7 +23,7 @@
#include "installthemes.h"
#include "installzip.h"
#include "progressloggergui.h"
-
+#include "utils.h"
ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent)
{
@@ -32,11 +32,16 @@ ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent)
ui.listThemes->setSelectionMode(QAbstractItemView::ExtendedSelection);
ui.themePreview->clear();
ui.themePreview->setText(tr("no theme selected"));
-
+
connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(close()));
connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
}
+ThemesInstallWindow::~ThemesInstallWindow()
+{
+ if(infocachedir!="")
+ recRmdir(infocachedir);
+}
QString ThemesInstallWindow::resolution()
{
@@ -186,6 +191,16 @@ void ThemesInstallWindow::updateDetails(int row)
igetter.setProxy(proxy);
if(!userSettings->value("cachedisable").toBool())
igetter.setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
+ else
+ {
+ if(infocachedir=="")
+ {
+ infocachedir = QDir::tempPath()+"rbutil-themeinfo";
+ QDir d = QDir::temp();
+ d.mkdir("rbutil-themeinfo");
+ }
+ igetter.setCache(infocachedir);
+ }
igetter.getFile(img);
connect(&igetter, SIGNAL(done(bool)), this, SLOT(updateImage(bool)));
}
diff --git a/rbutil/rbutilqt/installthemes.h b/rbutil/rbutilqt/installthemes.h
index da6ad86485..0d24d5cae2 100644
--- a/rbutil/rbutilqt/installthemes.h
+++ b/rbutil/rbutilqt/installthemes.h
@@ -34,13 +34,14 @@ class ThemesInstallWindow : public QDialog
public:
ThemesInstallWindow(QWidget* parent = 0);
+ ~ThemesInstallWindow();
void setDeviceSettings(QSettings*);
void setUserSettings(QSettings *);
void setProxy(QUrl);
void downloadInfo(void);
void show(void);
void accept(void);
-
+
public slots:
private:
@@ -59,7 +60,9 @@ class ThemesInstallWindow : public QDialog
ZipInstaller *installer;
QString file;
QString fileName;
-
+
+ QString infocachedir;
+
private slots:
void downloadDone(bool);
void downloadDone(int, bool);
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index 2d0bd7633b..4b49f1cf63 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -33,6 +33,7 @@ SOURCES += rbutilqt.cpp \
installthemes.cpp \
uninstall.cpp \
uninstallwindow.cpp \
+ utils.cpp \
browseof.cpp \
preview.cpp
@@ -68,6 +69,7 @@ HEADERS += rbutilqt.h \
installthemes.h \
uninstall.h \
uninstallwindow.h \
+ utils.h \
browseof.h \
preview.h
diff --git a/rbutil/rbutilqt/uninstall.cpp b/rbutil/rbutilqt/uninstall.cpp
index ad31e1db38..2e96d49081 100644
--- a/rbutil/rbutilqt/uninstall.cpp
+++ b/rbutil/rbutilqt/uninstall.cpp
@@ -16,11 +16,11 @@
* KIND, either express or implied.
*
****************************************************************************/
-
-#include "uninstall.h"
+#include "uninstall.h"
+#include "utils.h"
-Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent)
+Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent)
{
m_mountpoint = mountpoint;
}
@@ -37,45 +37,22 @@ void Uninstaller::deleteAll(ProgressloggerInterface* dp)
m_dp->addItem(tr("Finished Uninstallation"),LOGOK);
m_dp->abort();
}
-// recursiv function to delete a dir with files
-bool Uninstaller::recRmdir( QString &dirName )
-{
- QString dirN = dirName;
- QDir dir(dirN);
- QStringList list = dir.entryList(QDir::AllEntries); // make list of entries in directory
- QFileInfo fileInfo;
- QString curItem, lstAt;
- for(int i = 0; i < list.size(); i++){ // loop through all items of list
- QString name = list.at(i);
- if(!(name == ".") && !(name == "..")){
- curItem = dirN + "/" + name;
- fileInfo.setFile(curItem);
- if(fileInfo.isDir()) // is directory
- recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory
- else // is file
- QFile::remove(curItem); // ok, delete file
- }
- }
- dir.cdUp();
- return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull
-}
-
void Uninstaller::uninstall(ProgressloggerInterface* dp)
{
m_dp = dp;
m_dp->setProgressMax(0);
m_dp->addItem(tr("Starting Uninstallation"),LOGINFO);
-
+
QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
-
+
for(int i=0; i< uninstallSections.size() ; i++)
{
m_dp->addItem(tr("Uninstalling ") + uninstallSections.at(i) + " ...",LOGINFO);
installlog.beginGroup(uninstallSections.at(i));
QStringList toDeleteList = installlog.allKeys();
QStringList dirList;
-
+
// iterate over all entrys
for(int j =0; j < toDeleteList.size(); j++ )
{
@@ -101,7 +78,7 @@ void Uninstaller::uninstall(ProgressloggerInterface* dp)
installlog.endGroup();
//installlog.removeGroup(uninstallSections.at(i))
- }
+ }
uninstallSections.clear();
installlog.sync();
m_dp->setProgressMax(1);
@@ -121,5 +98,5 @@ QStringList Uninstaller::getAllSections()
bool Uninstaller::uninstallPossible()
{
- return QFileInfo(m_mountpoint +"/.rockbox/rbutil.log").exists();
+ return QFileInfo(m_mountpoint +"/.rockbox/rbutil.log").exists();
}
diff --git a/rbutil/rbutilqt/uninstall.h b/rbutil/rbutilqt/uninstall.h
index eee7bda5a6..4c774876e3 100644
--- a/rbutil/rbutilqt/uninstall.h
+++ b/rbutil/rbutilqt/uninstall.h
@@ -50,8 +50,6 @@ private slots:
private:
- bool recRmdir( QString &dirName );
-
QString m_mountpoint;
QStringList uninstallSections;
diff --git a/rbutil/rbutilqt/utils.cpp b/rbutil/rbutilqt/utils.cpp
new file mode 100644
index 0000000000..c7c8371274
--- /dev/null
+++ b/rbutil/rbutilqt/utils.cpp
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id$
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "utils.h"
+
+#include <QDir>
+
+// recursive function to delete a dir with files
+bool recRmdir( const QString &dirName )
+{
+ QString dirN = dirName;
+ QDir dir(dirN);
+ QStringList list = dir.entryList(QDir::AllEntries); // make list of entries in directory
+ QFileInfo fileInfo;
+ QString curItem, lstAt;
+ for(int i = 0; i < list.size(); i++){ // loop through all items of list
+ QString name = list.at(i);
+ if(!(name == ".") && !(name == "..")){
+ curItem = dirN + "/" + name;
+ fileInfo.setFile(curItem);
+ if(fileInfo.isDir()) // is directory
+ recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory
+ else // is file
+ QFile::remove(curItem); // ok, delete file
+ }
+ }
+ dir.cdUp();
+ return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull
+}
diff --git a/rbutil/rbutilqt/utils.h b/rbutil/rbutilqt/utils.h
new file mode 100644
index 0000000000..2c2ae97079
--- /dev/null
+++ b/rbutil/rbutilqt/utils.h
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id$
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <QString>
+
+bool recRmdir( const QString &dirName );
+
+#endif
+