~ben-kietzman/ubuntu/quantal/mountmanager/fix-for-598070

« back to all changes in this revision

Viewing changes to sources/core/diskcore.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2008-08-20 10:22:14 UTC
  • Revision ID: james.westby@ubuntu.com-20080820102214-fv93myu0ncb1503r
Tags: upstream-0.2.4
ImportĀ upstreamĀ versionĀ 0.2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//MountManager - the program for easy mounting of storage devices in Linux
 
2
//Copyright (C) 2007-2008 Tikhonov Sergey
 
3
//
 
4
//This file is part of MountManager Core
 
5
//
 
6
//This program is free software; you can redistribute it and/or
 
7
//modify it under the terms of the GNU General Public License
 
8
//as published by the Free Software Foundation; either version 2
 
9
//of the License, or (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, write to the Free Software
 
18
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
#include <QDebug>
 
20
#include "diskdevice.h"
 
21
#include "diskbackup.h"
 
22
#include "diskcore.h"
 
23
 
 
24
DiskCore::DiskCore(const QString &backupPath,bool debug) : DiskHal(debug), DiskBackUp(backupPath) {
 
25
        process = new QProcess;
 
26
        connect(process,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(processFinished(int,QProcess::ExitStatus)));
 
27
}
 
28
 
 
29
DiskCore::~DiskCore() {
 
30
        delete process;
 
31
}
 
32
 
 
33
void DiskCore::mount(const QString &blockName,const QString& mountPoint, const QString& fs, const QString& options) {
 
34
        process->execute(QString("mount -t %1 -o %2 %3 %4").arg(fs).arg(options).arg(blockName).arg(mountPoint));
 
35
}
 
36
 
 
37
void DiskCore::unmount(DiskDevice *deviceToUnmount) {
 
38
        unmount(deviceToUnmount->blockName());
 
39
}
 
40
 
 
41
void DiskCore::unmount(const QString &blockName) {
 
42
        process->execute(QString("umount %1").arg(blockName));
 
43
}
 
44
 
 
45
void DiskCore::mountAll() {
 
46
        process->execute("mount -a");
 
47
}
 
48
 
 
49
void DiskCore::unmountAll() {
 
50
        process->execute("umount -a");
 
51
}
 
52
 
 
53
void DiskCore::processFinished(int exitCode, QProcess::ExitStatus /*exitStatus*/) {
 
54
        if (exitCode != 0) {
 
55
                errorText = QString::fromUtf8(process->readAllStandardError().data());
 
56
                qDebug() << "[E] Error appeared:" << errorText;
 
57
                if (errorText.isEmpty())
 
58
                        emit (errorAppeared(tr("There is an unknown error - maybe you haven't enough rights for this action")));
 
59
                else
 
60
                        emit (errorAppeared(tr("Error") + ": " + errorText));
 
61
        } else
 
62
                errorText.clear();
 
63
}
 
64
 
 
65
const QString& DiskCore::error() const {
 
66
        return errorText;
 
67
}