Browse Source

making progress on the window front

pull/59/head
mhogomchungu 3 years ago
parent
commit
33794b5224
  1. 4
      CMakeLists.txt
  2. BIN
      icons/256x256/sirikali.ico
  3. 2
      src/configoptions.cpp
  4. 37
      src/keydialog.cpp
  5. 1
      src/keydialog.h
  6. 26
      src/mountinfo.cpp
  7. 37
      src/siritask.cpp
  8. 6
      src/siritask.h
  9. 23
      src/utility.cpp
  10. 1
      src/win_icon.rc
  11. 59
      src/winfsp.cpp
  12. 2
      src/winfsp.h

4
CMakeLists.txt

@ -316,7 +316,9 @@ if( APPLE )
add_executable( sirikali MACOSX_BUNDLE ${MOC} ${UI} ${SRC} ${TRAY_RC_SRCS} ${PROJECT_SOURCE_DIR}/icons/256x256/sirikali.icns )
else()
if( WIN32)
add_executable( sirikali WIN32 ${MOC} ${UI} ${SRC} ${TRAY_RC_SRCS} )
add_executable( sirikali WIN32 ${MOC} ${UI} ${SRC} ${TRAY_RC_SRCS} )
#add_executable( sirikali WIN32 ${MOC} ${UI} ${SRC} ${TRAY_RC_SRCS} src/win_icon.rc )
else()
add_executable( sirikali ${MOC} ${UI} ${SRC} ${TRAY_RC_SRCS} )
endif()

BIN
icons/256x256/sirikali.ico

2
src/configoptions.cpp

@ -77,7 +77,7 @@ configOptions::configOptions( QWidget * parent,
m_ui->lineEditMountPointPrefix->clear() ;
m_ui->lineEditMountPointPrefix->setEnabled( false ) ;
m_ui->pbMountPointPrefix->setEnabled( false ) ;
m_ui->lineEditFileManager->setEnabled( false ) ;
//m_ui->lineEditFileManager->setEnabled( false ) ;
}else{
m_ui->lineEditMountPointPrefix->setText( utility::mountPath() ) ;
}

37
src/keydialog.cpp

@ -182,8 +182,10 @@ void keyDialog::setUpInitUI()
if( utility::platformIsWindows() ){
m_ui->lineEditFolderPath->setText( "Z:" ) ;
utility::setWindowsMountPointOptions( this,m_ui->lineEditFolderPath,m_ui->pbOpenFolderPath ) ;
//m_ui->lineEditFolderPath->setText( "Z:" ) ;
//utility::setWindowsMountPointOptions( this,m_ui->lineEditFolderPath,m_ui->pbOpenFolderPath ) ;
m_ui->lineEditFolderPath->setText( utility::homePath() + "/Desktop/" ) ;
//m_ui->pbOpenFolderPath->setIcon( QIcon( ":/folder.png" ) ) ;
}else{
m_ui->lineEditFolderPath->setText( utility::homePath() + "/" ) ;
}
@ -205,10 +207,7 @@ void keyDialog::setUpInitUI()
QIcon folderIcon( ":/folder.png" ) ;
if( !utility::platformIsWindows() ){
m_ui->pbOpenFolderPath->setIcon( folderIcon ) ;
}
m_ui->pbOpenFolderPath->setIcon( folderIcon ) ;
m_ui->pbSetKeyKeyFile->setIcon( folderIcon ) ;
@ -852,6 +851,11 @@ void keyDialog::reportErrorMessage( const siritask::cmdStatus& s )
* Should not get here
*/
case siritask::status::volumeCreatedSuccessfully :
msg = tr( "Volume Created Successfully." ) ;
break ;
case siritask::status::cryfs :
msg = tr( "Failed To Unlock A Cryfs Volume.\nWrong Password Entered." ) ;
@ -967,6 +971,12 @@ void keyDialog::showErrorMessage( const siritask::cmdStatus& e )
void keyDialog::pbOK()
{
if( m_closeGUI ){
m_cancel() ;
return this->HideUI() ;
}
m_ui->checkBoxVisibleKey->setChecked( false ) ;
this->setUIVisible( true ) ;
@ -1040,14 +1050,19 @@ void keyDialog::encryptedFolderCreate()
}else{
this->reportErrorMessage( e ) ;
if( m_ui->cbKeyType->currentIndex() == keyDialog::Key ){
if( e == siritask::status::volumeCreatedSuccessfully ){
m_ui->lineEditKey->clear() ;
}
m_closeGUI = true ;
}else{
if( m_ui->cbKeyType->currentIndex() == keyDialog::Key ){
this->enableAll() ;
m_ui->lineEditKey->clear() ;
}
m_ui->lineEditKey->setFocus() ;
this->enableAll() ;
m_ui->lineEditKey->setFocus() ;
}
}
}

