Skip to content

Commit

Permalink
revisit cryfs support on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mhogomchungu committed Sep 23, 2019
1 parent fda210a commit c6877a8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
13 changes: 10 additions & 3 deletions src/engines/cryfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,15 @@ engines::engine::args cryfs::command( const QString& password,

engines::engine::status cryfs::errorCode( const QString& e,int s ) const
{
auto m = utility::unwrap( utility::backendIsGreaterOrEqualTo( "cryfs","0.9.9" ) ) ;
auto m = [ & ](){

if( utility::platformIsWindows() ){

return utility::result< bool >() ;
}else{
return utility::unwrap( utility::backendIsGreaterOrEqualTo( "cryfs","0.9.9" ) ) ;
}
}() ;

if( m && m.value() ){

Expand All @@ -136,8 +144,7 @@ engines::engine::status cryfs::errorCode( const QString& e,int s ) const
/*
* Falling back to parsing strings
*/

if( e.contains( this->incorrectPasswordText() ) ){
if( utility::containsAtleastOne( e,"Error 11:",this->incorrectPasswordText() ) ){

return engines::engine::status::cryfsBadPassword ;

Expand Down
6 changes: 3 additions & 3 deletions src/engines/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ static utility::result< custom::opts > _getOptions( const QByteArray& e,const QS

s.baseOpts.hasGUICreateOptions = true ;
s.baseOpts.customBackend = true ;
s.baseOpts.requiresAPassword = json.getBool( "requiresAPassword" ) ;
s.baseOpts.autoMountsOnCreate = json.getBool( "autoMountsOnVolumeCreation" ) ;
s.baseOpts.supportsMountPathsOnWindows = json.getBool( "supportsMountPointPaths" ) ;
s.mountControlStructure = json.getString( "mountControlStructure" ) ;
s.createControlStructure = json.getString( "createControlStructure" ) ;
s.baseOpts.reverseString = json.getString( "reverseString" ) ;
s.baseOpts.idleString = json.getString( "idleString" ) ;
s.baseOpts.requiresAPassword = json.getBool( "requiresAPassword" ) ;
s.baseOpts.autoMountsOnCreate = json.getBool( "autoMountsOnVolumeCreation" ) ;
s.baseOpts.supportsMountPathsOnWindows = json.getBool( "supportsMountPointPaths" ) ;
s.baseOpts.executableName = json.getString( "executableName" ) ;
s.baseOpts.incorrectPasswordText = json.getString( "wrongPasswordText" ) ;
s.baseOpts.passwordFormat = json.getString( "passwordFormat" ) ;
Expand Down
20 changes: 12 additions & 8 deletions src/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,18 +450,22 @@ namespace utility
return false ;
}

template< typename E,typename ... F >
bool containsAtleastOne( const E& e,const F& ... f )
template< typename E >
bool containsAtleastOne( const E& e )
{
for( const auto& it : { f ... } ){
Q_UNUSED( e )
return false ;
}

if( e.contains( it ) ){
template< typename E,typename F,typename ... G >
bool containsAtleastOne( const E& e,F&& f,G&& ... g )
{
if( e.contains( f ) ){

return true ;
}
return true ;
}else{
return containsAtleastOne( e,std::forward< G >( g ) ... ) ;
}

return false ;
}

template< typename E,typename ... F >
Expand Down

0 comments on commit c6877a8

Please sign in to comment.