summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/storage.cpp60
-rw-r--r--library/storage.h4
2 files changed, 0 insertions, 64 deletions
diff --git a/library/storage.cpp b/library/storage.cpp
index 657fb71..d98139b 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -1,465 +1,405 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> 2** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org>
3** Copyright (C) Lorn Potter <llornkcor@handhelds.org> 3** Copyright (C) Lorn Potter <llornkcor@handhelds.org>
4** Copyright (C) 2000 Trolltech AS. All rights reserved. 4** Copyright (C) 2000 Trolltech AS. All rights reserved.
5** 5**
6** This file is part of Opie Environment. 6** This file is part of Opie Environment.
7** 7**
8** This file may be distributed and/or modified under the terms of the 8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software 9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the 10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file. 11** packaging of this file.
12** 12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15** 15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information. 16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17** 17**
18** Contact info@trolltech.com if any conditions of this licensing are 18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you. 19** not clear to you.
20** 20**
21**********************************************************************/ 21**********************************************************************/
22 22
23#include <qpe/storage.h> 23#include <qpe/storage.h>
24#include <qpe/custom.h> 24#include <qpe/custom.h>
25 25
26#include <qfile.h> 26#include <qfile.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qcopchannel_qws.h> 28#include <qcopchannel_qws.h>
29 29
30#include <stdio.h> 30#include <stdio.h>
31 31
32#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 32#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
33#include <sys/vfs.h> 33#include <sys/vfs.h>
34#include <mntent.h> 34#include <mntent.h>
35#endif 35#endif
36 36
37#ifdef Q_OS_MACX 37#ifdef Q_OS_MACX
38# include <sys/param.h> 38# include <sys/param.h>
39# include <sys/ucred.h> 39# include <sys/ucred.h>
40# include <sys/mount.h> 40# include <sys/mount.h>
41# include <stdio.h> // For strerror() 41# include <stdio.h> // For strerror()
42# include <errno.h> 42# include <errno.h>
43#endif /* Q_OS_MACX */ 43#endif /* Q_OS_MACX */
44 44
45#include <qstringlist.h> 45#include <qstringlist.h>
46 46
47// Shouldn't be here ! (eilers) 47// Shouldn't be here ! (eilers)
48// #include <sys/vfs.h> 48// #include <sys/vfs.h>
49// #include <mntent.h> 49// #include <mntent.h>
50 50
51 51
52static bool isCF(const QString& m) 52static bool isCF(const QString& m)
53{ 53{
54 54
55#ifndef Q_OS_MACX 55#ifndef Q_OS_MACX
56 FILE* f = fopen("/var/run/stab", "r"); 56 FILE* f = fopen("/var/run/stab", "r");
57 if (!f) f = fopen("/var/state/pcmcia/stab", "r"); 57 if (!f) f = fopen("/var/state/pcmcia/stab", "r");
58 if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); 58 if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
59 if ( f ) 59 if ( f )
60 { 60 {
61 char line[1024]; 61 char line[1024];
62 char devtype[80]; 62 char devtype[80];
63 char devname[80]; 63 char devname[80];
64 while ( fgets( line, 1024, f ) ) 64 while ( fgets( line, 1024, f ) )
65 { 65 {
66 // 0 ide ide-cs 0 hda 3 0 66 // 0 ide ide-cs 0 hda 3 0
67 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) 67 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 )
68 { 68 {
69 if ( QString(devtype) == "ide" && m.find(devname)>0 ) 69 if ( QString(devtype) == "ide" && m.find(devname)>0 )
70 { 70 {
71 fclose(f); 71 fclose(f);
72 return TRUE; 72 return TRUE;
73 } 73 }
74 } 74 }
75 } 75 }
76 fclose(f); 76 fclose(f);
77 } 77 }
78#endif /* Q_OS_MACX */ 78#endif /* Q_OS_MACX */
79 return FALSE; 79 return FALSE;
80} 80}
81 81
82/*! \class StorageInfo storage.h 82/*! \class StorageInfo storage.h
83 \brief The StorageInfo class describes the disks mounted on the file system. 83 \brief The StorageInfo class describes the disks mounted on the file system.
84 84
85 This class provides access to the mount information for the Linux 85 This class provides access to the mount information for the Linux
86 filesystem. Each mount point is represented by the FileSystem class. 86 filesystem. Each mount point is represented by the FileSystem class.
87 To ensure this class has the most up to date size information, call 87 To ensure this class has the most up to date size information, call
88 the update() method. Note that this will automatically be signaled 88 the update() method. Note that this will automatically be signaled
89 by the operating system when a disk has been mounted or unmounted. 89 by the operating system when a disk has been mounted or unmounted.
90 90
91 \ingroup qtopiaemb 91 \ingroup qtopiaemb
92*/ 92*/
93 93
94/*! Constructor that determines the current mount points of the filesystem. 94/*! Constructor that determines the current mount points of the filesystem.
95 The standard \a parent parameters is passed on to QObject. 95 The standard \a parent parameters is passed on to QObject.
96 */ 96 */
97StorageInfo::StorageInfo( QObject *parent ) 97StorageInfo::StorageInfo( QObject *parent )
98 : QObject( parent ) 98 : QObject( parent )
99{ 99{
100 mFileSystems.setAutoDelete( TRUE ); 100 mFileSystems.setAutoDelete( TRUE );
101 channel = new QCopChannel( "QPE/Card", this ); 101 channel = new QCopChannel( "QPE/Card", this );
102 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), 102 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)),
103 this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); 103 this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
104 update(); 104 update();
105} 105}
106 106
107/*! Returns the longest matching FileSystem that starts with the 107/*! Returns the longest matching FileSystem that starts with the
108 same prefix as \a filename as its mount point. 108 same prefix as \a filename as its mount point.
109*/ 109*/
110const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) 110const FileSystem *StorageInfo::fileSystemOf( const QString &filename )
111{ 111{
112 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) 112 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
113 { 113 {
114 if ( filename.startsWith( (*i)->path() ) ) 114 if ( filename.startsWith( (*i)->path() ) )
115 return (*i); 115 return (*i);
116 } 116 }
117 return 0; 117 return 0;
118} 118}
119 119
120 120
121void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) 121void StorageInfo::cardMessage( const QCString& msg, const QByteArray& )
122{ 122{
123 if ( msg == "mtabChanged()" ) 123 if ( msg == "mtabChanged()" )
124 update(); 124 update();
125} 125}
126 126
127 127
128/*! Updates the mount and free space available information for each mount 128/*! Updates the mount and free space available information for each mount
129 point. This method is automatically called when a disk is mounted or 129 point. This method is automatically called when a disk is mounted or
130 unmounted. 130 unmounted.
131*/ 131*/
132// cause of the lack of a d pointer we need 132// cause of the lack of a d pointer we need
133// to store informations in a config file :( 133// to store informations in a config file :(
134void StorageInfo::update() 134void StorageInfo::update()
135{ 135{
136 //qDebug("StorageInfo::updating"); 136 //qDebug("StorageInfo::updating");
137#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 137#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
138 struct mntent *me; 138 struct mntent *me;
139 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 139 FILE *mntfp = setmntent( "/etc/mtab", "r" );
140 140
141 QStringList curdisks; 141 QStringList curdisks;
142 QStringList curopts; 142 QStringList curopts;
143 QStringList curfs; 143 QStringList curfs;
144 bool rebuild = FALSE; 144 bool rebuild = FALSE;
145 int n=0; 145 int n=0;
146 if ( mntfp ) 146 if ( mntfp )
147 { 147 {
148 while ( (me = getmntent( mntfp )) != 0 ) 148 while ( (me = getmntent( mntfp )) != 0 )
149 { 149 {
150 QString fs = me->mnt_fsname; 150 QString fs = me->mnt_fsname;
151 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" 151 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd"
152 || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" 152 || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd"
153 || fs.left( 14 ) == "/dev/mmc/part1" 153 || fs.left( 14 ) == "/dev/mmc/part1"
154 || fs.left(5)=="tmpfs" || fs.left(9)=="/dev/root" ) 154 || fs.left(5)=="tmpfs" || fs.left(9)=="/dev/root" )
155 { 155 {
156 n++; 156 n++;
157 curdisks.append(fs); 157 curdisks.append(fs);
158 curopts.append( me->mnt_opts ); 158 curopts.append( me->mnt_opts );
159 //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); 159 //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts );
160 curfs.append( me->mnt_dir ); 160 curfs.append( me->mnt_dir );
161 bool found = FALSE; 161 bool found = FALSE;
162 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) 162 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
163 { 163 {
164 if ( (*i)->disk() == fs ) 164 if ( (*i)->disk() == fs )
165 { 165 {
166 found = TRUE; 166 found = TRUE;
167 break; 167 break;
168 } 168 }
169 } 169 }
170 if ( !found ) 170 if ( !found )
171 rebuild = TRUE; 171 rebuild = TRUE;
172 } 172 }
173 } 173 }
174 endmntent( mntfp ); 174 endmntent( mntfp );
175 } 175 }
176 if ( rebuild || n != (int)mFileSystems.count() ) 176 if ( rebuild || n != (int)mFileSystems.count() )
177 { 177 {
178 mFileSystems.clear(); 178 mFileSystems.clear();
179 QStringList::ConstIterator it=curdisks.begin(); 179 QStringList::ConstIterator it=curdisks.begin();
180 QStringList::ConstIterator fsit=curfs.begin(); 180 QStringList::ConstIterator fsit=curfs.begin();
181 QStringList::ConstIterator optsIt=curopts.begin(); 181 QStringList::ConstIterator optsIt=curopts.begin();
182 for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) 182 for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt)
183 { 183 {
184 QString opts = *optsIt; 184 QString opts = *optsIt;
185 185
186 QString disk = *it; 186 QString disk = *it;
187 QString humanname; 187 QString humanname;
188 bool removable = FALSE; 188 bool removable = FALSE;
189 if ( isCF(disk) ) 189 if ( isCF(disk) )
190 { 190 {
191 humanname = tr("CF Card"); 191 humanname = tr("CF Card");
192 removable = TRUE; 192 removable = TRUE;
193 } 193 }
194 else if ( disk == "/dev/hda1" ) 194 else if ( disk == "/dev/hda1" )
195 { 195 {
196 humanname = tr("Hard Disk"); 196 humanname = tr("Hard Disk");
197 } 197 }
198 else if ( disk.left(9) == "/dev/mmcd" ) 198 else if ( disk.left(9) == "/dev/mmcd" )
199 { 199 {
200 humanname = tr("SD Card"); 200 humanname = tr("SD Card");
201 removable = TRUE; 201 removable = TRUE;
202 } 202 }
203 else if ( disk.left( 14 ) == "/dev/mmc/part1" ) 203 else if ( disk.left( 14 ) == "/dev/mmc/part1" )
204 { 204 {
205 humanname = tr("MMC Card"); 205 humanname = tr("MMC Card");
206 removable = TRUE; 206 removable = TRUE;
207 } 207 }
208 else if ( disk.left(7) == "/dev/hd" ) 208 else if ( disk.left(7) == "/dev/hd" )
209 humanname = tr("Hard Disk") + " " + disk; 209 humanname = tr("Hard Disk") + " " + disk;
210 else if ( disk.left(7) == "/dev/sd" ) 210 else if ( disk.left(7) == "/dev/sd" )
211 humanname = tr("SCSI Hard Disk") + " " + disk; 211 humanname = tr("SCSI Hard Disk") + " " + disk;
212 else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs 212 else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs
213 humanname = tr("Internal Memory"); 213 humanname = tr("Internal Memory");
214 else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) 214 else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" )
215 humanname = tr("Internal Storage"); 215 humanname = tr("Internal Storage");
216 else if ( disk.left(14) == "/dev/mtdblock/" ) 216 else if ( disk.left(14) == "/dev/mtdblock/" )
217 humanname = tr("Internal Storage") + " " + disk; 217 humanname = tr("Internal Storage") + " " + disk;
218 else if ( disk.left(13) == "/dev/mtdblock" ) 218 else if ( disk.left(13) == "/dev/mtdblock" )
219 humanname = tr("Internal Storage") + " " + disk; 219 humanname = tr("Internal Storage") + " " + disk;
220 else if ( disk.left(9) == "/dev/root" ) 220 else if ( disk.left(9) == "/dev/root" )
221 humanname = tr("Internal Storage") + " " + disk; 221 humanname = tr("Internal Storage") + " " + disk;
222 else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs 222 else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs
223 humanname = tr("Internal Memory"); 223 humanname = tr("Internal Memory");
224 FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); 224 FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts );
225 mFileSystems.append( fs ); 225 mFileSystems.append( fs );
226 } 226 }
227 emit disksChanged(); 227 emit disksChanged();
228 } 228 }
229 else 229 else
230 { 230 {
231 // just update them 231 // just update them
232 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) 232 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
233 i.current()->update(); 233 i.current()->update();
234 } 234 }
235#endif 235#endif
236} 236}
237 237
238bool deviceTab( const char *device) 238bool deviceTab( const char *device)
239{ 239{
240 QString name = device; 240 QString name = device;
241 bool hasDevice=false; 241 bool hasDevice=false;
242 242
243#ifdef Q_OS_MACX 243#ifdef Q_OS_MACX
244 // Darwin (MacOS X) 244 // Darwin (MacOS X)
245 struct statfs** mntbufp; 245 struct statfs** mntbufp;
246 int count = 0; 246 int count = 0;
247 if ( ( count = getmntinfo( mntbufp, MNT_WAIT ) ) == 0 ) 247 if ( ( count = getmntinfo( mntbufp, MNT_WAIT ) ) == 0 )
248 { 248 {
249 qWarning("deviceTab: Error in getmntinfo(): %s",strerror( errno ) ); 249 qWarning("deviceTab: Error in getmntinfo(): %s",strerror( errno ) );
250 hasDevice = false; 250 hasDevice = false;
251 } 251 }
252 for( int i = 0; i < count; i++ ) 252 for( int i = 0; i < count; i++ )
253 { 253 {
254 QString deviceName = mntbufp[i]->f_mntfromname; 254 QString deviceName = mntbufp[i]->f_mntfromname;
255 qDebug(deviceName); 255 qDebug(deviceName);
256 if( deviceName.left( name.length() ) == name ) 256 if( deviceName.left( name.length() ) == name )
257 hasDevice = true; 257 hasDevice = true;
258 } 258 }
259#else 259#else
260 // Linux 260 // Linux
261 struct mntent *me; 261 struct mntent *me;
262 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 262 FILE *mntfp = setmntent( "/etc/mtab", "r" );
263 if ( mntfp ) 263 if ( mntfp )
264 { 264 {
265 while ( (me = getmntent( mntfp )) != 0 ) 265 while ( (me = getmntent( mntfp )) != 0 )
266 { 266 {
267 QString deviceName = me->mnt_fsname; 267 QString deviceName = me->mnt_fsname;
268 // qDebug(deviceName); 268 // qDebug(deviceName);
269 if( deviceName.left(name.length()) == name) 269 if( deviceName.left(name.length()) == name)
270 { 270 {
271 hasDevice = true; 271 hasDevice = true;
272 } 272 }
273 } 273 }
274 } 274 }
275 endmntent( mntfp ); 275 endmntent( mntfp );
276#endif /* Q_OS_MACX */ 276#endif /* Q_OS_MACX */
277 277
278 278
279 return hasDevice; 279 return hasDevice;
280} 280}
281 281
282/*! 282/*!
283 * @fn static bool StorageInfo::hasCf() 283 * @fn static bool StorageInfo::hasCf()
284 * @brief returns whether device has Cf mounted 284 * @brief returns whether device has Cf mounted
285 * 285 *
286 */ 286 */
287bool StorageInfo::hasCf() 287bool StorageInfo::hasCf()
288{ 288{
289 return deviceTab("/dev/hd"); 289 return deviceTab("/dev/hd");
290} 290}
291 291
292/*! 292/*!
293 * @fn static bool StorageInfo::hasSd() 293 * @fn static bool StorageInfo::hasSd()
294 * @brief returns whether device has SD mounted 294 * @brief returns whether device has SD mounted
295 * 295 *
296 */ 296 */
297bool StorageInfo::hasSd() 297bool StorageInfo::hasSd()
298{ 298{
299 return deviceTab("/dev/mmcd"); 299 return deviceTab("/dev/mmcd");
300} 300}
301 301
302/*! 302/*!
303 * @fn static bool StorageInfo::hasMmc() 303 * @fn static bool StorageInfo::hasMmc()
304 * @brief returns whether device has mmc mounted 304 * @brief returns whether device has mmc mounted
305 * 305 *
306 */ 306 */
307bool StorageInfo::hasMmc() 307bool StorageInfo::hasMmc()
308{ 308{
309 bool hasMmc=false; 309 bool hasMmc=false;
310 if( deviceTab("/dev/mmc/part")) 310 if( deviceTab("/dev/mmc/part"))
311 hasMmc=true; 311 hasMmc=true;
312 if( deviceTab("/dev/mmcd")) 312 if( deviceTab("/dev/mmcd"))
313 hasMmc=true; 313 hasMmc=true;
314 return hasMmc; 314 return hasMmc;
315} 315}
316 316
317/*!
318* @fn QString StorageInfo::getCfPath()
319* @brief returns the Mount-Path of Cf Card
320*
321*/
322QString StorageInfo::getCfPath()
323{
324 QString r = "";
325
326 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
327 {
328 if ( (*i)->disk().left( 8 ) == "/dev/hda" )
329 {
330 r = (*i)->path();
331 break;
332 }
333 }
334 return r;
335}
336
337/*!
338* @fn QString StorageInfo::getSdPath()
339* @brief returns the Mount-Path of Sd Card
340*
341*/
342QString StorageInfo::getSdPath()
343{
344 QString r = "";
345
346 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
347 {
348 if ( (*i)->disk().left( 9 ) == "/dev/mmcd" )
349 {
350 r = (*i)->path();
351 break;
352 }
353 }
354 return r;
355}
356
357/*!
358* @fn QString StorageInfo::getMmcPath()
359* @brief returns the Mount-Path of Mmc Card
360*
361*/
362QString StorageInfo::getMmcPath()
363{
364 QString r = "";
365
366 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
367 {
368 if ( (*i)->disk().left( 14 ) == "/dev/mmc/part1" )
369 {
370 r = (*i)->path();
371 break;
372 }
373 }
374 return r;
375}
376
377/*! \fn const QList<FileSystem> &StorageInfo::fileSystems() const 317/*! \fn const QList<FileSystem> &StorageInfo::fileSystems() const
378 Returns a list of all available mounted file systems. 318 Returns a list of all available mounted file systems.
379 319
380 \warning This may change in Qtopia 3.x to return only relevant Qtopia file systems (and ignore mount points such as /tmp) 320 \warning This may change in Qtopia 3.x to return only relevant Qtopia file systems (and ignore mount points such as /tmp)
381*/ 321*/
382 322
383/*! \fn void StorageInfo::disksChanged() 323/*! \fn void StorageInfo::disksChanged()
384 Gets emitted when a disk has been mounted or unmounted, such as when 324 Gets emitted when a disk has been mounted or unmounted, such as when
385 a CF c 325 a CF c
386*/ 326*/
387//--------------------------------------------------------------------------- 327//---------------------------------------------------------------------------
388 328
389FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) 329FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o )
390 : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) 330 : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o )
391{ 331{
392 update(); 332 update();
393} 333}
394 334
395void FileSystem::update() 335void FileSystem::update()
396{ 336{
397#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 337#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
398 struct statfs fs; 338 struct statfs fs;
399 if ( !statfs( fspath.latin1(), &fs ) ) 339 if ( !statfs( fspath.latin1(), &fs ) )
400 { 340 {
401 blkSize = fs.f_bsize; 341 blkSize = fs.f_bsize;
402 totalBlks = fs.f_blocks; 342 totalBlks = fs.f_blocks;
403 availBlks = fs.f_bavail; 343 availBlks = fs.f_bavail;
404 } 344 }
405 else 345 else
406 { 346 {
407 blkSize = 0; 347 blkSize = 0;
408 totalBlks = 0; 348 totalBlks = 0;
409 availBlks = 0; 349 availBlks = 0;
410 } 350 }
411#endif 351#endif
412} 352}
413 353
414/*! \class FileSystem storage.h 354/*! \class FileSystem storage.h
415 \brief The FileSystem class describes a single mount point. 355 \brief The FileSystem class describes a single mount point.
416 356
417 This class simply returns information about a mount point, including 357 This class simply returns information about a mount point, including
418 file system name, mount point, human readable name, size information 358 file system name, mount point, human readable name, size information
419 and mount options information. 359 and mount options information.
420 \ingroup qtopiaemb 360 \ingroup qtopiaemb
421 361
422 \sa StorageInfo 362 \sa StorageInfo
423*/ 363*/
424 364
425/*! \fn const QString &FileSystem::disk() const 365/*! \fn const QString &FileSystem::disk() const
426 Returns the file system name, such as /dev/hda3 366 Returns the file system name, such as /dev/hda3
427*/ 367*/
428 368
429/*! \fn const QString &FileSystem::path() const 369/*! \fn const QString &FileSystem::path() const
430 Returns the mount path, such as /home 370 Returns the mount path, such as /home
431*/ 371*/
432 372
433/*! \fn const QString &FileSystem::name() const 373/*! \fn const QString &FileSystem::name() const
434 Returns the translated, human readable name for the mount directory. 374 Returns the translated, human readable name for the mount directory.
435*/ 375*/
436 376
437/*! \fn const QString &FileSystem::options() const 377/*! \fn const QString &FileSystem::options() const
438 Returns the mount options 378 Returns the mount options
439*/ 379*/
440 380
441/*! \fn long FileSystem::blockSize() const 381/*! \fn long FileSystem::blockSize() const
442 Returns the size of each block on the file system. 382 Returns the size of each block on the file system.
443*/ 383*/
444 384
445/*! \fn long FileSystem::totalBlocks() const 385/*! \fn long FileSystem::totalBlocks() const
446 Returns the total number of blocks on the file system 386 Returns the total number of blocks on the file system
447*/ 387*/
448 388
449/*! \fn long FileSystem::availBlocks() const 389/*! \fn long FileSystem::availBlocks() const
450 Returns the number of available blocks on the file system 390 Returns the number of available blocks on the file system
451 */ 391 */
452 392
453/*! \fn bool FileSystem::isRemovable() const 393/*! \fn bool FileSystem::isRemovable() const
454 Returns flag whether the file system can be removed, such as a CF card 394 Returns flag whether the file system can be removed, such as a CF card
455 would be removable, but the internal memory wouldn't 395 would be removable, but the internal memory wouldn't
456*/ 396*/
457 397
458/*! \fn bool FileSystem::isWritable() const 398/*! \fn bool FileSystem::isWritable() const
459 Returns flag whether the file system is mounted as writable or read-only. 399 Returns flag whether the file system is mounted as writable or read-only.
460 Returns FALSE if read-only, TRUE if read and write. 400 Returns FALSE if read-only, TRUE if read and write.
461*/ 401*/
462 402
463/*! \fn QStringList StorageInfo::fileSystemNames() const 403/*! \fn QStringList StorageInfo::fileSystemNames() const
464 Returns a list of filesystem names. 404 Returns a list of filesystem names.
465*/ 405*/
diff --git a/library/storage.h b/library/storage.h
index 35a1109..4c29288 100644
--- a/library/storage.h
+++ b/library/storage.h
@@ -1,86 +1,82 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef __storage_h__ 20#ifndef __storage_h__
21#define __storage_h__ 21#define __storage_h__
22 22
23#include <qobject.h> 23#include <qobject.h>
24#include <qlist.h> 24#include <qlist.h>
25 25
26class FileSystem; 26class FileSystem;
27class QCopChannel; 27class QCopChannel;
28 28
29class StorageInfo : public QObject 29class StorageInfo : public QObject
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32public: 32public:
33 StorageInfo( QObject *parent=0 ); 33 StorageInfo( QObject *parent=0 );
34 34
35 const QList<FileSystem> &fileSystems() const { return mFileSystems; } 35 const QList<FileSystem> &fileSystems() const { return mFileSystems; }
36 const FileSystem *fileSystemOf( const QString &filename ); 36 const FileSystem *fileSystemOf( const QString &filename );
37 static bool hasCf(); 37 static bool hasCf();
38 static bool hasSd(); 38 static bool hasSd();
39 static bool hasMmc(); 39 static bool hasMmc();
40
41 QString getCfPath();
42 QString getSdPath();
43 QString getMmcPath();
44signals: 40signals:
45 void disksChanged(); 41 void disksChanged();
46 42
47public slots: 43public slots:
48 void update(); 44 void update();
49 45
50private slots: 46private slots:
51 void cardMessage( const QCString& msg, const QByteArray& data ); 47 void cardMessage( const QCString& msg, const QByteArray& data );
52private: 48private:
53 QList<FileSystem> mFileSystems; 49 QList<FileSystem> mFileSystems;
54 QCopChannel *channel; 50 QCopChannel *channel;
55}; 51};
56 52
57class FileSystem 53class FileSystem
58{ 54{
59public: 55public:
60 const QString &disk() const { return fsdisk; } 56 const QString &disk() const { return fsdisk; }
61 const QString &path() const { return fspath; } 57 const QString &path() const { return fspath; }
62 const QString &name() const { return humanname; } 58 const QString &name() const { return humanname; }
63 const QString &options() const { return opts; } 59 const QString &options() const { return opts; }
64 long blockSize() const { return blkSize; } 60 long blockSize() const { return blkSize; }
65 long totalBlocks() const { return totalBlks; } 61 long totalBlocks() const { return totalBlks; }
66 long availBlocks() const { return availBlks; } 62 long availBlocks() const { return availBlks; }
67 bool isRemovable() const { return removable; } 63 bool isRemovable() const { return removable; }
68 bool isWritable() const { return opts.contains("rw"); } 64 bool isWritable() const { return opts.contains("rw"); }
69 65
70private: 66private:
71 friend class StorageInfo; 67 friend class StorageInfo;
72 FileSystem( const QString &disk, const QString &path, const QString &humanname, bool rem, const QString &opts ); 68 FileSystem( const QString &disk, const QString &path, const QString &humanname, bool rem, const QString &opts );
73 void update(); 69 void update();
74 70
75 QString fsdisk; 71 QString fsdisk;
76 QString fspath; 72 QString fspath;
77 QString humanname; 73 QString humanname;
78 long blkSize; 74 long blkSize;
79 long totalBlks; 75 long totalBlks;
80 long availBlks; 76 long availBlks;
81 bool removable; 77 bool removable;
82 QString opts; 78 QString opts;
83}; 79};
84 80
85 81
86#endif 82#endif