00001 #ifndef DISKINFO_H_
00002 #define DISKINFO_H_
00003 #define NUMDISKINFOLINES 8
00004
00005 using namespace std;
00006
00007 #include <stdint.h>
00008
00009 #include <QList>
00010 #include <QString>
00011 #include <QStringList>
00012
00013 #include "mythbaseexp.h"
00014 #include "mythsocket.h"
00015 #include "mythcorecontext.h"
00016
00017 class MBASE_PUBLIC FileSystemInfo : public QObject
00018 {
00019 Q_OBJECT
00020 public:
00021 FileSystemInfo();
00022 FileSystemInfo(const FileSystemInfo &other);
00023 FileSystemInfo(QString hostname, QString path, bool local, int fsid,
00024 int groupid, int blksize, int64_t total, int64_t used);
00025 FileSystemInfo(QStringList::const_iterator &it,
00026 QStringList::const_iterator end);
00027 FileSystemInfo(const QStringList &slist);
00028
00029 ~FileSystemInfo(void) {};
00030
00031 FileSystemInfo &operator=(const FileSystemInfo &other);
00032 virtual void clone(const FileSystemInfo &other);
00033 void clear(void);
00034
00035
00036 QString getHostname(void) const { return m_hostname; }
00037 QString getPath(void) const { return m_path; }
00038 bool isLocal(void) const { return m_local; }
00039 int getFSysID(void) const { return m_fsid; }
00040 int getGroupID(void) const { return m_grpid; }
00041 int getBlockSize(void) const { return m_blksize; }
00042 int64_t getTotalSpace(void) const { return m_total; }
00043 int64_t getUsedSpace(void) const { return m_used; }
00044 int getWeight(void) const { return m_weight; }
00045
00046
00047 int64_t getFreeSpace(void) const { return m_total-m_used; }
00048
00049
00050 void setHostname(QString hostname) { m_hostname = hostname; }
00051 void setPath(QString path) { m_path = path; }
00052 void setLocal(bool local = true) { m_local = local; }
00053 void setFSysID(int id) { m_fsid = id; }
00054 void setGroupID(int id) { m_grpid = id; }
00055 void setBlockSize(int size) { m_blksize = size; }
00056 void setTotalSpace(int64_t size) { m_total = size; }
00057 void setUsedSpace(int64_t size) { m_used = size; }
00058 void setWeight(int weight) { m_weight = weight; }
00059
00060 bool ToStringList(QStringList &slist) const;
00061
00062 static const QList<FileSystemInfo> RemoteGetInfo(MythSocket *sock=NULL);
00063 static void Consolidate(QList<FileSystemInfo> &disks, bool merge=true,
00064 int64_t fuzz=14000);
00065 void PopulateDiskSpace(void);
00066 void PopulateFSProp(void);
00067
00068 private:
00069 bool FromStringList(const QStringList &slist);
00070 bool FromStringList(QStringList::const_iterator &it,
00071 QStringList::const_iterator listend);
00072
00073 QString m_hostname;
00074 QString m_path;
00075 bool m_local;
00076 int m_fsid;
00077 int m_grpid;
00078 int m_blksize;
00079 int64_t m_total;
00080 int64_t m_used;
00081 int m_weight;
00082 };
00083 #endif