void MainWindow::pbOpen()
{
	QByteArray key = m_ui->lineEditKey->text().toLatin1() ;

	zuluCryptPluginManagerSendKey( m_handle,key.constData(),key.size() ) ;

	this->done() ;
}
Esempio n. 2
0
void getKey::run()
{
	QByteArray key = m_function( m_exe,m_keyFile,m_key ) ;

	if( key.isEmpty() ){
		m_status = getKey::wrongKey ;
	}else{
		void * handle = zuluCryptPluginManagerOpenConnection( m_token.toLatin1().constData() ) ;

		if( handle ){

			zuluCryptPluginManagerSendKey( handle,key.constData(),key.size() ) ;
			zuluCryptPluginManagerCloseConnection( handle ) ;

			m_status = getKey::complete ;
		}else{
			m_status = getKey::wrongKey ;
		}
	}
}
Esempio n. 3
0
void MainWindow::pbOpen()
{
	DialogMsg msg( this ) ;

	QString key = m_ui->lineEditKey->text().toLatin1() ;
	if( m_requireKey ){
		if( key.isEmpty() ){
			return msg.ShowUIOK( tr( "ERROR" ),tr( "Key field is empty" ) ) ;
		}
	}

	QString keyFile = m_ui->lineEditKeyFile->text() ;

	keyFile.replace( "file://","" ) ;

	if( m_requireKeyFile ){
		if( m_keyfileAsKey ){
			;
		}else{
			if( keyFile.isEmpty() ){
				return msg.ShowUIOK( tr( "ERROR" ),tr( "Path to %1 keyfile is empty" ).arg( m_appName ) ) ;
			}
			if( !QFile::exists( keyFile ) ){
				return msg.ShowUIOK( tr( "ERROR" ),tr( "Invalid path to %1 keyfile" ).arg( m_appName ) ) ;
			}
		}
	}

	m_exe_1 = m_exe ;
	QString e = m_findExecutable( m_exe_1 ) ;
	if( !e.isEmpty() ){
		return msg.ShowUIOK( tr( "ERROR" ),
				     tr( "Could not find \"%1\" executable in \"/usr/local\",\"/usr/bin\" and \"/usr/sbin\"" ).arg( e ) ) ;
	}

	this->disableAll() ;
	m_working = true ;

	Task::run< bool >( [ &,keyFile,key ](){

		QByteArray s = m_function( m_exe_1,keyFile,key ) ;

		if( s.isEmpty() ){

			return false ;
		}else{
			if( m_handle ){

				zuluCryptPluginManagerSendKey( m_handle,s.constData(),s.size() ) ;

				return true ;
			}else{
				return false ;
			}
		}

	} ).then( [ this ]( bool passed ){

		if( passed ){
			this->Exit( 0 ) ;
		}else{
			DialogMsg msg( this ) ;
			m_working = false ;

			if( m_appName.endsWith( " key" ) ){
				msg.ShowUIOK( tr( "ERROR" ),tr("Could not decrypt the %1,wrong key?" ).arg( m_appName ) ) ;
			}else{
				msg.ShowUIOK( tr( "ERROR" ),tr("Could not decrypt the %1 key,wrong key?" ).arg( m_appName ) ) ;
			}

			this->enableAlll() ;
			m_ui->lineEditKey->setFocus() ;
		}
	} ) ;
}