comparison ui/createinstallerdialog.cpp @ 1377:c8a6a3e6bdeb

(issue178) Show checksums after installer creation
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 15 Jan 2015 11:22:47 +0100
parents 41cf49df007d
children f3e2df6b49ba
comparison
equal deleted inserted replaced
1376:fdef94da2d70 1377:c8a6a3e6bdeb
30 /* Static information used in codesigning */ 30 /* Static information used in codesigning */
31 #ifndef SIGN_HASH 31 #ifndef SIGN_HASH
32 #define SIGN_HASH "sha256" 32 #define SIGN_HASH "sha256"
33 #endif 33 #endif
34 #ifndef SIGN_URL 34 #ifndef SIGN_URL
35 #define SIGN_URL "http://wald.intevation.org/projects/trustbridge/" 35 #define SIGN_URL "https://www.trustbridge.de"
36 #endif 36 #endif
37 #ifndef SIGN_PUBLISHER 37 #ifndef SIGN_PUBLISHER
38 #define SIGN_PUBLISHER "TrustBridge Test with ümlaut" 38 #define SIGN_PUBLISHER "Bundesamt für Sicherheit in der Informationstechnik"
39 #endif 39 #endif
40 40
41 CreateInstallerDialog::CreateInstallerDialog(QMainWindow *parent) : 41 CreateInstallerDialog::CreateInstallerDialog(QMainWindow *parent) :
42 QDialog(parent), 42 QDialog(parent),
43 mProgress(this), 43 mProgress(this),
183 { 183 {
184 if (mCurrentWorkingDir) { 184 if (mCurrentWorkingDir) {
185 delete mCurrentWorkingDir; 185 delete mCurrentWorkingDir;
186 mCurrentWorkingDir = NULL; 186 mCurrentWorkingDir = NULL;
187 } 187 }
188 FinishedDialog *fin = new FinishedDialog(0, tr("Created installer in %1.") 188
189 .arg(mSaveFile->text()), mNSISProc.readAll(), false);
190 qDebug() << "Finished: " << mNSISProc.readAll();
191 mProgress.setLabelText(tr("Signing installer package...")); 189 mProgress.setLabelText(tr("Signing installer package..."));
192 if (!signFile(mInstallerPath)) { 190 if (!signFile(mInstallerPath)) {
193 showErrorMessage(tr("Failed to sign installer package.")); 191 showErrorMessage(tr("Failed to sign installer package."));
194 QFile::remove(mInstallerPath); 192 QFile::remove(mInstallerPath);
195 } 193 mProgress.cancel();
196 mProgress.cancel(); 194 } else {
197 fin->show(); 195 mProgress.setLabelText(tr("Calculating checksums..."));
196 QString checksums = QString::fromLatin1("<br/><h3>") + tr("Checksums:") + "</h3>";
197 QDir outDir(mSaveFile->text());
198 bool checksumErr = false;
199 QStringList filters;
200 filters << "TrustBridge-*.sh" << "TrustBridge-*.exe";
201 qDebug() << "Entries: " << outDir.entryList(filters);
202 qDebug() << "Entries unfiltered: " << outDir.entryList();
203 foreach (const QString &file, outDir.entryList(filters)) {
204 QFile f(outDir.filePath(file));
205 if (!f.open(QIODevice::ReadOnly)) {
206 showErrorMessage (tr("Failed to open file \"%1\".").arg(file));
207 checksumErr = true;
208 break;
209 }
210 const QByteArray fileData = f.readAll();
211 if (fileData.isEmpty()) {
212 showErrorMessage (tr("Failed to read file \"%1\".").arg(file));
213 checksumErr = true;
214 break;
215 }
216 const QByteArray theSha256sum = sha256sum(fileData);
217 const QByteArray theSha1sum = sha1sum(fileData);
218 if (theSha1sum.isEmpty() || theSha256sum.isEmpty()) {
219 showErrorMessage (tr("Failed to calculate checksums for \"%1\".").arg(file));
220 checksumErr = true;
221 break;
222 }
223 checksums += QString::fromLatin1("<br/><b>%1:</b><br/><pre>").arg(file);
224 checksums += " SHA1: ";
225 for (int i=0; i < theSha1sum.size(); i++) {
226 checksums += QString("%1").arg(
227 (unsigned char)(theSha1sum[i]), 0, 16).rightJustified(2, '0');
228 }
229
230 checksums += "\n SHA256: ";
231 for (int i=0; i < theSha256sum.size(); i++) {
232 checksums += QString("%1").arg(
233 (unsigned char)(theSha256sum[i]), 0, 16).rightJustified(2, '0');
234 }
235 checksums += "</pre>";
236
237 }
238
239 mProgress.cancel();
240 if (!checksumErr) {
241 FinishedDialog *fin = new FinishedDialog(0, tr("Successfully created the installation packages in \"%1\".")
242 .arg(mSaveFile->text()) + checksums, mNSISProc.readAll(), false);
243 qDebug() << "Finished: " << mNSISProc.readAll();
244 fin->show();
245 }
246 }
198 close(); 247 close();
199 } 248 }
200 249
201 void CreateInstallerDialog::processError(QProcess::ProcessError error) 250 void CreateInstallerDialog::processError(QProcess::ProcessError error)
202 { 251 {
550 setWindowTitle(tr("Error!")); 599 setWindowTitle(tr("Error!"));
551 msgLabel->setPixmap(QApplication::style()->standardIcon( 600 msgLabel->setPixmap(QApplication::style()->standardIcon(
552 QStyle::SP_MessageBoxCritical).pixmap(16, 16)); 601 QStyle::SP_MessageBoxCritical).pixmap(16, 16));
553 } 602 }
554 msgLabel->setText(msg); 603 msgLabel->setText(msg);
604 msgLabel->setTextInteractionFlags(
605 Qt::TextSelectableByMouse |
606 Qt::TextSelectableByKeyboard);
555 607
556 topLayout->addWidget(msgLabel); 608 topLayout->addWidget(msgLabel);
557 topLayout->addWidget(detailsWindow); 609 topLayout->addWidget(detailsWindow);
558 QPushButton *detailsBtn = new QPushButton(tr("Details")); 610 QPushButton *detailsBtn = new QPushButton(tr("Details"));
559 connect(detailsBtn, SIGNAL(clicked()), detailsWindow, SLOT(show())); 611 connect(detailsBtn, SIGNAL(clicked()), detailsWindow, SLOT(show()));

http://wald.intevation.org/projects/trustbridge/