37 #include "obtainkeysjob.h"
39 #include "chiasmusbackend.h"
41 #include "kleo/cryptoconfig.h"
43 #include <tdelocale.h>
44 #include <tdemessagebox.h>
48 #include <tqstringlist.h>
49 #include <tqvariant.h>
51 #include <tqfileinfo.h>
53 #include <gpg-error.h>
57 Kleo::ObtainKeysJob::ObtainKeysJob()
62 assert( ChiasmusBackend::instance() );
63 assert( ChiasmusBackend::instance()->config() );
64 const CryptoConfigEntry * keypaths =
65 ChiasmusBackend::instance()->config()->entry(
"Chiasmus",
"General",
"keydir" );
67 mKeyPaths = TQStringList( keypaths->urlValue().path() );
70 Kleo::ObtainKeysJob::~ObtainKeysJob() {}
73 TQTimer::singleShot( 0,
this, TQ_SLOT(slotPerform()) );
82 void Kleo::ObtainKeysJob::slotCancel() {
86 void Kleo::ObtainKeysJob::slotPerform() {
90 void Kleo::ObtainKeysJob::slotPerform(
bool async ) {
91 if ( mCanceled && !mError )
92 mError = gpg_error( GPG_ERR_CANCELED );
93 if ( mIndex >= mKeyPaths.size() || mError ) {
95 emit SpecialJob::result( mError, TQVariant( mResult ) );
99 emit progress( i18n(
"Scanning directory %1..." ).arg( mKeyPaths[mIndex] ),
100 mIndex, mKeyPaths.size() );
102 const TQDir dir( KShell::tildeExpand( mKeyPaths[mIndex] ) );
104 if (
const TQFileInfoList * xisFiles = dir.entryInfoList(
"*.xis;*.XIS", TQDir::Files ) )
105 for ( TQFileInfoList::const_iterator it = xisFiles->begin(), end = xisFiles->end() ; it != end ; ++it )
106 if ( (*it)->isReadable() )
107 mResult.push_back( (*it)->absFilePath() );
112 TQTimer::singleShot( 0,
this, TQ_SLOT(slotPerform()) );
114 slotPerform(
false );
120 if ( mError.isCanceled() )
122 const TQString msg = TQString::fromUtf8( mError.asString() );
123 KMessageBox::error( parent, msg, caption );
126 #include "obtainkeysjob.moc"
void showErrorDialog(TQWidget *, const TQString &) const