storage.h
00001 /********************************************************************** 00002 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 00003 ** 00004 ** This file is part of Qtopia Environment. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 ** 00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00015 ** 00016 ** Contact info@trolltech.com if any conditions of this licensing are 00017 ** not clear to you. 00018 ** 00019 **********************************************************************/ 00020 #ifndef __storage_h__ 00021 #define __storage_h__ 00022 00023 #include <qobject.h> 00024 #include <qlist.h> 00025 00026 class FileSystem; 00027 class QCopChannel; 00028 00029 class StorageInfo : public QObject 00030 { 00031 Q_OBJECT 00032 public: 00033 StorageInfo( QObject *parent=0 ); 00034 00035 const QList<FileSystem> &fileSystems() const { return mFileSystems; } 00036 const FileSystem *fileSystemOf( const QString &filename ); 00037 static bool hasCf(); 00038 static bool hasSd(); 00039 static bool hasMmc(); 00040 signals: 00041 void disksChanged(); 00042 00043 public slots: 00044 void update(); 00045 00046 private slots: 00047 void cardMessage( const QCString& msg, const QByteArray& data ); 00048 private: 00049 QList<FileSystem> mFileSystems; 00050 QCopChannel *channel; 00051 }; 00052 00053 class FileSystem 00054 { 00055 public: 00056 const QString &disk() const { return fsdisk; } 00057 const QString &path() const { return fspath; } 00058 const QString &name() const { return humanname; } 00059 const QString &options() const { return opts; } 00060 long blockSize() const { return blkSize; } 00061 long totalBlocks() const { return totalBlks; } 00062 long availBlocks() const { return availBlks; } 00063 bool isRemovable() const { return removable; } 00064 bool isWritable() const { return opts.contains("rw"); } 00065 00066 private: 00067 friend class StorageInfo; 00068 FileSystem( const QString &disk, const QString &path, const QString &humanname, bool rem, const QString &opts ); 00069 void update(); 00070 00071 QString fsdisk; 00072 QString fspath; 00073 QString humanname; 00074 long blkSize; 00075 long totalBlks; 00076 long availBlks; 00077 bool removable; 00078 QString opts; 00079 }; 00080 00081 00082 #endif
