kdf
disklist.h
Go to the documentation of this file.00001 /* 00002 * disklist.h 00003 * 00004 * Copyright (c) 1999 Michael Kropfberger <michael.kropfberger@gmx.net> 00005 * 00006 * Requires the Qt widget libraries, available at no cost at 00007 * http://www.troll.no/ 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00022 */ 00023 00024 #ifndef __DISKLIST_H__ 00025 #define __DISKLIST_H__ 00026 00027 #include <kdebug.h> 00028 #include <kconfig.h> 00029 #include <klocale.h> 00030 //#include <kcontrol.h> 00031 00032 // defines the os-type 00033 #include <QtCore/qglobal.h> 00034 //Added by qt3to4: 00035 #include <Qt3Support/Q3PtrList> 00036 00037 #include "disks.h" 00038 00039 #define DF_COMMAND "df" 00040 // be pessimistic: df -T only works under linux !?? 00041 #if defined(_OS_LINUX_) 00042 #define DF_ARGS "-kT" 00043 #define NO_FS_TYPE false 00044 #else 00045 #define DF_ARGS "-k" 00046 #define NO_FS_TYPE true 00047 #endif 00048 00049 #ifdef _OS_SOLARIS_ 00050 #define CACHEFSTAB "/etc/cachefstab" 00051 #define FSTAB "/etc/vfstab" 00052 #else 00053 #define FSTAB "/etc/fstab" 00054 #endif 00055 00056 #define SEPARATOR "|" 00057 00058 /***************************************************************************/ 00059 typedef Q3PtrList<DiskEntry> DisksBase; 00060 typedef Q3PtrListIterator<DiskEntry> DisksIterator; 00061 00062 class KProcess; 00063 00064 /***************************************************************************/ 00065 class Disks : public DisksBase 00066 { 00067 public: 00068 Disks(bool deepCopies=true) { dc = deepCopies;} 00069 ~Disks() { clear(); } 00070 private: 00071 int compareItems( DiskEntry s1, DiskEntry s2 ) 00072 { 00073 int ret = s1.deviceName().compare(s2.deviceName()); 00074 if( ret == 0 ) 00075 { 00076 ret = s1.mountPoint().compare(s2.mountPoint()); 00077 } 00078 00079 kDebug() << "compareDISKS " << s1.deviceName() << " vs " << s2.deviceName() << " (" << ret << ")" ; 00080 return( ret ); 00081 } 00082 00083 /* 00084 int compareItems( DiskEntry* s1, DiskEntry* s2 ) { 00085 int ret; 00086 ret = strcmp (static_cast<DiskEntry*>(s1)->deviceName(), 00087 static_cast<DiskEntry*>(s2)->deviceName() ); 00088 if (0 == ret) 00089 ret = strcmp (static_cast<DiskEntry*>(s1)->mountPoint(), 00090 static_cast<DiskEntry*>(s2)->mountPoint()); 00091 return ret; 00092 }; 00093 */ 00094 00095 bool dc; 00096 }; 00097 00098 /***************************************************************************/ 00099 class DiskList : public QObject 00100 { Q_OBJECT 00101 public: 00102 DiskList( QObject *parent=0 ); 00103 ~DiskList(); 00104 int readFSTAB(); 00105 int readDF(); 00106 int find(const DiskEntry* disk) {return disks->find(disk);} 00107 DiskEntry* at(uint index) {return disks->at(index);} 00108 DiskEntry* first() {return disks->first();} 00109 DiskEntry* next() {return disks->next();} 00110 uint count() { return disks->count(); } 00111 00112 void deleteAllMountedAt(const QString &mountpoint); 00113 void setUpdatesDisabled(bool disable); 00114 00115 signals: 00116 void readDFDone(); 00117 void criticallyFull(DiskEntry *disk); 00118 00119 public slots: 00120 void loadSettings(); 00121 void applySettings(); 00122 00123 private slots: 00124 void dfDone(); 00125 00126 private: 00127 void replaceDeviceEntry(DiskEntry *disk); 00128 00129 Disks *disks; 00130 KProcess *dfProc; 00131 bool readingDFStdErrOut; 00132 KSharedConfigPtr config; 00133 bool updatesDisabled; 00134 00135 }; 00136 /***************************************************************************/ 00137 00138 00139 #endif
KDE 4.2 API Reference