1
/***************************************************************************
2
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18
***************************************************************************/
24
#include "fs/filesystem.h"
29
#include <parted/parted.h>
38
/** @brief Base class for all Jobs.
40
Each Operation is made up of one or more Jobs. Usually, an Operation will run each Job it is
41
made up of and only complete successfully if each Job could be run without error. Jobs are
42
all-or-nothing and try to be as atomic as possible: A Job is either successfully run or not, there
43
is no case where a Job finishes with a warning.
47
class Job : public QObject
53
/** Status of this Job */
56
Pending = 0, /**< Pending, not yet run */
57
Success, /**< Successfully run */
58
Error /**< Running generated an error */
73
virtual qint32 numSteps() const { return 1; } /**< @return the number of steps the job takes to complete */
74
virtual QString description() const = 0; /**< @return the Job's description */
75
virtual bool run(Report& parent) = 0; /**< @param parent parent Report to add new child to for this Job @return true if successfully run */
77
virtual QIcon statusIcon() const;
78
virtual QString statusText() const;
80
JobStatus status() const { return m_Status; } /**< @return the Job's current status */
82
static FileSystem::Type detectFileSystem(PedDevice* pedDevice, PedPartition* pedPartition);
85
bool openPed(const QString& path, bool diskFailOk = false);
88
bool commit(quint32 timeout = 10);
89
static bool commit(PedDisk* disk, quint32 timeout = 10);
91
bool copyBlocks(Report& report, CopyTarget& target, CopySource& source);
92
bool rollbackCopyBlocks(Report& report, CopyTarget& origTarget, CopySource& origSource);
94
FileSystem::Type detectFileSystemBySector(Report& report, Device& device, qint64 sector);
96
void emitProgress(int i);
98
Report* jobStarted(Report& parent);
99
void jobFinished(Report& report, bool b);
101
void setStatus(JobStatus s) { m_Status = s; }
103
PedDevice* pedDevice() { return m_PedDevice; }
104
PedDisk* pedDisk() { return m_PedDisk; }
106
static PedFileSystemType* getPedFileSystemType(FileSystem::Type t);
107
static void pedTimerHandler(PedTimer* pedTimer, void* ctx);
110
PedDevice* m_PedDevice;