bool MyEditor::slotCheckContent(TQString fileToCheck, bool checkForPgpMessage) { TQFile qfile(fileToCheck); if (qfile.open(IO_ReadOnly)) { ////////// open file TQTextStream t( &qfile ); TQString result(t.read()); ////////////// if pgp data found, decode it if ((checkForPgpMessage) && (result.startsWith("-----BEGIN PGP MESSAGE"))) { qfile.close(); slotDecodeFile(fileToCheck); return true; } else if (result.startsWith("-----BEGIN PGP PUBLIC KEY BLOCK")) {////// dropped file is a public key, ask for import qfile.close(); int result=KMessageBox::warningContinueCancel(this,i18n("<p>The file <b>%1</b> is a public key.<br>Do you want to import it ?</p>").arg(fileToCheck),i18n("Warning")); if (result==KMessageBox::Cancel) { TDEIO::NetAccess::removeTempFile(fileToCheck); return true; } else { KgpgInterface *importKeyProcess=new KgpgInterface(); importKeyProcess->importKeyURL(KURL(fileToCheck)); connect(importKeyProcess,TQT_SIGNAL(importfinished(TQStringList)),TQT_TQOBJECT(this),TQT_SLOT(slotProcessResult(TQStringList))); return true; } } else { if (result.startsWith("-----BEGIN PGP PRIVATE KEY BLOCK")) { qfile.close(); KMessageBox::information(0,i18n("This file is a private key.\nPlease use kgpg key management to import it.")); TDEIO::NetAccess::removeTempFile(fileToCheck); return true; } setText(result); qfile.close(); TDEIO::NetAccess::removeTempFile(fileToCheck); } } return false; }
void MainWindow::importAutomaton() { QString fileName = QFileDialog::getOpenFileName(this, tr("Import Automaton"), QDir::currentPath(), tr("Automaton Files (*.xml *.fsm)")); if (fileName.isEmpty()) return; DCAutomaton* newAutomaton = new DCAutomaton(DCAutomaton::Visual); m_importer = new ImportAutomaton(ImportAutomaton::SUPREMICA, fileName); m_importer->setAutomaton(newAutomaton); connect(m_importer, SIGNAL(importfinished(DCAutomaton*)), this, SLOT(importFinished(DCAutomaton*))); m_importer->start(); QProgressDialog progress("Import automaton", "Abort Copy", 0, 100, this); progress.setWindowModality(Qt::WindowModal); connect(m_importer, SIGNAL(importstatus(QString)), &progress, SLOT(setLabelText(QString))); connect(m_importer, SIGNAL(importvalue(int)), &progress, SLOT(setValue(int))); connect(m_importer, SIGNAL(importfinished()), &progress, SLOT(close())); progress.exec(); }