diff options
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/rbutilqt/installrb.cpp | 118 | ||||
-rw-r--r-- | rbutil/rbutilqt/installrb.h | 80 |
2 files changed, 100 insertions, 98 deletions
diff --git a/rbutil/rbutilqt/installrb.cpp b/rbutil/rbutilqt/installrb.cpp index 401722deb1..8fa977f524 100644 --- a/rbutil/rbutilqt/installrb.cpp +++ b/rbutil/rbutilqt/installrb.cpp | |||
@@ -1,4 +1,6 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
2 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
3 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
4 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
@@ -13,29 +15,29 @@ | |||
13 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
14 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
15 | * | 17 | * |
16 | ****************************************************************************/ | 18 | ****************************************************************************/ |
17 | 19 | ||
18 | #include "installrb.h" | 20 | #include "installrb.h" |
19 | 21 | ||
20 | #include "zip/zip.h" | 22 | #include "zip/zip.h" |
21 | #include "zip/unzip.h" | 23 | #include "zip/unzip.h" |
22 | 24 | ||
23 | RBInstaller::RBInstaller(QObject* parent): QObject(parent) | 25 | RBInstaller::RBInstaller(QObject* parent): QObject(parent) |
24 | { | 26 | { |
25 | 27 | ||
26 | } | 28 | } |
27 | 29 | ||
28 | 30 | ||
29 | void RBInstaller::install(QString url,QString file,QString mountpoint, QUrl proxy,Ui::InstallProgressFrm* dp) | 31 | void RBInstaller::install(QString url,QString file,QString mountpoint, QUrl proxy,Ui::InstallProgressFrm* dp) |
30 | { | 32 | { |
31 | m_url=url; | 33 | m_url=url; |
32 | m_mountpoint = mountpoint; | 34 | m_mountpoint = mountpoint; |
33 | m_file = file; | 35 | m_file = file; |
34 | m_dp = dp; | 36 | m_dp = dp; |
35 | 37 | ||
36 | m_dp->listProgress->addItem(tr("Downloading file %1.%2") | 38 | m_dp->listProgress->addItem(tr("Downloading file %1.%2") |
37 | .arg(QFileInfo(m_url).baseName(), QFileInfo(m_url).completeSuffix())); | 39 | .arg(QFileInfo(m_url).baseName(), QFileInfo(m_url).completeSuffix())); |
38 | 40 | ||
39 | // temporary file needs to be opened to get the filename | 41 | // temporary file needs to be opened to get the filename |
40 | downloadFile.open(); | 42 | downloadFile.open(); |
41 | m_file = downloadFile.fileName(); | 43 | m_file = downloadFile.fileName(); |
@@ -43,28 +45,28 @@ void RBInstaller::install(QString url,QString file,QString mountpoint, QUrl prox | |||
43 | // get the real file. | 45 | // get the real file. |
44 | getter = new HttpGet(this); | 46 | getter = new HttpGet(this); |
45 | getter->setProxy(proxy); | 47 | getter->setProxy(proxy); |
46 | getter->setFile(&downloadFile); | 48 | getter->setFile(&downloadFile); |
47 | getter->getFile(QUrl(url)); | 49 | getter->getFile(QUrl(url)); |
48 | 50 | ||
49 | connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); | 51 | connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); |
50 | connect(getter, SIGNAL(downloadDone(int, bool)), this, SLOT(downloadRequestFinished(int, bool))); | 52 | connect(getter, SIGNAL(downloadDone(int, bool)), this, SLOT(downloadRequestFinished(int, bool))); |
51 | connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int))); | 53 | connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int))); |
52 | 54 | ||
53 | } | 55 | } |
54 | 56 | ||
55 | void RBInstaller::downloadRequestFinished(int id, bool error) | 57 | void RBInstaller::downloadRequestFinished(int id, bool error) |
56 | { | 58 | { |
57 | qDebug() << "Install::downloadRequestFinished" << id << error; | 59 | qDebug() << "Install::downloadRequestFinished" << id << error; |
58 | qDebug() << "error:" << getter->errorString(); | 60 | qDebug() << "error:" << getter->errorString(); |
59 | 61 | ||
60 | downloadDone(error); | 62 | downloadDone(error); |
61 | } | 63 | } |
62 | 64 | ||
63 | void RBInstaller::downloadDone(bool error) | 65 | void RBInstaller::downloadDone(bool error) |
64 | { | 66 | { |
65 | qDebug() << "Install::downloadDone, error:" << error; | 67 | qDebug() << "Install::downloadDone, error:" << error; |
66 | 68 | ||
67 | 69 | ||
68 | // update progress bar | 70 | // update progress bar |
69 | int max = m_dp->progressBar->maximum(); | 71 | int max = m_dp->progressBar->maximum(); |
70 | if(max == 0) { | 72 | if(max == 0) { |
@@ -84,13 +86,13 @@ void RBInstaller::downloadDone(bool error) | |||
84 | emit done(true); | 86 | emit done(true); |
85 | return; | 87 | return; |
86 | } | 88 | } |
87 | else m_dp->listProgress->addItem(tr("Download finished.")); | 89 | else m_dp->listProgress->addItem(tr("Download finished.")); |
88 | 90 | ||
89 | // unzip downloaded file | 91 | // unzip downloaded file |
90 | qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint; | 92 | qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint; |
91 | 93 | ||
92 | m_dp->listProgress->addItem(tr("Extracting file.")); | 94 | m_dp->listProgress->addItem(tr("Extracting file.")); |
93 | 95 | ||
94 | qDebug() << "file to unzip: " << m_file; | 96 | qDebug() << "file to unzip: " << m_file; |
95 | UnZip::ErrorCode ec; | 97 | UnZip::ErrorCode ec; |
96 | UnZip uz; | 98 | UnZip uz; |
@@ -101,8 +103,8 @@ void RBInstaller::downloadDone(bool error) | |||
101 | m_dp->buttonAbort->setText(tr("&Ok")); | 103 | m_dp->buttonAbort->setText(tr("&Ok")); |
102 | emit done(false); | 104 | emit done(false); |
103 | return; | 105 | return; |
104 | } | 106 | } |
105 | 107 | ||
106 | ec = uz.extractAll(m_mountpoint); | 108 | ec = uz.extractAll(m_mountpoint); |
107 | if(ec != UnZip::Ok) { | 109 | if(ec != UnZip::Ok) { |
108 | m_dp->listProgress->addItem(tr("Extracting failed: %1.") | 110 | m_dp->listProgress->addItem(tr("Extracting failed: %1.") |
@@ -112,8 +114,8 @@ void RBInstaller::downloadDone(bool error) | |||
112 | return; | 114 | return; |
113 | } | 115 | } |
114 | 116 | ||
115 | m_dp->listProgress->addItem(tr("creating installation log")); | 117 | m_dp->listProgress->addItem(tr("creating installation log")); |
116 | 118 | ||
117 | QStringList zipContents = uz.fileList(); | 119 | QStringList zipContents = uz.fileList(); |
118 | 120 | ||
119 | QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); | 121 | QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); |
@@ -129,16 +131,16 @@ void RBInstaller::downloadDone(bool error) | |||
129 | downloadFile.remove(); | 131 | downloadFile.remove(); |
130 | 132 | ||
131 | m_dp->listProgress->addItem(tr("Extraction finished successfully.")); | 133 | m_dp->listProgress->addItem(tr("Extraction finished successfully.")); |
132 | m_dp->buttonAbort->setText(tr("&Ok")); | 134 | m_dp->buttonAbort->setText(tr("&Ok")); |
133 | 135 | ||
134 | emit done(false); | 136 | emit done(false); |
135 | } | 137 | } |
136 | 138 | ||
137 | void RBInstaller::updateDataReadProgress(int read, int total) | 139 | void RBInstaller::updateDataReadProgress(int read, int total) |
138 | { | 140 | { |
139 | m_dp->progressBar->setMaximum(total); | 141 | m_dp->progressBar->setMaximum(total); |
140 | m_dp->progressBar->setValue(read); | 142 | m_dp->progressBar->setValue(read); |
141 | qDebug() << "progress:" << read << "/" << total; | 143 | qDebug() << "progress:" << read << "/" << total; |
142 | 144 | ||
143 | } | 145 | } |
144 | 146 | ||
diff --git a/rbutil/rbutilqt/installrb.h b/rbutil/rbutilqt/installrb.h index 91268d5a97..c940fd8731 100644 --- a/rbutil/rbutilqt/installrb.h +++ b/rbutil/rbutilqt/installrb.h | |||
@@ -15,46 +15,46 @@ | |||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
16 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | 20 | ||
21 | #ifndef INSTALLRB_H | 21 | #ifndef INSTALLRB_H |
22 | #define INSTALLRB_H | 22 | #define INSTALLRB_H |
23 | 23 | ||
24 | 24 | ||
25 | 25 | ||
26 | #include <QtGui> | 26 | #include <QtGui> |
27 | #include <QtNetwork> | 27 | #include <QtNetwork> |
28 | 28 | ||
29 | #include "ui_installprogressfrm.h" | 29 | #include "ui_installprogressfrm.h" |
30 | #include "httpget.h" | 30 | #include "httpget.h" |
31 | 31 | ||
32 | class RBInstaller : public QObject | 32 | class RBInstaller : public QObject |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | RBInstaller(QObject* parent) ; | 36 | RBInstaller(QObject* parent) ; |
37 | ~RBInstaller(){} | 37 | ~RBInstaller(){} |
38 | void install(QString url,QString filename,QString mountpoint, QUrl proxy,Ui::InstallProgressFrm* dp); | 38 | void install(QString url,QString filename,QString mountpoint, QUrl proxy,Ui::InstallProgressFrm* dp); |
39 | 39 | ||
40 | signals: | 40 | signals: |
41 | void done(bool error); | 41 | void done(bool error); |
42 | 42 | ||
43 | private slots: | 43 | private slots: |
44 | void updateDataReadProgress(int, int); | 44 | void updateDataReadProgress(int, int); |
45 | void downloadDone(bool); | 45 | void downloadDone(bool); |
46 | void downloadRequestFinished(int, bool); | 46 | void downloadRequestFinished(int, bool); |
47 | 47 | ||
48 | private: | 48 | private: |
49 | QString m_url,m_file,m_mountpoint; | 49 | QString m_url,m_file,m_mountpoint; |
50 | 50 | ||
51 | HttpGet *getter; | 51 | HttpGet *getter; |
52 | QTemporaryFile downloadFile; | 52 | QTemporaryFile downloadFile; |
53 | 53 | ||
54 | Ui::InstallProgressFrm* m_dp; | 54 | Ui::InstallProgressFrm* m_dp; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | #endif | 59 | #endif |
60 | 60 | ||