author | ar <ar> | 2004-01-10 13:54:11 (UTC) |
---|---|---|
committer | ar <ar> | 2004-01-10 13:54:11 (UTC) |
commit | bf9988d771a03bc6a1d97a11ce3794d8b429b534 (patch) (unidiff) | |
tree | 2537aae850a32b9d3ff6d82d8fb0906c3cead7fd | |
parent | 53f1f3a01c088346231fcf2ca8bf6bf62351f37f (diff) | |
download | opie-bf9988d771a03bc6a1d97a11ce3794d8b429b534.zip opie-bf9988d771a03bc6a1d97a11ce3794d8b429b534.tar.gz opie-bf9988d771a03bc6a1d97a11ce3794d8b429b534.tar.bz2 |
- remove
QString getCfPath();
QString getSdPath();
QString getMmcPath();
-rw-r--r-- | library/storage.cpp | 60 | ||||
-rw-r--r-- | library/storage.h | 4 |
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 | |||
@@ -269,156 +269,96 @@ bool deviceTab( const char *device) | |||
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 | */ |
287 | bool StorageInfo::hasCf() | 287 | bool 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 | */ |
297 | bool StorageInfo::hasSd() | 297 | bool 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 | */ |
307 | bool StorageInfo::hasMmc() | 307 | bool 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 | */ | ||
322 | QString 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 | */ | ||
342 | QString 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 | */ | ||
362 | QString 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 | ||
389 | FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) | 329 | FileSystem::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 | ||
395 | void FileSystem::update() | 335 | void 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 | ||
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 | ||
26 | class FileSystem; | 26 | class FileSystem; |
27 | class QCopChannel; | 27 | class QCopChannel; |
28 | 28 | ||
29 | class StorageInfo : public QObject | 29 | class StorageInfo : public QObject |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
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(); | ||
44 | signals: | 40 | signals: |
45 | void disksChanged(); | 41 | void disksChanged(); |
46 | 42 | ||
47 | public slots: | 43 | public slots: |
48 | void update(); | 44 | void update(); |
49 | 45 | ||
50 | private slots: | 46 | private slots: |
51 | void cardMessage( const QCString& msg, const QByteArray& data ); | 47 | void cardMessage( const QCString& msg, const QByteArray& data ); |
52 | private: | 48 | private: |
53 | QList<FileSystem> mFileSystems; | 49 | QList<FileSystem> mFileSystems; |
54 | QCopChannel *channel; | 50 | QCopChannel *channel; |
55 | }; | 51 | }; |
56 | 52 | ||
57 | class FileSystem | 53 | class FileSystem |
58 | { | 54 | { |
59 | public: | 55 | public: |
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 | ||
70 | private: | 66 | private: |
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 |