1/*
2* disklist.h
3*
4* Copyright (c) 1999 Michael Kropfberger <michael.kropfberger@gmx.net>
5* 2009 Dario Andres Rodriguez <andresbajotierra@gmail.com>
6*
7* This program is free software; you can redistribute it and/or modify
8* it under the terms of the GNU General Public License as published by
9* the Free Software Foundation; either version 2 of the License, or
10* (at your option) any later version.
11*
12* This program is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15* GNU General Public License for more details.
16*
17* You should have received a copy of the GNU General Public License
18* along with this program; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20*/
21
22#ifndef DISKLIST_H
23#define DISKLIST_H
24
25// defines the os-type
26#include <QtCore/qglobal.h>
27
28#include <ksharedconfig.h>
29
30#include "disks.h"
31
32static QLatin1String DF_Command = QLatin1String( "df" );
33
34#if defined(Q_OS_LINUX)
35 static QLatin1String DF_Args = QLatin1String( "-kT" );
36 static const bool No_FS_Type = false;
37#else
38 static QLatin1String DF_Args = QLatin1String( "-k" );
39 static const bool No_FS_Type = true;
40#endif
41
42#if defined(Q_OS_SOLARIS)
43 static QLatin1String CacheFSTAB = QLatin1String( "/etc/cachefstab" );
44 static QLatin1String FSTAB = QLatin1String( "/etc/vfstab" );
45#else
46 static QLatin1String FSTAB = QLatin1String( "/etc/fstab" );
47#endif
48
49static const QLatin1Char Separator = QLatin1Char( '|' );
50
51/***************************************************************************/
52typedef QList<DiskEntry*> Disks;
53typedef QList<DiskEntry*>::const_iterator DisksConstIterator;
54typedef QList<DiskEntry*>::iterator DisksIterator;
55
56class KProcess;
57
58class DiskList : public QObject
59{
60 Q_OBJECT
61
62 public:
63 DiskList( QObject *parent=0 );
64 ~DiskList();
65
66 int readFSTAB();
67 int readDF();
68 int find(DiskEntry* disk);
69 DiskEntry* at(uint index) { return disks->at(index); }
70 uint count() { return disks->count(); }
71 void deleteAllMountedAt(const QString &mountpoint);
72 void setUpdatesDisabled(bool disable);
73
74 //To iterate over disks items
75 DisksConstIterator disksConstIteratorBegin() { return disks->constBegin(); }
76 DisksConstIterator disksConstIteratorEnd() { return disks->constEnd(); }
77
78 DisksIterator disksIteratorBegin() { return disks->begin(); }
79 DisksIterator disksIteratorEnd() { return disks->end(); }
80
81 Q_SIGNALS:
82 void readDFDone();
83 void criticallyFull(DiskEntry *disk);
84
85 public slots:
86 void loadSettings();
87 void applySettings();
88
89 private slots:
90 void dfDone();
91
92 private:
93 void replaceDeviceEntry(DiskEntry *disk);
94
95 Disks *disks;
96 KProcess *dfProc;
97 bool readingDFStdErrOut;
98 KSharedConfigPtr config;
99 bool updatesDisabled;
100
101};
102/***************************************************************************/
103
104
105#endif
106
107