signon  8.58
crypto-handlers.h
Go to the documentation of this file.
1 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of signon
4  *
5  * Copyright (C) 2009-2011 Nokia Corporation.
6  *
7  * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
8  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * version 2.1 as published by the Free Software Foundation.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22  * 02110-1301 USA
23  */
24 
25 
32 #ifndef SIGNON_CRYPTSETUP_HANDLER_H
33 #define SIGNON_CRYPTSETUP_HANDLER_H
34 
35 #include <QProcess>
36 #include <QMap>
37 #include <QFile>
38 
39 
44 class SystemCommandLineCallHandler: public QObject
45 {
46  Q_OBJECT
47 
48 public:
53 
58 
67  bool makeCall(const QString &appPath,
68  const QStringList &args,
69  bool readOutput = false);
70 
75  QByteArray output() const { return m_output; }
76 
77 private Q_SLOTS:
78  void error(QProcess::ProcessError err);
79 
80 private:
81  QProcess m_process;
82  QByteArray m_output;
83 
84  Q_DISABLE_COPY(SystemCommandLineCallHandler);
85 };
86 
92 {
93  enum {
94  Ext2 = 0,
96  Ext4
97  };
103  static bool createPartitionFile(const QString &fileName,
104  const quint32 fileSize);
105 
113  static bool formatPartitionFile(const QString &fileName,
114  const quint32 fileSystemType);
115 
116 private:
121  Q_DISABLE_COPY(PartitionHandler)
122 };
123 
124 
129 {
137  static bool mount(const QString &source,
138  const QString &target,
139  const QString &fileSystemType = QLatin1String("ext2"));
145  static bool umount(const QString &target);
146 
147 private:
151  MountHandler();
152  Q_DISABLE_COPY(MountHandler)
153 };
154 
155 
162 {
168  static bool setupDevice(const QString &deviceName,
169  const QString &blockDevice);
170 
175  static QString findAvailableDevice();
176 
182  static bool releaseDevice(const QString &deviceName);
183 
184 private:
188  LosetupHandler();
189  Q_DISABLE_COPY(LosetupHandler)
190 };
191 
192 
200 {
206  static bool formatFile(const QByteArray &key, const QString &deviceName);
207 
214  static bool openFile(const QByteArray &key,
215  const QString &deviceName,
216  const QString &deviceMap);
217 
222  static bool closeFile(const QString &deviceName);
223 
229  static bool removeFile(const QString &deviceName);
230 
240  static bool addKeySlot(const QString &deviceName,
241  const QByteArray &key,
242  const QByteArray &existingKey);
243 
251  static bool removeKeySlot(const QString &deviceName,
252  const QByteArray &key,
253  const QByteArray &remainingKey);
254 
259  static bool loadDmMod();
260 
264  static QString error();
265 
266 private:
271  Q_DISABLE_COPY(CryptsetupHandler)
272 };
273 
274 #endif // SIGNON_CRYPTSETUP_HANDLER_H
bool makeCall(const QString &appPath, const QStringList &args, bool readOutput=false)
Executes the application at appPath in a separate child process.
Wraps the libcryptsetup API functionality.
~SystemCommandLineCallHandler()
Destructor.
QByteArray output() const
SystemCommandLineCallHandler()
Basic constructor.
Handles mounting, unmounting of loopback devices.
Handles mounting and unmounting of file systems.
Handles calls to system command line tools.