"Fossies" - the Fresh Open Source Software Archive

Member "zuluCrypt-5.7.1/zuluCrypt-gui/luksaddkey.cpp" (31 Jan 2020, 18723 Bytes) of package /linux/misc/zuluCrypt-5.7.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "luksaddkey.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.7.0_vs_5.7.1.

    1 /*
    2  *
    3  *  Copyright ( c ) 2011-2015
    4  *  name : Francis Banyikwa
    5  *  email: mhogomchungu@gmail.com
    6  *  This program is free software: you can redistribute it and/or modify
    7  *  it under the terms of the GNU General Public License as published by
    8  *  the Free Software Foundation, either version 2 of the License, or
    9  *  ( at your option ) any later version.
   10  *
   11  *  This program is distributed in the hope that it will be useful,
   12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  *  GNU General Public License for more details.
   15  *
   16  *  You should have received a copy of the GNU General Public License
   17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
   18  */
   19 
   20 #include "ui_luksaddkey.h"
   21 #include "luksaddkey.h"
   22 #include "../zuluCrypt-cli/constants.h"
   23 #include "zulucrypt.h"
   24 #include "utility.h"
   25 
   26 #include <Qt>
   27 #include <QObject>
   28 #include <QFileDialog>
   29 #include <QDir>
   30 #include <iostream>
   31 #include <QRadioButton>
   32 #include <QPushButton>
   33 #include <QMessageBox>
   34 #include <QProcess>
   35 #include <QIcon>
   36 #include <QDebug>
   37 
   38 #include <QCloseEvent>
   39 
   40 #include "openvolume.h"
   41 #include "task.hpp"
   42 #include "dialogmsg.h"
   43 #include "plugin.h"
   44 #include "utility.h"
   45 
   46 luksaddkey::luksaddkey( QWidget * parent ) : QDialog( parent )
   47 {
   48     m_ui = new Ui::luksaddkey() ;
   49     m_ui->setupUi( this ) ;
   50 
   51     m_label.setOptions( m_ui->label_5,m_ui->pushButton ) ;
   52 
   53     m_isWindowClosable = true ;
   54 
   55     m_ui->textEditPathToVolume->setText( QString() ) ;
   56 
   57     m_ui->textEditExistingPassphrase->setEchoMode( QLineEdit::Password ) ;
   58     m_ui->textEditPassphraseToAdd->setEchoMode( QLineEdit::Password ) ;
   59 
   60     this->setFixedSize( this->size() ) ;
   61     this->setFont( parent->font() ) ;
   62 
   63     connect( m_ui->cbVolumeType,SIGNAL( activated( int ) ),this,SLOT( cbVolumeType( int ) ) ) ;
   64     connect( m_ui->pushButtonOpenFile,SIGNAL( clicked() ),this,SLOT( pbOpenFile() ) ) ;
   65     connect( m_ui->pushButtonOpenExistingKeyFile,SIGNAL( clicked() ),this,SLOT( pbOpenExisitingKeyFile() ) ) ;
   66     connect( m_ui->pushButtonOpenNewKeyFile,SIGNAL( clicked() ),this,SLOT( pbOpenNewKeyFile() ) ) ;
   67     connect( m_ui->pushButtonOpenPartition,SIGNAL( clicked() ),this,SLOT( pbOpenPartition( void ) ) ) ;
   68     connect( m_ui->pushButtonAdd,SIGNAL( clicked() ),this,SLOT( pbAdd() ) ) ;
   69     connect( m_ui->pushButtonCancel,SIGNAL( clicked() ),this,SLOT( pbCancel() ) ) ;
   70 
   71     if( m_ui->cbNewKey->currentIndex() == 0 && m_keystrength.canCheckQuality() ){
   72 
   73         connect( m_ui->textEditPassphraseToAdd,SIGNAL( textChanged( QString ) ),this,SLOT( keyChanged_0( QString ) ) ) ;
   74     }else{
   75         connect( m_ui->textEditPassphraseToAdd,SIGNAL( textChanged( QString ) ),this,SLOT( keyChanged_1( QString ) ) ) ;
   76     }
   77 
   78     connect( m_ui->cbExistingKey,SIGNAL( activated( int ) ),this,SLOT( cbExistingKey( int ) ) ) ;
   79     connect( m_ui->cbNewKey,SIGNAL( activated( int ) ),this,SLOT( cbNewKey( int ) ) ) ;
   80 
   81     m_ui->lineEditReEnterPassphrase->setEchoMode( QLineEdit::Password ) ;
   82 
   83     m_ui->pushButtonOpenExistingKeyFile->setEnabled( false ) ;
   84     m_ui->pushButtonOpenNewKeyFile->setEnabled( false ) ;
   85 
   86     m_ui->pushButtonOpenPartition->setIcon( QIcon( ":/partition.png" ) ) ;
   87     m_ui->pushButtonOpenFile->setIcon( QIcon( ":/file.png" ) ) ;
   88 
   89     this->cbExistingKey( 0 ) ;
   90     this->cbNewKey( 0 ) ;
   91     this->cbVolumeType( 0 ) ;
   92 
   93     m_veraCryptWarning.setWarningLabel( m_ui->label_5 ) ;
   94 
   95     this->installEventFilter( this ) ;
   96 }
   97 
   98 bool luksaddkey::eventFilter( QObject * watched,QEvent * event )
   99 {
  100     return utility::eventFilter( this,watched,event,[ this ](){ this->HideUI() ; } ) ;
  101 }
  102 
  103 void luksaddkey::keyChanged_1( QString key )
  104 {
  105     Q_UNUSED( key )
  106     this->setWindowTitle( tr( "Add A Key To A Volume" ) ) ;
  107 }
  108 
  109 void luksaddkey::keyChanged_0( QString key )
  110 {
  111     auto st = m_keystrength.quality( key ) ;
  112 
  113     if( st < 0 ){
  114 
  115         this->setWindowTitle( tr( "Passphrase Quality: 0%" ) ) ;
  116     }else{
  117         this->setWindowTitle( tr( "Passphrase Quality: %1%" ).arg( QString::number( st ) ) ) ;
  118     }
  119 }
  120 
  121 void luksaddkey::closeEvent( QCloseEvent * e )
  122 {
  123     e->ignore() ;
  124 
  125     if( m_isWindowClosable ){
  126 
  127         this->HideUI() ;
  128     }
  129 }
  130 
  131 void luksaddkey::ShowUI( const QString& path )
  132 {
  133     m_ui->textEditPathToVolume->setText( path ) ;
  134     this->ShowUI() ;
  135 }
  136 
  137 void luksaddkey::ShowUI()
  138 {
  139     this->setFieldFocus() ;
  140     this->show() ;
  141 }
  142 
  143 void luksaddkey::setFieldFocus()
  144 {
  145     if( m_ui->textEditPathToVolume->text().isEmpty() ){
  146 
  147         m_ui->textEditPathToVolume->setFocus() ;
  148 
  149     }else if( m_ui->textEditExistingPassphrase->text().isEmpty() ){
  150 
  151         m_ui->textEditExistingPassphrase->setFocus() ;
  152 
  153     }else if( m_ui->textEditPassphraseToAdd->text().isEmpty() ){
  154 
  155         m_ui->textEditPassphraseToAdd->setFocus() ;
  156 
  157     }else if( m_ui->cbNewKey->currentIndex() == 0 ){
  158 
  159         if( m_ui->lineEditReEnterPassphrase->text().isEmpty() ){
  160 
  161             m_ui->lineEditReEnterPassphrase->setFocus() ;
  162         }else{
  163             m_ui->pushButtonAdd->setFocus() ;
  164         }
  165     }else{
  166         m_ui->pushButtonAdd->setFocus() ;
  167     }
  168 }
  169 
  170 void luksaddkey::HideUI()
  171 {
  172     this->hide() ;
  173     this->deleteLater() ;
  174 }
  175 
  176 void luksaddkey::cbVolumeType( int e )
  177 {
  178     bool s = ( e == 2 ) ;
  179 
  180     m_ui->lineEditPIM->setEnabled( s ) ;
  181     m_ui->label_4->setEnabled( s ) ;
  182     m_ui->lineEditPIM->setEnabled( s ) ;
  183 }
  184 
  185 void luksaddkey::cbExistingKey( int e )
  186 {
  187     m_yubikeyExistingKey = false ;
  188 
  189     auto _key_ui = [ this ](){
  190 
  191         m_ui->textEditExistingPassphrase->setToolTip( tr( "Enter A Key" ) ) ;
  192         m_ui->textEditExistingPassphrase->setEchoMode( QLineEdit::Password ) ;
  193         m_ui->pushButtonOpenExistingKeyFile->setEnabled( false ) ;
  194         m_ui->labelExistingPassphrase->setText( tr( "Password" ) ) ;
  195         m_ui->textEditExistingPassphrase->clear() ;
  196         m_ui->pushButtonOpenExistingKeyFile->setIcon( QIcon( ":/passphrase.png" ) ) ;
  197         m_ui->textEditExistingPassphrase->setFocus() ;
  198         m_ui->textEditExistingPassphrase->setEnabled( true ) ;
  199     } ;
  200 
  201     if( e == 0 ){
  202 
  203         _key_ui() ;
  204 
  205     }else if( e == 1 ){
  206 
  207         m_ui->textEditExistingPassphrase->setToolTip( tr( "Enter a path to a keyfile location" ) ) ;
  208         m_ui->textEditExistingPassphrase->setEchoMode( QLineEdit::Normal ) ;
  209         m_ui->pushButtonOpenExistingKeyFile->setEnabled( true ) ;
  210         m_ui->labelExistingPassphrase->setText( tr( "KeyFile Path" ) ) ;
  211         m_ui->textEditExistingPassphrase->clear() ;
  212         m_ui->pushButtonOpenExistingKeyFile->setIcon( QIcon( ":/keyfile.png" ) ) ;
  213         m_ui->textEditExistingPassphrase->setFocus() ;
  214         m_ui->textEditExistingPassphrase->setEnabled( true ) ;
  215 
  216     }else if( e == 2 ){
  217 
  218         _key_ui() ;
  219 
  220         m_ui->textEditExistingPassphrase->setEnabled( false ) ;
  221 
  222         plugin::instance( this,plugins::plugin::hmac_key,[ this ]( const QString& key ){
  223 
  224             m_ui->textEditExistingPassphrase->setText( key ) ;
  225 
  226             if( key.isEmpty() ){
  227 
  228                 m_ui->cbExistingKey->setCurrentIndex( 0 ) ;
  229                 this->cbExistingKey( 0 ) ;
  230             }
  231         } ) ;
  232     }else{
  233         _key_ui() ;
  234         m_yubikeyExistingKey = true ;
  235     }
  236 }
  237 
  238 void luksaddkey::cbNewKey( int e )
  239 {
  240     m_yubekeyNewKey = false ;
  241 
  242     auto _key_ui = [ this ](){
  243 
  244         m_ui->textEditPassphraseToAdd->setToolTip( tr( "Enter a key" ) ) ;
  245         m_ui->textEditPassphraseToAdd->setEchoMode( QLineEdit::Password ) ;
  246         m_ui->pushButtonOpenNewKeyFile->setEnabled( false ) ;
  247         m_ui->labelNewPassphrase->setText( tr( "Password" ) ) ;
  248         m_ui->textEditPassphraseToAdd->clear() ;
  249         m_ui->lineEditReEnterPassphrase->clear() ;
  250         m_ui->lineEditReEnterPassphrase->setEnabled( true ) ;
  251         m_ui->labelReEnterPassphrase->setEnabled( true ) ;
  252         m_ui->pushButtonOpenNewKeyFile->setIcon( QIcon( ":/passphrase.png" ) ) ;
  253         m_ui->textEditPassphraseToAdd->setFocus() ;
  254         m_ui->textEditPassphraseToAdd->setEnabled( true ) ;
  255     } ;
  256 
  257     if( e == 0 ){
  258 
  259         _key_ui() ;
  260 
  261     }else if( e == 1 ){
  262 
  263         m_ui->textEditPassphraseToAdd->clear() ;
  264         m_ui->lineEditReEnterPassphrase->clear() ;
  265         m_ui->textEditPassphraseToAdd->setToolTip( tr( "Enter a path to a keyfile location" ) ) ;
  266         m_ui->textEditPassphraseToAdd->setEchoMode( QLineEdit::Normal ) ;
  267         m_ui->pushButtonOpenNewKeyFile->setEnabled( true ) ;
  268         m_ui->labelNewPassphrase->setText( tr( "KeyFile path" ) ) ;
  269         m_ui->lineEditReEnterPassphrase->setEnabled( false ) ;
  270         m_ui->labelReEnterPassphrase->setEnabled( false ) ;
  271         m_ui->pushButtonOpenNewKeyFile->setIcon( QIcon( ":/keyfile.png" ) ) ;
  272         m_ui->textEditPassphraseToAdd->setFocus() ;
  273         m_ui->textEditPassphraseToAdd->setEnabled( true ) ;
  274 
  275     }else if( e == 2 ){
  276 
  277         _key_ui() ;
  278 
  279         m_ui->textEditPassphraseToAdd->setEnabled( false ) ;
  280         m_ui->lineEditReEnterPassphrase->setEnabled( false ) ;
  281 
  282         plugin::instance( this,plugins::plugin::hmac_key,[ this ]( const QString& key ){
  283 
  284             m_ui->textEditPassphraseToAdd->setText( key ) ;
  285             m_ui->lineEditReEnterPassphrase->setText( key ) ;
  286 
  287             if( key.isEmpty() ){
  288 
  289                 m_ui->cbNewKey->setCurrentIndex( 0 ) ;
  290                 this->cbNewKey( 0 ) ;
  291             }else{
  292                 if( m_keystrength.canCheckQuality() ){
  293 
  294                     this->setWindowTitle( tr( "Passphrase Quality: 100%" ) ) ;
  295                 }
  296             }
  297         } ) ;
  298     }else{
  299         m_yubekeyNewKey = true ;
  300         m_ui->lineEditReEnterPassphrase->setEnabled( false ) ;
  301         m_ui->lineEditReEnterPassphrase->clear() ;
  302         m_ui->textEditPassphraseToAdd->clear() ;
  303         m_ui->textEditPassphraseToAdd->setEchoMode( QLineEdit::Password ) ;
  304     }
  305 }
  306 
  307 void luksaddkey::pbOpenExisitingKeyFile( void )
  308 {
  309     auto Z = QFileDialog::getOpenFileName( this,tr( "Existing KeyFile" ),utility::homePath() ) ;
  310 
  311     if( !Z.isEmpty() ){
  312 
  313         m_ui->textEditExistingPassphrase->setText( Z ) ;
  314     }
  315 
  316     this->setFieldFocus() ;
  317 }
  318 
  319 void luksaddkey::pbOpenNewKeyFile( void )
  320 {
  321     auto Z = QFileDialog::getOpenFileName( this,tr( "New KeyFile" ),utility::homePath() ) ;
  322 
  323     if( !Z.isEmpty() ){
  324 
  325         m_ui->textEditPassphraseToAdd->setText( Z ) ;
  326     }
  327 
  328     this->setFieldFocus() ;
  329 }
  330 
  331 void luksaddkey::pbOpenFile( void )
  332 {
  333     auto Z = QFileDialog::getOpenFileName( this,tr( "Encrypted Volume Path" ),utility::homePath() ) ;
  334 
  335     if( !Z.isEmpty() ){
  336 
  337         m_ui->textEditPathToVolume->setText( Z ) ;
  338     }
  339 
  340     this->setFieldFocus() ;
  341 }
  342 
  343 void luksaddkey::pbOpenPartition( void )
  344 {
  345     openvolume::instance( this,false ).showLuksOnly().ShowAllPartitions( [ this ]( const QString& e ){
  346 
  347         this->setFieldFocus() ;
  348         this->ShowUI( e ) ;
  349     } ) ;
  350 }
  351 
  352 void luksaddkey::pbAdd( void )
  353 {
  354     DialogMsg msg( this ) ;
  355 
  356     std::function< void() > sendNewKey = [](){} ;
  357     std::function< void() > sendExistingKey = [](){} ;
  358 
  359     this->disableAll() ;
  360 
  361     utility::raii raii( [ this ](){ this->enableAll() ; } ) ;
  362 
  363     auto ExistingKey = m_ui->textEditExistingPassphrase->text() ;
  364 
  365     auto NewKey = m_ui->textEditPassphraseToAdd->text() ;
  366     auto NewKey_1 = m_ui->lineEditReEnterPassphrase->text() ;
  367 
  368     m_volumePath = m_ui->textEditPathToVolume->text() ;
  369 
  370     auto existingKeyIsKeyFile = m_ui->cbExistingKey->currentIndex() == 1 ;
  371     auto newKeyIsKeyFile = m_ui->cbNewKey->currentIndex() == 1 ;
  372 
  373     if( m_volumePath.isEmpty() ){
  374 
  375         return msg.ShowUIOK( tr( "ERROR!" ),tr( "Atleast one required field is empty" ) ) ;
  376     }
  377 
  378     m_volumePath = utility::resolvePath( m_volumePath ) ;
  379 
  380     if( utility::requireSystemPermissions( m_volumePath ) ){
  381 
  382         if( !utility::enablePolkit( utility::background_thread::False ) ){
  383 
  384             return  msg.ShowUIOK( tr( "ERROR!" ),tr( "Failed to enable polkit support" ) ) ;
  385         }
  386     }
  387 
  388     if( existingKeyIsKeyFile ){
  389 
  390         if( ExistingKey.isEmpty() ){
  391 
  392             return msg.ShowUIOK( tr( "ERROR!" ),tr( "Atleast one required field is empty" ) ) ;
  393         }
  394     }
  395 
  396     if( newKeyIsKeyFile ){
  397 
  398         if( NewKey.isEmpty() ){
  399 
  400             return msg.ShowUIOK( tr( "ERROR!" ),tr( "Atleast one required field is empty" ) ) ;
  401         }
  402     }else{
  403         if( !m_yubekeyNewKey ){
  404 
  405             if( NewKey != NewKey_1 ){
  406 
  407                 msg.ShowUIOK( tr( "ERROR!" ),tr( "Keys do not match" ) ) ;
  408 
  409                 m_ui->textEditPassphraseToAdd->clear() ;
  410                 m_ui->lineEditReEnterPassphrase->clear() ;
  411                 m_ui->textEditPassphraseToAdd->setFocus() ;
  412 
  413                 return ;
  414             }
  415         }
  416     }
  417 
  418     QString existingPassType ;
  419 
  420     if( existingKeyIsKeyFile ){
  421 
  422         ExistingKey = utility::resolvePath( ExistingKey ).replace( "\"","\"\"\"" ) ;
  423         existingPassType = "-u" ;
  424     }else{
  425         auto k = m_ui->textEditExistingPassphrase->text() ;
  426 
  427         if( m_yubikeyExistingKey ){
  428 
  429             auto m = utility::yubiKey( k ) ;
  430 
  431             if( m.has_value() ){
  432 
  433                 k = m.value() ;
  434             }else{
  435                 this->cbExistingKey( 0 ) ;
  436                 return m_label.show( tr( "Failed To Locate Or Run Yubikey's \"ykchalresp\" Program." ) ) ;
  437             }
  438         }
  439 
  440         existingPassType = "-u" ;
  441         ExistingKey = utility::keyPath() + "-existingKey" ;
  442 
  443         sendExistingKey = [ = ](){
  444 
  445             utility::keySend( ExistingKey,k ) ;
  446         } ;
  447     }
  448 
  449     QString newPassType ;
  450 
  451     if( newKeyIsKeyFile ){
  452 
  453         NewKey = utility::resolvePath( NewKey ).replace( "\"","\"\"\"" ) ;
  454         newPassType = "-n" ;
  455     }else{
  456         auto k = m_ui->textEditPassphraseToAdd->text() ;
  457 
  458         if( m_yubekeyNewKey ){
  459 
  460             auto m = utility::yubiKey( k ) ;
  461 
  462             if( m.has_value() ){
  463 
  464                 k = m.value() ;
  465             }else{
  466                 this->cbNewKey( 0 ) ;
  467                 return m_label.show( tr( "Failed To Locate Or Run Yubikey's \"ykchalresp\" Program." ) ) ;
  468             }
  469         }
  470 
  471         newPassType = "-n" ;
  472 
  473         NewKey = utility::keyPath() + "-newKey" ;
  474 
  475         sendNewKey = [ = ](){
  476 
  477             utility::keySend( NewKey,k ) ;
  478         } ;
  479     }
  480 
  481     const QString& a = QString( ZULUCRYPTzuluCrypt ) ;
  482 
  483     QString b = m_volumePath ;
  484 
  485     b.replace( "\"","\"\"\"" ) ;
  486 
  487     const QString& c = existingPassType ;
  488     const QString& d = ExistingKey ;
  489     const QString& e = newPassType ;
  490     const QString& f = NewKey ;
  491 
  492     auto r = "%1 -a -d \"%2\" %3 \"%4\" %5 \"%6\"" ;
  493 
  494     auto exe = utility::appendUserUID( r ).arg( a,b,c,d,e,f ) ;
  495 
  496     if( m_ui->cbVolumeType->currentIndex() == 2 ){
  497 
  498         exe += " -t vcrypt" ;
  499 
  500         auto e = m_ui->lineEditPIM->text() ;
  501 
  502         if( !e.isEmpty() ){
  503 
  504             exe += "." + e ;
  505         }
  506     }
  507 
  508     m_isWindowClosable = false ;
  509 
  510     m_veraCryptWarning.show( m_ui->cbVolumeType->currentIndex() == 2 ) ;
  511 
  512     raii.cancel() ;
  513 
  514     sendNewKey() ;
  515     sendExistingKey() ;
  516 
  517     this->taskFinished( utility::Task::run( exe ).await() ) ;
  518 }
  519 
  520 void luksaddkey::keyAdded()
  521 {
  522     m_volumePath.replace( "\"","\"\"\"" ) ;
  523 
  524     auto l = utility::luksEmptySlots( m_volumePath ).await() ;
  525 
  526     QString success ;
  527 
  528     if( l.isEmpty() ){
  529 
  530         m_label.show( tr( "Key added successfully." ) ) ;
  531     }else{
  532         QString x = tr( "Key added successfully.\n%1 / %2 slots are now in use" ) ;
  533         m_label.show( x.arg( l.first() ).arg( l.at( 1 ) ) ) ;
  534     }
  535 
  536     this->HideUI() ;
  537 }
  538 
  539 void luksaddkey::taskFinished( const utility::Task& e )
  540 {
  541     m_veraCryptWarning.stopTimer() ;
  542 
  543     m_isWindowClosable = true ;
  544 
  545     switch( e.exitCode() ){
  546         case 0  : return this->keyAdded() ;
  547         case 1  : m_label.show( tr( "Presented key does not match any key in the volume" ) ) ;              break ;
  548         case 2  : m_label.show( tr( "Could not open luks volume" ) ) ;                          break ;
  549         case 3  : m_label.show( tr( "Volume is not a luks volume" ) ) ;                         break ;
  550         case 4  : m_label.show( tr( "Insufficient privilege to add a key to a system device,\nonly root user or members of group \"zulucrypt\" can do that\n" ) )   ;break ;
  551         case 5  : m_label.show( tr( "Could not open volume in write mode" ) ) ;                 break ;
  552         case 6  : m_label.show( tr( "All key slots are occupied, can not add any more keys" ) ) ;       break ;
  553         case 7  : m_label.show( tr( "Can not get passphrase in silent mode" ) ) ;               break ;
  554         case 8  : m_label.show( tr( "Insufficient memory to hold passphrase" ) ) ;                          break ;
  555         case 9  : m_label.show( tr( "New passphrases do not match" ) ) ;                        break ;
  556         case 10 : m_label.show( tr( "One or more required argument(s) for this operation is missing" ) ) ;          break ;
  557         case 11 : m_label.show( tr( "One or both keyfile(s) does not exist" ) ) ;               break ;
  558         case 12 : m_label.show( tr( "Insufficient privilege to open key file for reading" ) ) ;         break ;
  559         case 13 : m_label.show( tr( "Couldnt get enought memory to hold the key file" ) ) ;         break ;
  560         case 14 : m_label.show( tr( "Could not get a key from a socket" ) ) ;                   break ;
  561         case 15 : m_label.show( tr( "Could not get elevated privilege,check binary permissions" ) ) ;       break ;
  562         case 110: m_label.show( tr( "Can not find a partition that match presented UUID" ) ) ;          break ;
  563         case 113: m_label.show( tr( "Device is not a luks device" ) ) ;                     break ;
  564         default:  m_label.show( tr( "Error Code: %1\n--\nStdOut: %2\n--\nStdError: %3").arg( QString::number( e.exitCode() ),QString( e.stdError() ),QString( e.stdOut() ) ) ) ;
  565     }
  566 
  567     m_veraCryptWarning.hide() ;
  568 
  569     this->enableAll() ;
  570 }
  571 
  572 void luksaddkey::disableAll()
  573 {
  574     m_ui->lineEditPIM->setEnabled( false ) ;
  575     m_ui->label_4->setEnabled( false ) ;
  576     m_ui->cbVolumeType->setEnabled( false ) ;
  577     m_ui->label_3->setEnabled( false ) ;
  578     m_ui->labelExistingPassphrase->setEnabled( false ) ;
  579     m_ui->labelLuksVolume->setEnabled( false ) ;
  580     m_ui->labelNewPassphrase->setEnabled( false ) ;
  581     m_ui->textEditExistingPassphrase->setEnabled( false ) ;
  582     m_ui->textEditPassphraseToAdd->setEnabled( false ) ;
  583     m_ui->textEditPathToVolume->setEnabled( false ) ;
  584     m_ui->lineEditReEnterPassphrase->setEnabled( false ) ;
  585     m_ui->labelNewPassphrase->setEnabled( false ) ;
  586     m_ui->lineEditReEnterPassphrase->setEnabled( false ) ;
  587     m_ui->pushButtonAdd->setEnabled( false ) ;
  588     m_ui->pushButtonCancel->setEnabled( false ) ;
  589     m_ui->pushButtonOpenExistingKeyFile->setEnabled( false ) ;
  590     m_ui->pushButtonOpenFile->setEnabled( false ) ;
  591     m_ui->pushButtonOpenNewKeyFile->setEnabled( false ) ;
  592     m_ui->pushButtonOpenPartition->setEnabled( false ) ;
  593     m_ui->labelReEnterPassphrase->setEnabled( false ) ;
  594     m_ui->label->setEnabled( false ) ;
  595     m_ui->label_2->setEnabled( false ) ;
  596     m_ui->cbNewKey->setEnabled( false ) ;
  597     m_ui->cbExistingKey->setEnabled( false ) ;
  598 }
  599 
  600 void luksaddkey::enableAll()
  601 {
  602     auto index = m_ui->cbVolumeType->currentIndex() ;
  603 
  604     m_ui->label_4->setEnabled( index == 2 ) ;
  605     m_ui->lineEditPIM->setEnabled( index == 2 ) ;
  606     m_ui->cbVolumeType->setEnabled( true ) ;
  607     m_ui->label_3->setEnabled( true ) ;
  608     m_ui->labelReEnterPassphrase->setEnabled( true ) ;
  609     m_ui->labelExistingPassphrase->setEnabled( true ) ;
  610     m_ui->labelLuksVolume->setEnabled( true ) ;
  611     m_ui->labelNewPassphrase->setEnabled( true ) ;
  612     m_ui->textEditExistingPassphrase->setEnabled( true ) ;
  613     m_ui->textEditPassphraseToAdd->setEnabled( true ) ;
  614     m_ui->textEditPathToVolume->setEnabled( true ) ;
  615     m_ui->labelNewPassphrase->setEnabled( true ) ;
  616     m_ui->pushButtonAdd->setEnabled( true ) ;
  617     m_ui->pushButtonCancel->setEnabled( true ) ;
  618     m_ui->pushButtonOpenExistingKeyFile->setEnabled( true ) ;
  619     m_ui->pushButtonOpenFile->setEnabled( true ) ;
  620     m_ui->pushButtonOpenNewKeyFile->setEnabled( true ) ;
  621     m_ui->pushButtonOpenPartition->setEnabled( true ) ;
  622     m_ui->lineEditPIM->setEnabled( true ) ;
  623     m_ui->cbNewKey->setEnabled( true ) ;
  624     m_ui->cbExistingKey->setEnabled( true ) ;
  625 
  626     index = m_ui->cbNewKey->currentIndex() ;
  627 
  628     if( index == 0 ){
  629 
  630         m_ui->lineEditReEnterPassphrase->setEnabled( true ) ;
  631 
  632     }else if( index == 1 ){
  633 
  634         m_ui->lineEditReEnterPassphrase->setEnabled( false ) ;
  635 
  636     }else if( index == 2 ){
  637 
  638         m_ui->lineEditReEnterPassphrase->setEnabled( false ) ;
  639         m_ui->textEditPassphraseToAdd->setEnabled( false ) ;
  640     }
  641 
  642     m_ui->label->setEnabled( true ) ;
  643     m_ui->label_2->setEnabled( true ) ;
  644 }
  645 
  646 void luksaddkey::pbCancel( void )
  647 {
  648     this->HideUI() ;
  649 }
  650 
  651 luksaddkey::~luksaddkey()
  652 {
  653     delete m_ui ;
  654 }