diff options
author | Dominik Wenger <domonoky@googlemail.com> | 2007-08-12 16:47:35 +0000 |
---|---|---|
committer | Dominik Wenger <domonoky@googlemail.com> | 2007-08-12 16:47:35 +0000 |
commit | e40b4df1406b70a4c54b67d279ae8654a0341a32 (patch) | |
tree | 07ce63b96fbca9d8fb180bda44722fc0e2148a6e /rbutil/rbutilqt | |
parent | 451dec17fe2be8dace913f6a88bbf489d50deeef (diff) | |
download | rockbox-e40b4df1406b70a4c54b67d279ae8654a0341a32.tar.gz rockbox-e40b4df1406b70a4c54b67d279ae8654a0341a32.zip |
rbutilQt:Ups.. the forgotten uninstall files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14296 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r-- | rbutil/rbutilqt/uninstall.cpp | 123 | ||||
-rw-r--r-- | rbutil/rbutilqt/uninstall.h | 65 | ||||
-rw-r--r-- | rbutil/rbutilqt/uninstallwindow.cpp | 96 | ||||
-rw-r--r-- | rbutil/rbutilqt/uninstallwindow.h | 55 |
4 files changed, 339 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/uninstall.cpp b/rbutil/rbutilqt/uninstall.cpp new file mode 100644 index 0000000000..ce9995370d --- /dev/null +++ b/rbutil/rbutilqt/uninstall.cpp | |||
@@ -0,0 +1,123 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id: uninstall.cpp 13990 2007-07-25 22:26:10Z Dominik Wenger $ | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "uninstall.h" | ||
21 | |||
22 | |||
23 | Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent) | ||
24 | { | ||
25 | m_mountpoint = mountpoint; | ||
26 | } | ||
27 | |||
28 | void Uninstaller::deleteAll(ProgressloggerInterface* dp) | ||
29 | { | ||
30 | m_dp = dp; | ||
31 | QString rbdir(m_mountpoint + ".rockbox/"); | ||
32 | m_dp->addItem(tr("Starting Uninstallation"),LOGINFO); | ||
33 | m_dp->setProgressMax(0); | ||
34 | recRmdir(rbdir); | ||
35 | m_dp->setProgressMax(1); | ||
36 | m_dp->setProgressValue(1); | ||
37 | m_dp->addItem(tr("Finished Uninstallation"),LOGOK); | ||
38 | m_dp->abort(); | ||
39 | } | ||
40 | // recursiv function to delete a dir with files | ||
41 | bool Uninstaller::recRmdir( QString &dirName ) | ||
42 | { | ||
43 | QString dirN = dirName; | ||
44 | QDir dir(dirN); | ||
45 | QStringList list = dir.entryList(QDir::AllEntries); // make list of entries in directory | ||
46 | QFileInfo fileInfo; | ||
47 | QString curItem, lstAt; | ||
48 | for(int i = 0; i < list.size(); i++){ // loop through all items of list | ||
49 | QString name = list.at(i); | ||
50 | if(!(name == ".") && !(name == "..")){ | ||
51 | curItem = dirN + "/" + name; | ||
52 | fileInfo.setFile(curItem); | ||
53 | if(fileInfo.isDir()) // is directory | ||
54 | recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory | ||
55 | else // is file | ||
56 | QFile::remove(curItem); // ok, delete file | ||
57 | } | ||
58 | } | ||
59 | dir.cdUp(); | ||
60 | return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull | ||
61 | } | ||
62 | |||
63 | |||
64 | void Uninstaller::uninstall(ProgressloggerInterface* dp) | ||
65 | { | ||
66 | m_dp = dp; | ||
67 | m_dp->setProgressMax(0); | ||
68 | m_dp->addItem(tr("Starting Uninstallation"),LOGINFO); | ||
69 | |||
70 | QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); | ||
71 | |||
72 | for(int i=0; i< uninstallSections.size() ; i++) | ||
73 | { | ||
74 | m_dp->addItem(tr("Uninstalling ") + uninstallSections.at(i) + " ...",LOGINFO); | ||
75 | installlog.beginGroup(uninstallSections.at(i)); | ||
76 | QStringList toDeleteList = installlog.allKeys(); | ||
77 | QStringList dirList; | ||
78 | |||
79 | // iterate over all entrys | ||
80 | for(int j =0; j < toDeleteList.size(); j++ ) | ||
81 | { | ||
82 | QFileInfo toDelete(m_mountpoint + "/" + toDeleteList.at(j)); | ||
83 | if(toDelete.isFile()) // if it is a file remove it | ||
84 | { | ||
85 | if(!QFile::remove(toDelete.filePath())) | ||
86 | m_dp->addItem(tr("Could not delete: ")+ toDelete.filePath(),LOGWARNING); | ||
87 | installlog.remove(toDeleteList.at(j)); | ||
88 | } | ||
89 | else // if it is a dir, remember it for later deletion | ||
90 | { | ||
91 | dirList << toDeleteList.at(j); | ||
92 | } | ||
93 | } | ||
94 | // delete the dirs | ||
95 | for(int j=0; j < dirList.size(); j++ ) | ||
96 | { | ||
97 | installlog.remove(dirList.at(j)); | ||
98 | QDir dir(m_mountpoint); | ||
99 | dir.rmdir(dirList.at(j)); | ||
100 | } | ||
101 | |||
102 | installlog.endGroup(); | ||
103 | //installlog.removeGroup(uninstallSections.at(i)) | ||
104 | } | ||
105 | uninstallSections.clear(); | ||
106 | installlog.sync(); | ||
107 | m_dp->setProgressMax(1); | ||
108 | m_dp->setProgressValue(1); | ||
109 | m_dp->addItem(tr("Uninstallation finished"),LOGOK); | ||
110 | m_dp->abort(); | ||
111 | } | ||
112 | |||
113 | QStringList Uninstaller::getAllSections() | ||
114 | { | ||
115 | QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); | ||
116 | return installlog.childGroups(); | ||
117 | } | ||
118 | |||
119 | |||
120 | bool Uninstaller::uninstallPossible() | ||
121 | { | ||
122 | return QFileInfo(m_mountpoint +"/.rockbox/rbutil.log").exists(); | ||
123 | } | ||
diff --git a/rbutil/rbutilqt/uninstall.h b/rbutil/rbutilqt/uninstall.h new file mode 100644 index 0000000000..93040eab12 --- /dev/null +++ b/rbutil/rbutilqt/uninstall.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id: uninstall.h 13990 2007-07-25 22:26:10Z Dominik Wenger $ | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | |||
21 | #ifndef UNINSTALL_H | ||
22 | #define UNINSTALL_H | ||
23 | |||
24 | |||
25 | |||
26 | #include <QtGui> | ||
27 | |||
28 | |||
29 | #include "progressloggerinterface.h" | ||
30 | |||
31 | |||
32 | class Uninstaller : public QObject | ||
33 | { | ||
34 | Q_OBJECT | ||
35 | public: | ||
36 | Uninstaller(QObject* parent,QString mountpoint) ; | ||
37 | ~Uninstaller(){} | ||
38 | |||
39 | void deleteAll(ProgressloggerInterface* dp); | ||
40 | void uninstall(ProgressloggerInterface* dp); | ||
41 | |||
42 | bool uninstallPossible(); | ||
43 | |||
44 | QStringList getAllSections(); | ||
45 | |||
46 | void setSections(QStringList sections) {uninstallSections = sections;} | ||
47 | |||
48 | |||
49 | private slots: | ||
50 | |||
51 | |||
52 | private: | ||
53 | bool recRmdir( QString &dirName ); | ||
54 | |||
55 | QString m_mountpoint; | ||
56 | |||
57 | QStringList uninstallSections; | ||
58 | |||
59 | ProgressloggerInterface* m_dp; | ||
60 | }; | ||
61 | |||
62 | |||
63 | |||
64 | #endif | ||
65 | |||
diff --git a/rbutil/rbutilqt/uninstallwindow.cpp b/rbutil/rbutilqt/uninstallwindow.cpp new file mode 100644 index 0000000000..18fc863159 --- /dev/null +++ b/rbutil/rbutilqt/uninstallwindow.cpp | |||
@@ -0,0 +1,96 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Riebeling | ||
10 | * $Id: uninstallwindow.cpp 14151 2007-08-02 22:27:51Z bluebrother $ | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "uninstallwindow.h" | ||
21 | #include "ui_uninstallfrm.h" | ||
22 | |||
23 | |||
24 | UninstallWindow::UninstallWindow(QWidget *parent) : QDialog(parent) | ||
25 | { | ||
26 | ui.setupUi(this); | ||
27 | |||
28 | connect(ui.UninstalllistWidget,SIGNAL(itemSelectionChanged()),this,SLOT(selectionChanged())); | ||
29 | connect(ui.CompleteRadioBtn,SIGNAL(toggled(bool)),this,SLOT(UninstallMethodChanged(bool))); | ||
30 | } | ||
31 | |||
32 | |||
33 | void UninstallWindow::accept() | ||
34 | { | ||
35 | logger = new ProgressLoggerGui(this); | ||
36 | logger->show(); | ||
37 | |||
38 | if(ui.CompleteRadioBtn->isChecked()) | ||
39 | { | ||
40 | uninstaller->deleteAll(logger); | ||
41 | } | ||
42 | else | ||
43 | { | ||
44 | uninstaller->uninstall(logger); | ||
45 | } | ||
46 | connect(logger,SIGNAL(closed()),this,SLOT(close())); | ||
47 | } | ||
48 | |||
49 | |||
50 | void UninstallWindow::selectionChanged() | ||
51 | { | ||
52 | QList<QListWidgetItem *> itemlist = ui.UninstalllistWidget->selectedItems(); | ||
53 | QStringList seletedStrings; | ||
54 | for(int i=0;i < itemlist.size(); i++ ) | ||
55 | { | ||
56 | seletedStrings << itemlist.at(i)->text(); | ||
57 | } | ||
58 | |||
59 | uninstaller->setSections(seletedStrings); | ||
60 | } | ||
61 | |||
62 | void UninstallWindow::UninstallMethodChanged(bool complete) | ||
63 | { | ||
64 | if(complete) | ||
65 | ui.smartGroupBox->setEnabled(false); | ||
66 | else | ||
67 | ui.smartGroupBox->setEnabled(true); | ||
68 | } | ||
69 | |||
70 | void UninstallWindow::setDeviceSettings(QSettings *dev) | ||
71 | { | ||
72 | devices = dev; | ||
73 | qDebug() << "Install::setDeviceSettings:" << devices; | ||
74 | } | ||
75 | |||
76 | |||
77 | void UninstallWindow::setUserSettings(QSettings *user) | ||
78 | { | ||
79 | userSettings = user; | ||
80 | |||
81 | QString mountpoint =userSettings->value("defaults/mountpoint").toString(); | ||
82 | uninstaller = new Uninstaller(this,mountpoint); | ||
83 | |||
84 | // disable smart uninstall, if not possible | ||
85 | if(!uninstaller->uninstallPossible()) | ||
86 | { | ||
87 | ui.smartRadioButton->setEnabled(false); | ||
88 | ui.smartGroupBox->setEnabled(false); | ||
89 | ui.CompleteRadioBtn->setChecked(true); | ||
90 | } | ||
91 | else // fill in installed parts | ||
92 | { | ||
93 | ui.smartRadioButton->setChecked(true); | ||
94 | ui.UninstalllistWidget->addItems(uninstaller->getAllSections()); | ||
95 | } | ||
96 | } | ||
diff --git a/rbutil/rbutilqt/uninstallwindow.h b/rbutil/rbutilqt/uninstallwindow.h new file mode 100644 index 0000000000..177ff8db76 --- /dev/null +++ b/rbutil/rbutilqt/uninstallwindow.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2007 by Dominik Wenger | ||
10 | * $Id: uninstallwindow.h 14151 2007-08-02 22:27:51Z domonoky $ | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #ifndef UNINSTALLWINDOW_H | ||
21 | #define UNINSTALLWINDOW_H | ||
22 | |||
23 | #include <QtGui> | ||
24 | |||
25 | #include <QSettings> | ||
26 | |||
27 | #include "ui_uninstallfrm.h" | ||
28 | #include "progressloggergui.h" | ||
29 | #include "uninstall.h" | ||
30 | |||
31 | class UninstallWindow : public QDialog | ||
32 | { | ||
33 | Q_OBJECT | ||
34 | public: | ||
35 | UninstallWindow(QWidget *parent = 0); | ||
36 | void setUserSettings(QSettings*); | ||
37 | void setDeviceSettings(QSettings*); | ||
38 | |||
39 | public slots: | ||
40 | void accept(void); | ||
41 | |||
42 | private slots: | ||
43 | void selectionChanged(); | ||
44 | void UninstallMethodChanged(bool complete); | ||
45 | private: | ||
46 | Uninstaller* uninstaller; | ||
47 | Ui::UninstallFrm ui; | ||
48 | ProgressLoggerGui* logger; | ||
49 | QSettings *devices; | ||
50 | QSettings *userSettings; | ||
51 | |||
52 | }; | ||
53 | |||
54 | |||
55 | #endif | ||