1
src/keydialog.h

@ -213,6 +213,7 @@ private :
bool m_reUseMountPoint ;
bool m_checked = false ;
bool m_hmac ;
bool m_closeGUI = false ;
secrets& m_secrets ;

26
src/mountinfo.cpp

@ -33,7 +33,7 @@
enum class background_thread{ True,False } ;
static QStringList _getwinfspInstances( background_thread thread )
static std::vector< QStringList > _getwinfspInstances( background_thread thread )
{
if( thread == background_thread::True ){
@ -89,6 +89,7 @@ static QStringList _unlocked_volumes( background_thread thread )
}else{
QStringList s ;
QString mode ;
QString m ;
QString fs ;
const QString w = "x x x:x x %1 %2,x - %3 %4 x" ;
@ -109,30 +110,36 @@ static QStringList _unlocked_volumes( background_thread thread )
auto _babySitter = [ & ](){
for( const auto& it : _getwinfspInstances( thread ) ){
for( const QStringList& e : _getwinfspInstances( thread ) ){
auto e = utility::split( it,' ' ) ;
if( e.size() > 7 ){
if( e.size() > 8 ){
if( e.contains( " -o ro " ) ){
if( e.contains( "ro" ) ){
mode = "ro" ;
}else{
mode = "rw" ;
}
auto m = e.at( 7 ).mid( 8 ) ;
for( const auto& it : e ){
if( it.startsWith( "subtype=" ) ){
m = it ;
m.replace( "subtype=","" ) ;
}
}
fs = "fuse." + m ;
s.append( w.arg( path( e.last() ),mode,fs,m + "@" + path( e.at( 8 ) ) ) ) ;
s.append( w.arg( path( e.last() ),mode,fs,m + "@" + path( e.at( 7 ) ) ) ) ;
}
}
} ;
auto _nonBabySitter = [ & ](){
#if 0
for( const auto& it : _getwinfspInstances( thread ) ){
auto e = utility::split( it,' ' ) ;
@ -153,6 +160,7 @@ static QStringList _unlocked_volumes( background_thread thread )
s.append( w.arg( path( e.last() ),mode,fs,m + "@" + path( e.at( 6 ) ) ) ) ;
}
}
#endif
} ;
if( SiriKali::Winfsp::babySittingBackends() ){

37
src/siritask.cpp

@ -29,13 +29,6 @@
using cs = siritask::status ;
static bool _windows_platform()
{
//return false ;
//return true ;
return utility::platformIsWindows() ;
}
static bool _create_folder( const QString& m )
{
if( utility::platformIsWindows() ){
@ -196,7 +189,7 @@ static bool _unmount_ecryptfs( const QString& cipherFolder,
static bool _unmount_rest( const QString& mountPoint,int maxCount )
{
if( _windows_platform() ){
if( utility::platformIsWindows() ){
return SiriKali::Winfsp::FspLaunchStop( mountPoint ).success() ;
}
@ -349,7 +342,7 @@ static QString _args( const QString& exe,const siritask::options& opt,
auto e = QString( "%1 mount -b %2 %3 -o fsname=securefs@%4 -o subtype=securefs %5 %6" ) ;
if( _windows_platform() ){
if( utility::platformIsWindows() ){
e.replace( " -b ","" ) ;
}
@ -533,7 +526,7 @@ static siritask::cmdStatus _status( const utility::Task& r,siritask::status s,bo
{
if( r.success() ){
return siritask::status::success ;
return siritask::cmdStatus( siritask::status::success,r.exitCode() ) ;
}
siritask::cmdStatus e( r.exitCode(),stdOut ? r.stdOut() : r.stdError() ) ;
@ -626,11 +619,16 @@ static siritask::cmdStatus _status( const utility::Task& r,siritask::status s,bo
return e ;
}
static utility::Task _run_task( const QString& cmd,const QString& password,bool ecryptfs )
static utility::Task _run_task( const QString& cmd,const QString& password,bool create,bool ecryptfs )
{
if( _windows_platform() ){
if( utility::platformIsWindows() ){
return SiriKali::Winfsp::FspLaunchStart( cmd,password.toLatin1() ) ;
if( create ){
return Task::process::run( cmd,password.toLatin1() ).get() ;
}else{
return SiriKali::Winfsp::FspLaunchStart( cmd,password.toLatin1() ) ;
}
}else{
return utility::Task( cmd,20000,utility::systemEnvironment(),
password.toLatin1(),[](){},ecryptfs ) ;
@ -653,7 +651,7 @@ static siritask::cmdStatus _cmd( bool create,const siritask::options& opt,
auto cmd = _args( exe,opt,configFilePath,create ) ;
auto s = _run_task( cmd,password,_ecryptfs( app ) ) ;
auto s = _run_task( cmd,password,create,_ecryptfs( app ) ) ;
return { cmd,_status( s,_status( app,status_type::exeName ),app == "encfs" ) } ;
} ;
@ -830,11 +828,16 @@ Task::future< siritask::cmdStatus >& siritask::encryptedFolderCreate( const siri
if( opt.type.isOneOf( "gocryptfs","securefs" ) ){
e = siritask::encryptedFolderMount( opt,true ).get() ;
if( utility::platformIsWindows() ){
e = cs::volumeCreatedSuccessfully ;
}else{
e = siritask::encryptedFolderMount( opt,true ).get() ;
if( e != cs::success ){
if( e != cs::success ){
_deleteFolders( opt.cipherFolder,opt.plainFolder ) ;
_deleteFolders( opt.cipherFolder,opt.plainFolder ) ;
}
}
}
}else{

6
src/siritask.h

@ -145,7 +145,8 @@ namespace siritask
ecryptfs_simpleNotFound,
unknown,
failedToCreateMountPoint,
backendFail
backendFail,
volumeCreatedSuccessfully
};
class cmdStatus
@ -154,6 +155,9 @@ namespace siritask
cmdStatus()
{
}
cmdStatus( siritask::status s,int c ) : m_exitCode( c ),m_status( s )
{
}
template< typename T = QString >
cmdStatus( const siritask::cmdStatus& s,const T& e = T() )
{

23
src/utility.cpp

@ -442,9 +442,12 @@ void utility::openPath( const QString& path,const QString& opener,
openPath( path,opener ).then( [ title,msg,obj ]( bool failed ){
if( failed && obj ){
if( !utility::platformIsWindows() ){
DialogMsg( obj ).ShowUIOK( title,msg ) ;
if( failed && obj ){
DialogMsg( obj ).ShowUIOK( title,msg ) ;
}
}
} ) ;
}
@ -1413,9 +1416,21 @@ QString utility::runCommandOnMount()
static QString _file_manager()
{
auto s = utility::platformIsLinux() ? "xdg-open" : "open" ;
QString s ;
QString e ;
if( utility::platformIsLinux() ){
auto e = utility::executableFullPath( s ) ;
s = "xdg-open" ;
e = utility::executableFullPath( s ) ;
}else if( utility::platformIsOSX() ){
s = "open" ;
e = utility::executableFullPath( s ) ;
}else{
s = "expoler.exe" ;
}
if( e.isEmpty() ){

1
src/win_icon.rc

@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "icons\\256x256\\sirikali.ico"

59
src/winfsp.cpp

@ -37,11 +37,11 @@ class manageInstances
public:
Task::process::result addInstance( const QString& args,const QByteArray& password ) ;
Task::process::result removeInstance( const QString& mountPoint ) ;
QStringList commands() const ;
std::vector< QStringList > commands() const ;
void updateVolumeList( std::function< void() > ) ;
private:
bool waitFor( QProcess *,QByteArray&,const char * ) ;
std::vector< std::pair< QProcess *,QString > > m_instances ;
std::vector< QProcess * > m_instances ;
std::function< void() > m_updateVolumeList ;
} ;
@ -52,7 +52,7 @@ public:
~ActiveInstances() ;
bool valid() const ;
const std::vector< SiriKali::Winfsp::winFsp >& values() const ;
QStringList commands() const ;
std::vector< QStringList > commands() const ;
private:
class impl ;
std::unique_ptr< impl > m_handle ;
@ -180,16 +180,9 @@ public:
{
return m_entries ;
}
QStringList commands() const
std::vector< QStringList > commands() const
{
QStringList s ;
for( const auto& it : m_entries ){
s.append( it.command ) ;
}
return s ;
return {} ;
}
private:
void addToList( const SiriKali::Winfsp::winFsp& e )
@ -336,7 +329,7 @@ public:
{
return m_entries ;
}
QStringList commands() const
std::vector< QStringList > commands() const
{
return {} ;
}
@ -365,36 +358,32 @@ const std::vector< SiriKali::Winfsp::winFsp >& SiriKali::Winfsp::ActiveInstances
return m_handle->values() ;
}
QStringList SiriKali::Winfsp::ActiveInstances::commands() const
std::vector< QStringList > SiriKali::Winfsp::ActiveInstances::commands() const
{
return m_handle->commands() ;
}
QStringList SiriKali::Winfsp::manageInstances::commands() const
std::vector< QStringList > SiriKali::Winfsp::manageInstances::commands() const
{
QStringList s ;
std::vector< QStringList > s ;
for( const auto& it : m_instances ){
const auto& y = it.second ;
auto e = it->arguments() ;
/*
* y will contain something like: "C:/path/to/executable mount -o rw -o fsname=securefs@"C:/vault" -o subtype=securefs "C:/vault" "Z:"
*
* below code removes the first argument because its useless and will cause problems if it contains a space character
*/
for( auto& m : e ){
int m = y.indexOf( "mount" ) ;
if( m != -1 ){
auto n = y ;
n.remove( 0,m ) ;
n.prepend( "woof " ) ;
s.append( n ) ;
/*
* linux's /proc/self/mountinfo makes these substitutions and we make
* them too to be consistent with linux
*/
//m.replace( "\n","\\012" ) ;
m.replace( " ","\\040" ) ;
//m.replace( "\\","\\134" ) ;
//m.replace( "\\t","\\011" ) ;
}
s.emplace_back( e ) ;
}
return s ;
@ -449,7 +438,7 @@ Task::process::result SiriKali::Winfsp::manageInstances::addInstance( const QStr
if( this->waitFor( exe,data,"init" ) ){
m_instances.emplace_back( exe,args ) ;
m_instances.emplace_back( exe ) ;
m_updateVolumeList() ;
@ -463,7 +452,7 @@ Task::process::result SiriKali::Winfsp::manageInstances::removeInstance( const Q
{
for( size_t i = 0 ; i < m_instances.size() ; i++ ){
auto e = m_instances[ i ].first ;
auto e = m_instances[ i ] ;
auto m = "\"" + e->arguments().at( 8 ) + "\"" ;
@ -516,7 +505,7 @@ Task::process::result SiriKali::Winfsp::FspLaunchStop( const QString& className,
return Task::process::result() ;
}
QStringList SiriKali::Winfsp::commands()
std::vector< QStringList > SiriKali::Winfsp::commands()
{
if( SiriKali::Winfsp::babySittingBackends() ){

2
src/winfsp.h

@ -51,7 +51,7 @@ int terminateProcess( unsigned long pid ) ;
QString readRegister( const char * path,const char * key ) ;
QStringList commands() ;
std::vector< QStringList > commands() ;
bool babySittingBackends() ;

Loading…
Cancel
Save