00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _MEDIUM_H_
00020 #define _MEDIUM_H_
00021
00022 #include <tqstring.h>
00023 #include <tqstringlist.h>
00024 #include <kurl.h>
00025 #include <tqmap.h>
00026
00027 class Medium
00028 {
00029 public:
00030 typedef TQValueList<const Medium> List;
00031
00032 static const uint ID = 0;
00033 static const uint NAME = 1;
00034 static const uint LABEL = 2;
00035 static const uint USER_LABEL = 3;
00036 static const uint MOUNTABLE = 4;
00037 static const uint DEVICE_NODE = 5;
00038 static const uint MOUNT_POINT = 6;
00039 static const uint FS_TYPE = 7;
00040 static const uint MOUNTED = 8;
00041 static const uint BASE_URL = 9;
00042 static const uint MIME_TYPE = 10;
00043 static const uint ICON_NAME = 11;
00044 static const uint ENCRYPTED = 12;
00045 static const uint CLEAR_DEVICE_UDI = 13;
00046 static const uint PROPERTIES_COUNT = 14;
00047 static const TQString SEPARATOR;
00048
00049 Medium(const TQString &id, const TQString &name);
00050 static const Medium create(const TQStringList &properties);
00051 static List createList(const TQStringList &properties);
00052
00053 const TQStringList &properties() const { return m_properties; }
00054
00055 TQString id() const { return m_properties[ID]; }
00056 TQString name() const { return m_properties[NAME]; }
00057 TQString label() const { return m_properties[LABEL]; }
00058 TQString userLabel() const { return m_properties[USER_LABEL]; }
00059 bool isMountable() const { return m_properties[MOUNTABLE]=="true"; }
00060 TQString deviceNode() const { return m_properties[DEVICE_NODE]; }
00061 TQString mountPoint() const { return m_properties[MOUNT_POINT]; }
00062 TQString fsType() const { return m_properties[FS_TYPE]; }
00063 bool isMounted() const { return m_properties[MOUNTED]=="true"; }
00064 TQString baseURL() const { return m_properties[BASE_URL]; }
00065 TQString mimeType() const { return m_properties[MIME_TYPE]; }
00066 TQString iconName() const { return m_properties[ICON_NAME]; }
00067 bool isEncrypted() const { return m_properties[ENCRYPTED]=="true"; };
00068 TQString clearDeviceUdi() const { return m_properties[CLEAR_DEVICE_UDI]; };
00069
00070 bool needMounting() const;
00071 bool needDecryption() const;
00072 KURL prettyBaseURL() const;
00073 TQString prettyLabel() const;
00074
00075 void setName(const TQString &name);
00076 void setLabel(const TQString &label);
00077 void setUserLabel(const TQString &label);
00078 void setEncrypted(bool state);
00079
00080 bool mountableState(bool mounted);
00081 void mountableState(const TQString &deviceNode,
00082 const TQString &mountPoint,
00083 const TQString &fsType, bool mounted);
00084 void mountableState(const TQString &deviceNode,
00085 const TQString &clearDeviceUdi,
00086 const TQString &mountPoint,
00087 const TQString &fsType, bool mounted);
00088 void unmountableState(const TQString &baseURL = TQString::null);
00089
00090 void setMimeType(const TQString &mimeType);
00091 void setIconName(const TQString &iconName);
00092 void setHalMounted(bool flag) const { m_halmounted = flag; }
00093 bool halMounted() const { return m_halmounted; }
00094
00095 private:
00096 Medium();
00097 void loadUserLabel();
00098
00099 TQStringList m_properties;
00100 mutable bool m_halmounted;
00101
00102 friend class TQValueListNode<const Medium>;
00103 };
00104
00105 namespace MediaManagerUtils {
00106 static inline TQMap<TQString,TQString> splitOptions(const TQStringList & options)
00107 {
00108 TQMap<TQString,TQString> valids;
00109
00110 for (TQStringList::ConstIterator it = options.begin(); it != options.end(); ++it)
00111 {
00112 TQString key = (*it).left((*it).find('='));
00113 TQString value = (*it).mid((*it).find('=') + 1);
00114 valids[key] = value;
00115 }
00116 return valids;
00117 }
00118 }
00119
00120 #endif