mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
Tell user about illegal files
Tell the user about any files that did not contain any crypto items
This commit is contained in:
parent
8724ae5f5c
commit
d9c3661608
@ -27,6 +27,10 @@ class pki_multi: public pki_base
|
||||
void fload(const QString fname);
|
||||
void probeAnything(const QString fname);
|
||||
pki_base *pull();
|
||||
int count() const
|
||||
{
|
||||
return multi.count();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -302,13 +302,23 @@ int ImportMulti::entries()
|
||||
return mcont->rootItem->childCount();
|
||||
}
|
||||
|
||||
void ImportMulti::execute(int force)
|
||||
void ImportMulti::execute(int force, QStringList failed)
|
||||
{
|
||||
/* if there is nothing to import don't pop up */
|
||||
if (entries() == 0) {
|
||||
accept();
|
||||
return;
|
||||
}
|
||||
if (failed.count() == 1) {
|
||||
QMessageBox::information(this, XCA_TITLE,
|
||||
tr("Failed to open the file: '%1'").
|
||||
arg(failed[0]));
|
||||
} else if (failed.count() > 1) {
|
||||
QMessageBox::information(this, XCA_TITLE,
|
||||
tr("Failed to open the %1 files: '%2'").
|
||||
arg(failed.count()).
|
||||
arg(failed.join("', '")));
|
||||
}
|
||||
/* if there is only 1 item and force is 0 import it silently */
|
||||
if (entries() == 1 && force == 0) {
|
||||
QModelIndex idx = mcont->index(0, 0, QModelIndex());
|
||||
|
||||
@ -30,7 +30,7 @@ class ImportMulti: public QDialog, private Ui::ImportMulti
|
||||
void addItem(pki_base *pki);
|
||||
pki_base *getSelected();
|
||||
pki_base *import(QModelIndex &idx);
|
||||
void execute(int force=0);
|
||||
void execute(int force=0, QStringList failed = QStringList());
|
||||
int entries();
|
||||
void tokenInfo(unsigned long s);
|
||||
|
||||
|
||||
@ -209,14 +209,16 @@ void MainWindow::dropEvent(QDropEvent *event)
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
QUrl u;
|
||||
ImportMulti *dlgi = new ImportMulti(this);
|
||||
QStringList failed;
|
||||
|
||||
foreach(u, urls) {
|
||||
QString s = u.toLocalFile();
|
||||
fprintf(stderr, "URL: '%s'\n", CCHAR(s));
|
||||
pki_multi *pki = probeAnything(s);
|
||||
if (!pki->count())
|
||||
failed << s;
|
||||
dlgi->addItem(pki);
|
||||
}
|
||||
dlgi->execute(1);
|
||||
dlgi->execute(1, failed);
|
||||
delete dlgi;
|
||||
}
|
||||
|
||||
@ -297,6 +299,7 @@ void MainWindow::read_cmdline()
|
||||
int cnt = 1, opt = 0, force_load = 0;
|
||||
char *arg = NULL;
|
||||
exitApp = 0;
|
||||
QStringList failed;
|
||||
ImportMulti *dlgi = new ImportMulti(this);
|
||||
while (cnt < qApp->argc()) {
|
||||
arg = qApp->argv()[cnt];
|
||||
@ -343,11 +346,13 @@ void MainWindow::read_cmdline()
|
||||
force_load = 0;
|
||||
} else {
|
||||
pki_multi *pki = probeAnything(file);
|
||||
if (!pki->count())
|
||||
failed << file;
|
||||
dlgi->addItem(pki);
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
dlgi->execute(1); /* force showing of import dialog */
|
||||
dlgi->execute(1, failed); /* force showing of import dialog */
|
||||
if (dlgi->result() == QDialog::Rejected)
|
||||
exitApp = 1;
|
||||
delete dlgi;
|
||||
@ -877,9 +882,12 @@ void MainWindow::connNewX509(NewX509 *nx)
|
||||
void MainWindow::importAnything(QString file)
|
||||
{
|
||||
ImportMulti *dlgi = new ImportMulti(this);
|
||||
QStringList failed;
|
||||
pki_multi *pki = probeAnything(file);
|
||||
if (!pki->count())
|
||||
failed << file;
|
||||
dlgi->addItem(pki);
|
||||
dlgi->execute(1);
|
||||
dlgi->execute(1, failed);
|
||||
delete dlgi;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user