summaryrefslogtreecommitdiff
authorar <ar>2004-01-10 13:54:11 (UTC)
committer ar <ar>2004-01-10 13:54:11 (UTC)
commitbf9988d771a03bc6a1d97a11ce3794d8b429b534 (patch) (unidiff)
tree2537aae850a32b9d3ff6d82d8fb0906c3cead7fd
parent53f1f3a01c088346231fcf2ca8bf6bf62351f37f (diff)
downloadopie-bf9988d771a03bc6a1d97a11ce3794d8b429b534.zip
opie-bf9988d771a03bc6a1d97a11ce3794d8b429b534.tar.gz
opie-bf9988d771a03bc6a1d97a11ce3794d8b429b534.tar.bz2
- remove
QString getCfPath(); QString getSdPath(); QString getMmcPath();
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
@@ -221,245 +221,185 @@ void StorageInfo::update()
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