zuluCrypt  5.7.1
About: zuluCrypt is a simple but feature rich solution for hard drives encryption. It can manage PLAIN dm-crypt, LUKS, TrueCrypt and VeraCrypt encrypted volumes.
  Fossies Dox: zuluCrypt-5.7.1.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

siritask.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-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 #ifndef SIRITASK_H
21 #define SIRITASK_H
22 
23 #include "volumeproperty.h"
24 #include "task.hpp"
25 #include "../zuluCrypt-gui/utility.h"
26 
27 #include <QVector>
28 #include <QString>
29 #include <QStringList>
30 
31 namespace siritask
32 {
33  class volumeType
34  {
35  public:
37  {
38  }
39  template< typename T >
40  volumeType( const T& type ) : m_type( type )
41  {
42  }
43  template< typename T >
44  volumeType& operator=( const T& e )
45  {
46  m_type = e ;
47  return *this ;
48  }
49  const QString& name() const
50  {
51  return m_type ;
52  }
53  template< typename T >
54  bool startsWith( const T& e ) const
55  {
56  return m_type.startsWith( e ) ;
57  }
58  QString executableFullPath() const
59  {
61  }
62  template< typename T >
63  bool operator==( const T& type ) const
64  {
65  return m_type == type ;
66  }
67  template< typename T >
68  bool operator!=( const T& type ) const
69  {
70  return m_type != type ;
71  }
72  template< typename ... T >
73  bool isOneOf( const T& ... t ) const
74  {
75  return utility::equalsAtleastOne( m_type,t ... ) ;
76  }
77  private:
78  QString m_type ;
79  };
80  struct options
81  {
82  using function_t = std::function< void( const QString& ) > ;
83 
84  options( const QString& cipher_folder,
85  const QString& plain_folder,
86  const QString& volume_key,
87  const QString& mount_options,
88  const QString& config_file_path,
89  const QString& volume_type,
90  bool unlock_in_read_only,
91  function_t folder_opener = []( const QString& e ){ Q_UNUSED( e ) } ) :
92 
93  cipherFolder( cipher_folder ),
94  plainFolder( plain_folder ),
95  key( volume_key ),
96  mOpt( mount_options ),
97  configFilePath( config_file_path ),
98  type( volume_type ),
99  ro( unlock_in_read_only ),
100  openFolder( folder_opener )
101  {
102  }
103 
104  QString cipherFolder ;
105  QString plainFolder ;
106  QString key ;
107  QString mOpt ;
108  QString configFilePath ;
110  bool ro ;
112  };
113 
114  enum class status
115  {
116  success,
117  cryfs,
118  encfs,
119  gocryptfs,
120  securefs,
121  ecryptfs,
129  unknown,
131  backendFail,
133  };
134 
135  class cmdStatus
136  {
137  public:
139  {
140  }
141  template< typename T = QString >
142  cmdStatus( const siritask::cmdStatus& s,const T& e = T() )
143  {
144  m_status = s.status() ;
145  m_exitCode = s.exitCode() ;
146 
147  if( e.isEmpty() ){
148 
149  m_message = s.msg() ;
150  }else{
151  m_message = e ;
152  }
153  }
154  template< typename T = QString >
155  cmdStatus( siritask::status s,const T& e = T() ) :
156  m_status( s ),m_message( e )
157  {
158  }
159  template< typename T >
160  cmdStatus( int s,const T& e ) :
161  m_exitCode( s ),m_message( e )
162  {
163  }
165  {
166  return m_status ;
167  }
168  bool operator==( siritask::status s ) const
169  {
170  return m_status == s ;
171  }
172  bool operator!=( siritask::status s ) const
173  {
174  return m_status != s ;
175  }
177  {
178  m_exitCode = s ;
179  return *this ;
180  }
182  {
183  m_status = s ;
184  return *this ;
185  }
186  template< typename T >
187  cmdStatus& setMessage( const T& e )
188  {
189  m_message = e ;
190  return *this ;
191  }
192  const QString& msg() const
193  {
194  return m_message ;
195  }
196  int exitCode() const
197  {
198  return m_exitCode ;
199  }
200  private:
201  int m_exitCode = -1 ;
203  QString m_message ;
204  };
205 
206  bool deleteMountFolder( const QString& ) ;
207  Task::future< bool >& encryptedFolderUnMount( const QString& cipherFolder,
208  const QString& mountPoint,
209  const QString& fileSystem ) ;
212 }
213 
214 #endif // SIRITASK_H
siritask::cmdStatus::cmdStatus
cmdStatus(siritask::status s, const T &e=T())
Definition: siritask.h:155
siritask::encryptedFolderUnMount
Task::future< bool > & encryptedFolderUnMount(const QString &cipherFolder, const QString &mountPoint, const QString &fileSystem)
Definition: siritask.cpp:112
siritask::options::plainFolder
QString plainFolder
Definition: siritask.h:105
LXQt::Wallet::Task::future
Definition: task.h:111
siritask::cmdStatus::setExitCode
cmdStatus & setExitCode(int s)
Definition: siritask.h:176
task.hpp
siritask::volumeType
Definition: siritask.h:33
siritask::volumeType::volumeType
volumeType(const T &type)
Definition: siritask.h:40
siritask::volumeType::m_type
QString m_type
Definition: siritask.h:78
siritask::status::backendFail
@ backendFail
siritask::options
Definition: siritask.h:80
siritask::volumeType::name
const QString & name() const
Definition: siritask.h:49
siritask::options::function_t
std::function< void(const QString &) > function_t
Definition: siritask.h:82
siritask::cmdStatus::cmdStatus
cmdStatus(const siritask::cmdStatus &s, const T &e=T())
Definition: siritask.h:142
siritask::status::gocryptfs
@ gocryptfs
siritask::cmdStatus::operator!=
bool operator!=(siritask::status s) const
Definition: siritask.h:172
siritask::cmdStatus
Definition: siritask.h:135
siritask::status::encfs
@ encfs
siritask::status::gocryptfsNotFound
@ gocryptfsNotFound
siritask::volumeType::operator=
volumeType & operator=(const T &e)
Definition: siritask.h:44
siritask::status::cryfs
@ cryfs
siritask::volumeType::operator!=
bool operator!=(const T &type) const
Definition: siritask.h:68
siritask::options::ro
bool ro
Definition: siritask.h:110
siritask
Definition: siritask.h:31
siritask::cmdStatus::setStatus
cmdStatus & setStatus(siritask::status s)
Definition: siritask.h:181
siritask::volumeType::startsWith
bool startsWith(const T &e) const
Definition: siritask.h:54
siritask::encryptedFolderCreate
Task::future< siritask::cmdStatus > & encryptedFolderCreate(const options &)
Definition: siritask.cpp:627
siritask::cmdStatus::exitCode
int exitCode() const
Definition: siritask.h:196
utility::executableFullPath
QString executableFullPath(const QString &)
Definition: zulupolkit.cpp:43
siritask::volumeType::volumeType
volumeType()
Definition: siritask.h:36
siritask::options::key
QString key
Definition: siritask.h:106
siritask::status::securefsNotFound
@ securefsNotFound
utility::equalsAtleastOne
bool equalsAtleastOne(const E &e, const F &... f)
Definition: utility.h:617
siritask::volumeType::operator==
bool operator==(const T &type) const
Definition: siritask.h:63
siritask::cmdStatus::msg
const QString & msg() const
Definition: siritask.h:192
siritask::cmdStatus::operator==
bool operator==(siritask::status s) const
Definition: siritask.h:168
volumeproperty.h
siritask::cmdStatus::setMessage
cmdStatus & setMessage(const T &e)
Definition: siritask.h:187
siritask::cmdStatus::m_message
QString m_message
Definition: siritask.h:203
siritask::status::cryfsNotFound
@ cryfsNotFound
siritask::status::success
@ success
siritask::status::ecryptfs
@ ecryptfs
siritask::cmdStatus::status
siritask::status status() const
Definition: siritask.h:164
siritask::cmdStatus::cmdStatus
cmdStatus()
Definition: siritask.h:138
siritask::deleteMountFolder
bool deleteMountFolder(const QString &)
Definition: siritask.cpp:102
siritask::status
status
Definition: siritask.h:114
siritask::options::mOpt
QString mOpt
Definition: siritask.h:107
siritask::options::cipherFolder
QString cipherFolder
Definition: siritask.h:104
siritask::volumeType::isOneOf
bool isOneOf(const T &... t) const
Definition: siritask.h:73
siritask::options::type
siritask::volumeType type
Definition: siritask.h:109
siritask::status::securefs
@ securefs
siritask::options::configFilePath
QString configFilePath
Definition: siritask.h:108
e
static QString e
Definition: about.cpp:31
siritask::cmdStatus::m_status
siritask::status m_status
Definition: siritask.h:202
siritask::status::ecrypfsBadExePermissions
@ ecrypfsBadExePermissions
siritask::status::ecryptfsIllegalPath
@ ecryptfsIllegalPath
siritask::options::options
options(const QString &cipher_folder, const QString &plain_folder, const QString &volume_key, const QString &mount_options, const QString &config_file_path, const QString &volume_type, bool unlock_in_read_only, function_t folder_opener=[](const QString &e){ Q_UNUSED(e) })
Definition: siritask.h:84
siritask::options::openFolder
function_t openFolder
Definition: siritask.h:111
siritask::status::encfsNotFound
@ encfsNotFound
siritask::volumeType::executableFullPath
QString executableFullPath() const
Definition: siritask.h:58
siritask::encryptedFolderMount
Task::future< siritask::cmdStatus > & encryptedFolderMount(const options &, bool=false)
Definition: siritask.cpp:535
siritask::status::ecryptfs_simpleNotFound
@ ecryptfs_simpleNotFound
siritask::cmdStatus::m_exitCode
int m_exitCode
Definition: siritask.h:201
siritask::status::cryfsMigrateFileSystem
@ cryfsMigrateFileSystem
siritask::cmdStatus::cmdStatus
cmdStatus(int s, const T &e)
Definition: siritask.h:160
siritask::status::failedToCreateMountPoint
@ failedToCreateMountPoint
siritask::status::unknown
@ unknown