~ubuntu-branches/ubuntu/oneiric/partitionmanager/oneiric

« back to all changes in this revision

Viewing changes to src/jobs/setfilesystemlabeljob.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2009-01-23 17:57:36 UTC
  • Revision ID: james.westby@ubuntu.com-20090123175736-2ltrhgg3m55dokbm
Tags: upstream-1.0.0~beta1a
ImportĀ upstreamĀ versionĀ 1.0.0~beta1a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2008 by Volker Lanz <vl@fidra.de>                       *
 
3
 *                                                                         *
 
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.                                   *
 
8
 *                                                                         *
 
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.                          *
 
13
 *                                                                         *
 
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
 ***************************************************************************/
 
19
 
 
20
#include "jobs/setfilesystemlabeljob.h"
 
21
 
 
22
#include "core/partition.h"
 
23
 
 
24
#include "fs/filesystem.h"
 
25
 
 
26
#include "util/report.h"
 
27
 
 
28
#include <klocale.h>
 
29
 
 
30
/** Creates a new SetFileSystemLabelJob
 
31
        @param p the Partition the FileSystem whose label is to be set is on
 
32
        @param newlabel the new label
 
33
*/
 
34
SetFileSystemLabelJob::SetFileSystemLabelJob(Partition& p, const QString& newlabel) :
 
35
        Job(),
 
36
        m_Partition(p),
 
37
        m_Label(newlabel)
 
38
{
 
39
}
 
40
 
 
41
bool SetFileSystemLabelJob::run(Report& parent)
 
42
{
 
43
        bool rval = true;
 
44
 
 
45
        Report* report = jobStarted(parent);
 
46
 
 
47
        // If there's no support for file system label setting for this file system,
 
48
        // just ignore the request and say all is well. This helps in operations because
 
49
        // we don't have to check for support to avoid having a failed job.
 
50
        if (partition().fileSystem().supportSetLabel() == FileSystem::SupportNone)
 
51
                report->line() << i18nc("@info/plain", "File system on partition <filename>%1</filename> does not support setting labels. Job ignored.", partition().deviceNode());
 
52
        else if (partition().fileSystem().supportSetLabel() == FileSystem::SupportExternal)
 
53
        {
 
54
                rval = partition().fileSystem().writeLabel(*report, partition().deviceNode(), label());
 
55
 
 
56
                if (rval)
 
57
                        partition().fileSystem().setLabel(label());
 
58
        }
 
59
 
 
60
        jobFinished(*report, rval);
 
61
                
 
62
        return rval;
 
63
}
 
64
 
 
65
QString SetFileSystemLabelJob::description() const
 
66
{
 
67
        return i18nc("@info/plain", "Set the file system label on partition <filename>%1</filename> to \"%2\"", partition().deviceNode(), label());
 
68
}