• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

tdestoragedevice.h
00001 /* This file is part of the TDE libraries
00002    Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
00003              (C) 2013 Golubev Alexander <fatzer2@gmail.com>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef _TDESTORAGEDEVICE_H
00021 #define _TDESTORAGEDEVICE_H
00022 
00023 #include "tdegenericdevice.h"
00024 
00025 struct crypt_device;
00026 
00027 // Keep readDiskDeviceSubtypeFromString() in tdehardwaredevices.cpp in sync with this enum
00028 namespace TDEDiskDeviceType {
00029 #if __cplusplus >= 201103L
00030 enum TDEDiskDeviceType : unsigned long long {
00031 #else
00032 enum TDEDiskDeviceType {
00033 #endif
00034     Null =      0x0000000000000000ULL,
00035     MediaDevice =   0x0000000000000001ULL,
00036     Floppy =    0x0000000000000002ULL,
00037     CDROM =     0x0000000000000004ULL,
00038     CDR =       0x0000000000000008ULL,
00039     CDRW =      0x0000000000000010ULL,
00040     CDMO =      0x0000000000000020ULL,
00041     CDMRRW =    0x0000000000000040ULL,
00042     CDMRRWW =   0x0000000000000080ULL,
00043     DVDROM =    0x0000000000000100ULL,
00044     DVDRAM =    0x0000000000000200ULL,
00045     DVDR =      0x0000000000000400ULL,
00046     DVDRW =     0x0000000000000800ULL,
00047     DVDRDL =    0x0000000000001000ULL,
00048     DVDRWDL =   0x0000000000002000ULL,
00049     DVDPLUSR =  0x0000000000004000ULL,
00050     DVDPLUSRW = 0x0000000000008000ULL,
00051     DVDPLUSRDL =    0x0000000000010000ULL,
00052     DVDPLUSRWDL =   0x0000000000020000ULL,
00053     BDROM =     0x0000000000040000ULL,
00054     BDR =       0x0000000000080000ULL,
00055     BDRW =      0x0000000000100000ULL,
00056     HDDVDROM =  0x0000000000200000ULL,
00057     HDDVDR =    0x0000000000400000ULL,
00058     HDDVDRW =   0x0000000000800000ULL,
00059     Zip =       0x0000000001000000ULL,
00060     Jaz =       0x0000000002000000ULL,
00061     Camera =    0x0000000004000000ULL,
00062     LUKS =      0x0000000008000000ULL,
00063     OtherCrypted =  0x0000000010000000ULL,
00064     CDAudio =   0x0000000020000000ULL,
00065     CDVideo =   0x0000000040000000ULL,
00066     DVDVideo =  0x0000000080000000ULL,
00067     BDVideo =   0x0000000100000000ULL,
00068     Flash =     0x0000000200000000ULL,
00069     USB =       0x0000000400000000ULL,
00070     Tape =      0x0000000800000000ULL,
00071     HDD =       0x0000001000000000ULL,
00072     Optical =   0x0000002000000000ULL,
00073     RAM =       0x0000004000000000ULL,
00074     Loop =      0x0000008000000000ULL,
00075     CompactFlash =  0x0000010000000000ULL,
00076     MemoryStick =   0x0000020000000000ULL,
00077     SmartMedia =    0x0000040000000000ULL,
00078     SDMMC =     0x0000080000000000ULL,
00079     UnlockedCrypt = 0x0000100000000000ULL,
00080     Other =     0x8000000000000000ULL
00081 };
00082 
00083 inline TDEDiskDeviceType operator|(TDEDiskDeviceType a, TDEDiskDeviceType b)
00084 {
00085     return static_cast<TDEDiskDeviceType>(static_cast<unsigned long long>(a) | static_cast<unsigned long long>(b));
00086 }
00087 
00088 inline TDEDiskDeviceType operator&(TDEDiskDeviceType a, TDEDiskDeviceType b)
00089 {
00090     return static_cast<TDEDiskDeviceType>(static_cast<unsigned long long>(a) & static_cast<unsigned long long>(b));
00091 }
00092 
00093 inline TDEDiskDeviceType operator~(TDEDiskDeviceType a)
00094 {
00095     return static_cast<TDEDiskDeviceType>(~static_cast<unsigned long long>(a));
00096 }
00097 };
00098 
00099 namespace TDEDiskDeviceStatus {
00100 enum TDEDiskDeviceStatus {
00101     Null =          0x00000000,
00102     Mountable =     0x00000001,
00103     Removable =     0x00000002,
00104     Inserted =      0x00000004,
00105     Blank =         0x00000008,
00106     UsedByDevice =      0x00000010,
00107     UsesDevice =        0x00000020,
00108     ContainsFilesystem =    0x00000040,
00109     Hotpluggable =      0x00000080,
00110     Hidden =        0x00000100,
00111     Other =         0x80000000
00112 };
00113 
00114 inline TDEDiskDeviceStatus operator|(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
00115 {
00116     return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) | static_cast<int>(b));
00117 }
00118 
00119 inline TDEDiskDeviceStatus operator&(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
00120 {
00121     return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) & static_cast<int>(b));
00122 }
00123 
00124 inline TDEDiskDeviceStatus operator~(TDEDiskDeviceStatus a)
00125 {
00126     return static_cast<TDEDiskDeviceStatus>(~static_cast<int>(a));
00127 }
00128 };
00129 
00130 namespace TDELUKSKeySlotStatus {
00131 enum TDELUKSKeySlotStatus {
00132     Invalid =       0x00000000,
00133     Inactive =      0x00000001,
00134     Active =        0x00000002,
00135     Last =          0x00000004,
00136     Other =         0x80000000
00137 };
00138 
00139 inline TDELUKSKeySlotStatus operator|(TDELUKSKeySlotStatus a, TDELUKSKeySlotStatus b)
00140 {
00141     return static_cast<TDELUKSKeySlotStatus>(static_cast<int>(a) | static_cast<int>(b));
00142 }
00143 
00144 inline TDELUKSKeySlotStatus operator&(TDELUKSKeySlotStatus a, TDELUKSKeySlotStatus b)
00145 {
00146     return static_cast<TDELUKSKeySlotStatus>(static_cast<int>(a) & static_cast<int>(b));
00147 }
00148 
00149 inline TDELUKSKeySlotStatus operator~(TDELUKSKeySlotStatus a)
00150 {
00151     return static_cast<TDELUKSKeySlotStatus>(~static_cast<int>(a));
00152 }
00153 };
00154 
00155 typedef TQValueList<TDELUKSKeySlotStatus::TDELUKSKeySlotStatus> TDELUKSKeySlotStatusList;
00156 
00157 namespace TDELUKSResult {
00158 enum TDELUKSResult {
00159     Invalid =       0x00000000,
00160     Success =       0x00000001,
00161     LUKSNotSupported =  0x00000002,
00162     LUKSNotFound =      0x00000003,
00163     InvalidKeyslot =    0x00000004,
00164     KeyslotOpFailed =   0x00000005,
00165     Other =         0x80000000
00166 };
00167 };
00168 
00169 typedef TQMap<TQString,TQString> TDEStorageMountOptions;
00170 
00171 class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
00172 {
00173     public:
00178         TDEStorageDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
00179 
00183         ~TDEStorageDevice();
00184 
00188         TQString diskLabel();
00189 
00193         TQString diskUUID();
00194 
00198         TDEDiskDeviceType::TDEDiskDeviceType diskType();
00199 
00203         TDEDiskDeviceStatus::TDEDiskDeviceStatus diskStatus();
00204 
00208         bool mediaInserted();
00209 
00213         TQString fileSystemName();
00214 
00218         TQString fileSystemUsage();
00219 
00223         TQStringList holdingDevices();
00224 
00228         TQStringList slaveDevices();
00229 
00240         TQString mountDevice(TQString mediaName=TQString::null, TDEStorageMountOptions mountOptions=TDEStorageMountOptions(), TQString* errRet=0, int* retcode=0);
00241 
00253         TQString mountEncryptedDevice(TQString passphrase, TQString mediaName=TQString::null, TDEStorageMountOptions mountOptions=TDEStorageMountOptions(), TQString* errRet=0, int* retcode=0);
00254 
00263         bool unmountDevice(TQString* errRet, int* retcode=0);
00264 
00268         TQString mountPath();
00269 
00273         unsigned long long deviceSize();
00274 
00278         TQString deviceFriendlySize();
00279 
00287         TQPixmap icon(TDEIcon::StdSizes size);
00288 
00294         TQString friendlyName();
00295 
00301         TQString detailedFriendlyName();
00302 
00308         TQString friendlyDeviceType();
00309 
00313         bool isDiskOfType(TDEDiskDeviceType::TDEDiskDeviceType tf);
00314 
00318         bool checkDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus sf);
00319 
00326         bool lockDriveMedia(bool lock);
00327 
00333         bool ejectDriveMedia();
00334 
00340         bool ejectDrive();
00341 
00347         static TQString determineFileSystemType(TQString path);
00348 
00355         void cryptSetOperationsUnlockPassword(TQByteArray password);
00356 
00361         void cryptClearOperationsUnlockPassword();
00362 
00368         bool cryptOperationsUnlockPasswordSet();
00369 
00380         TDELUKSResult::TDELUKSResult cryptCheckKey(unsigned int keyslot);
00381 
00393         TDELUKSResult::TDELUKSResult cryptAddKey(unsigned int keyslot, TQByteArray password);
00394 
00403         TDELUKSResult::TDELUKSResult cryptDelKey(unsigned int keyslot);
00404 
00408         unsigned int cryptKeySlotCount();
00409 
00413         TDELUKSKeySlotStatusList cryptKeySlotStatus();
00414 
00419         TQString cryptKeySlotFriendlyName(TDELUKSKeySlotStatus::TDELUKSKeySlotStatus status);
00420 
00421     protected:
00428         void internalSetDeviceNode(TQString sn);
00429 
00434         void internalSetDiskLabel(TQString dn);
00435 
00440         void internalSetDiskUUID(TQString id);
00441 
00446         void internalSetDiskType(TDEDiskDeviceType::TDEDiskDeviceType tf);
00447 
00452         void internalSetDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus st);
00453 
00458         void internalSetMediaInserted(bool inserted);
00459 
00464         void internalSetFileSystemName(TQString fn);
00465 
00470         void internalSetFileSystemUsage(TQString fu);
00471 
00476         void internalSetHoldingDevices(TQStringList hd);
00477 
00482         void internalSetSlaveDevices(TQStringList sd);
00483 
00487         void internalInitializeLUKSIfNeeded();
00488 
00492         void internalGetLUKSKeySlotStatus();
00493 
00494     private:
00495         TDEDiskDeviceType::TDEDiskDeviceType m_diskType;
00496         TDEDiskDeviceStatus::TDEDiskDeviceStatus m_diskStatus;
00497         TQString m_diskName;
00498         TQString m_diskUUID;
00499         TQString m_fileSystemName;
00500         TQString m_fileSystemUsage;
00501         bool m_mediaInserted;
00502         TQString m_mountPath;
00503         TQStringList m_holdingDevices;
00504         TQStringList m_slaveDevices;
00505         struct crypt_device* m_cryptDevice;
00506         TQByteArray m_cryptDevicePassword;
00507         TQString m_cryptDeviceType;
00508         unsigned int m_cryptKeySlotCount;
00509         TDELUKSKeySlotStatusList m_cryptKeyslotStatus;
00510 
00511     friend class TDEHardwareDevices;
00512 };
00513 
00514 #endif // _TDESTORAGEDEVICE_H

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.