summaryrefslogtreecommitdiffstats
path: root/mainwindow.cpp
diff options
context:
space:
mode:
authorMartin Talarczyk <talarczyk.martin@fh-swf.de>2015-09-29 22:35:19 +0200
committerMartin Talarczyk <talarczyk.martin@fh-swf.de>2015-09-29 22:36:41 +0200
commit5e3a2b3c451240415a6472fab05de0e4a2f232e1 (patch)
treeaf9bd0b26955d984ba2b439e17bbe788f55c1abc /mainwindow.cpp
parent469c16a63c811c648e205d03905fa8db72b9c554 (diff)
downloadsrc-5e3a2b3c451240415a6472fab05de0e4a2f232e1.tar.gz
src-5e3a2b3c451240415a6472fab05de0e4a2f232e1.zip
Fange Fehler ab, Korigiere Rechtschreibfehler
*try catch blöcke eingefügt. *Rechtschreib fehler auf Gui koriegirt.
Diffstat (limited to 'mainwindow.cpp')
-rw-r--r--mainwindow.cpp156
1 files changed, 132 insertions, 24 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 01a5dcd..7df9bbe 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -13,6 +13,7 @@ MainWindow::~MainWindow()
delete ui;
}
+// Button
void MainWindow::on_pushButtonDecrypt_clicked()
{
@@ -25,16 +26,24 @@ void MainWindow::on_pushButtonDecrypt_clicked()
tr("Sie haben keine Datei eingegen die Entschlüsselt werden soll."));
ui->lineEditFilePath->setFocus();
}
-
- if (in.isEmpty())
- {
- QMessageBox::warning(this, tr("Keine Seicherort ausgefählt"),
- tr("Sie haben keine Speicherort für die Entschlüsselte Datei eingegeben."));
- }
-
- if (!in.isEmpty() && !out.isEmpty())
+ else
{
- hybridcrypt.decrypt(in, out);
+ if (in.isEmpty())
+ {
+ QMessageBox::warning(this, tr("Keine Seicherort ausgefählt"),
+ tr("Sie haben keine Speicherort für die Entschlüsselte Datei eingegeben."));
+ }
+ else
+ {
+ try
+ {
+ hybridcrypt.decrypt(in, out);
+ }
+ catch (CryptException e)
+ {
+ QMessageBox::critical(this, tr("Fehler beim Entschlüsseln"), e.what());
+ }
+ }
}
}
@@ -43,12 +52,30 @@ void MainWindow::on_pushButtonEncrypt_clicked()
{
PublicKeyImportDialog publicKeyImport;
- QString filename = ui->lineEditFilePath->text();
+ QString inFilename = ui->lineEditFilePath->text();
- if (publicKeyImport.exec() && !fielname.isEmpty())
+ // outFile Diaglog findet in PublicKeyImportDialog stat.
+
+ if (!inFilename.isEmpty())
{
- hybridcrypt.encrypt(filename, publicKeyImport.getOutFileName(),
- publicKeyImport.getFielListPublicKey());
+ if (publicKeyImport.exec())
+ {
+ try
+ {
+ hybridcrypt.encrypt(inFilename, publicKeyImport.getOutFileName(),
+ publicKeyImport.getFielListPublicKey());
+ }
+ catch (CryptException e)
+ {
+ QMessageBox::critical(this, tr("Fehler beim Verschlüsselen"), e.what());
+ }
+ }
+ }
+ else
+ {
+ QMessageBox::information(this, tr("Keine Datei ausgewählt"),
+ tr("Sie haben Keine Datei ausgewählt. Entschlüsselung hat nicht Statgefunden"));
+ ui->lineEditFilePath->setFocus();
}
}
@@ -57,21 +84,29 @@ void MainWindow::on_pushButtonOpenFile_clicked()
{
QString fielname = readFilename("Datei öffnen");
ui->lineEditFilePath->setText(fielname);
- qDebug() << fielname;
-
}
+//Menü Führung
void MainWindow::on_actionImport_triggered()
{
QString filename = readKeyFilename(tr("Importiren eines Schlüsselpaares"));
- qDebug() << filename;
-
if (!filename.isEmpty())
{
QString password = readPassword();
- hybridcrypt.importUserKeypair(filename, password);
+
+ if (!password.isEmpty())
+ {
+ try
+ {
+ hybridcrypt.importUserKeypair(filename, password);
+ }
+ catch (CryptException e)
+ {
+ QMessageBox::critical(this, tr("Fehler beim Importieren"), e.what());
+ }
+ }
}
else
{
@@ -81,20 +116,94 @@ void MainWindow::on_actionImport_triggered()
}
+void MainWindow::on_actionExportMyKeypair_triggered()
+{
+ qDebug() << "on_actionExportMyKeypair_triggered";
+ if (hybridcrypt.isUserKeyInitialised())
+ {
+ QString expoKeyFileName = QFileDialog::getSaveFileName(this,
+ tr("Export Datei für den Schlüssel"),
+ QDir::homePath(), tr("Schlüssel Dateien (*.pem)"));
+ PasswordDialog pwd;
-void MainWindow::on_actionClose_triggered()
-{
- close();
+ if (!expoKeyFileName.isEmpty())
+ {
+ if (pwd.exec())
+ {
+ try
+ {
+ hybridcrypt.exportUserKeypair(expoKeyFileName, pwd.getPassword());
+ }
+ catch (CryptException e)
+ {
+ QMessageBox::critical(this, tr("Fehler beim Exportieren"), e.what());
+ }
+ }
+ }
+ else
+ {
+ QMessageBox::warning(this, tr("Keine Schlüsseldatei ausgewählt"),
+ tr("Sie haben keine Ziehlort für die Datei aus gewählt. Exportiren wurden icht durchgeführt."));
+ }
+ }
}
+
void MainWindow::on_actionExportMyPublicKey_triggered()
{
+ qDebug() << "on_actionExportMyPublicKey_triggered";
+
+ if (hybridcrypt.isUserKeyInitialised())
+ {
+ QString expoKeyFileName = QFileDialog::getSaveFileName(this,
+ tr("Export Datei für den Schlüssel"),
+ QDir::homePath(), tr("Schlüssel Dateien (*.pem *.der *.asc)"));
- hybridcrypt.exportPublicUserKey(
- readKeyFilename("Export Datei für den Schlüssel"));
+ if (!expoKeyFileName.isEmpty())
+ {
+ try
+ {
+ hybridcrypt.exportPublicUserKey(expoKeyFileName);
+ }
+ catch (CryptException e)
+ {
+ QMessageBox::critical(this, tr("Fehler beim Exportieren"), e.what());
+ }
+ }
+ else
+ {
+ QMessageBox::warning(this, tr("Keine Schlüsseldatei ausgewählt"),
+ tr("Sie haben keine Ziehlort für die Datei aus gewählt. Exportiren wurden icht durchgeführt."));
+ }
+ }
}
+void MainWindow::on_actionCreateKeypair_triggered()
+{
+ qDebug() << "on_actionCreateKeypair_triggered";
+
+ try
+ {
+ hybridcrypt.createKeypair();
+
+ QMessageBox::information(this, tr("Erzuegen war erfolgreich"),
+ tr("Erzeugen des Schlüssels war erfolgreich."));
+ }
+ catch (CryptException e)
+ {
+ QMessageBox::critical(this, tr("Fehler beim Erzeugen"), e.what());
+ }
+
+}
+
+void MainWindow::on_actionClose_triggered()
+{
+ close();
+}
+
+//Private Funksionen
+
QString MainWindow::readKeyFilename(QString titel)
{
return QFileDialog::getOpenFileName(this, titel,
@@ -111,7 +220,6 @@ QString MainWindow::readPassword()
{
PasswordDialog w;
-
if (w.exec())
{
return w.getPassword();