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

tdecore

  • tdecore
  • tdehw
tdestoragedevice.h
1 /* This file is part of the TDE libraries
2  Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
3  (C) 2013 Golubev Alexander <fatzer2@gmail.com>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef _TDESTORAGEDEVICE_H
21 #define _TDESTORAGEDEVICE_H
22 
23 #include "tdegenericdevice.h"
24 
25 struct crypt_device;
26 
27 // Keep readDiskDeviceSubtypeFromString() in tdehardwaredevices.cpp in sync with this enum
28 namespace TDEDiskDeviceType {
29 #if __cplusplus >= 201103L
30 enum TDEDiskDeviceType : unsigned long long {
31 #else
32 enum TDEDiskDeviceType {
33 #endif
34  Null = 0x0000000000000000ULL,
35  MediaDevice = 0x0000000000000001ULL,
36  Floppy = 0x0000000000000002ULL,
37  CDROM = 0x0000000000000004ULL,
38  CDR = 0x0000000000000008ULL,
39  CDRW = 0x0000000000000010ULL,
40  CDMO = 0x0000000000000020ULL,
41  CDMRRW = 0x0000000000000040ULL,
42  CDMRRWW = 0x0000000000000080ULL,
43  DVDROM = 0x0000000000000100ULL,
44  DVDRAM = 0x0000000000000200ULL,
45  DVDR = 0x0000000000000400ULL,
46  DVDRW = 0x0000000000000800ULL,
47  DVDRDL = 0x0000000000001000ULL,
48  DVDRWDL = 0x0000000000002000ULL,
49  DVDPLUSR = 0x0000000000004000ULL,
50  DVDPLUSRW = 0x0000000000008000ULL,
51  DVDPLUSRDL = 0x0000000000010000ULL,
52  DVDPLUSRWDL = 0x0000000000020000ULL,
53  BDROM = 0x0000000000040000ULL,
54  BDR = 0x0000000000080000ULL,
55  BDRW = 0x0000000000100000ULL,
56  HDDVDROM = 0x0000000000200000ULL,
57  HDDVDR = 0x0000000000400000ULL,
58  HDDVDRW = 0x0000000000800000ULL,
59  Zip = 0x0000000001000000ULL,
60  Jaz = 0x0000000002000000ULL,
61  Camera = 0x0000000004000000ULL,
62  LUKS = 0x0000000008000000ULL,
63  OtherCrypted = 0x0000000010000000ULL,
64  CDAudio = 0x0000000020000000ULL,
65  CDVideo = 0x0000000040000000ULL,
66  DVDVideo = 0x0000000080000000ULL,
67  BDVideo = 0x0000000100000000ULL,
68  Flash = 0x0000000200000000ULL,
69  USB = 0x0000000400000000ULL,
70  Tape = 0x0000000800000000ULL,
71  HDD = 0x0000001000000000ULL,
72  Optical = 0x0000002000000000ULL,
73  RAM = 0x0000004000000000ULL,
74  Loop = 0x0000008000000000ULL,
75  CompactFlash = 0x0000010000000000ULL,
76  MemoryStick = 0x0000020000000000ULL,
77  SmartMedia = 0x0000040000000000ULL,
78  SDMMC = 0x0000080000000000ULL,
79  UnlockedCrypt = 0x0000100000000000ULL,
80  Other = 0x8000000000000000ULL
81 };
82 
83 inline TDEDiskDeviceType operator|(TDEDiskDeviceType a, TDEDiskDeviceType b)
84 {
85  return static_cast<TDEDiskDeviceType>(static_cast<unsigned long long>(a) | static_cast<unsigned long long>(b));
86 }
87 
88 inline TDEDiskDeviceType operator&(TDEDiskDeviceType a, TDEDiskDeviceType b)
89 {
90  return static_cast<TDEDiskDeviceType>(static_cast<unsigned long long>(a) & static_cast<unsigned long long>(b));
91 }
92 
93 inline TDEDiskDeviceType operator~(TDEDiskDeviceType a)
94 {
95  return static_cast<TDEDiskDeviceType>(~static_cast<unsigned long long>(a));
96 }
97 };
98 
99 namespace TDEDiskDeviceStatus {
100 enum TDEDiskDeviceStatus {
101  Null = 0x00000000,
102  Mountable = 0x00000001,
103  Removable = 0x00000002,
104  Inserted = 0x00000004,
105  Blank = 0x00000008,
106  UsedByDevice = 0x00000010,
107  UsesDevice = 0x00000020,
108  ContainsFilesystem = 0x00000040,
109  Hotpluggable = 0x00000080,
110  Hidden = 0x00000100,
111  Other = 0x80000000
112 };
113 
114 inline TDEDiskDeviceStatus operator|(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
115 {
116  return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) | static_cast<int>(b));
117 }
118 
119 inline TDEDiskDeviceStatus operator&(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
120 {
121  return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) & static_cast<int>(b));
122 }
123 
124 inline TDEDiskDeviceStatus operator~(TDEDiskDeviceStatus a)
125 {
126  return static_cast<TDEDiskDeviceStatus>(~static_cast<int>(a));
127 }
128 };
129 
130 namespace TDELUKSKeySlotStatus {
131 enum TDELUKSKeySlotStatus {
132  Invalid = 0x00000000,
133  Inactive = 0x00000001,
134  Active = 0x00000002,
135  Last = 0x00000004,
136  Other = 0x80000000
137 };
138 
139 inline TDELUKSKeySlotStatus operator|(TDELUKSKeySlotStatus a, TDELUKSKeySlotStatus b)
140 {
141  return static_cast<TDELUKSKeySlotStatus>(static_cast<int>(a) | static_cast<int>(b));
142 }
143 
144 inline TDELUKSKeySlotStatus operator&(TDELUKSKeySlotStatus a, TDELUKSKeySlotStatus b)
145 {
146  return static_cast<TDELUKSKeySlotStatus>(static_cast<int>(a) & static_cast<int>(b));
147 }
148 
149 inline TDELUKSKeySlotStatus operator~(TDELUKSKeySlotStatus a)
150 {
151  return static_cast<TDELUKSKeySlotStatus>(~static_cast<int>(a));
152 }
153 };
154 
155 typedef TQValueList<TDELUKSKeySlotStatus::TDELUKSKeySlotStatus> TDELUKSKeySlotStatusList;
156 
157 namespace TDELUKSResult {
158 enum TDELUKSResult {
159  Invalid = 0x00000000,
160  Success = 0x00000001,
161  LUKSNotSupported = 0x00000002,
162  LUKSNotFound = 0x00000003,
163  InvalidKeyslot = 0x00000004,
164  KeyslotOpFailed = 0x00000005,
165  Other = 0x80000000
166 };
167 };
168 
169 typedef TQMap<TQString,TQString> TDEStorageMountOptions;
170 
171 class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
172 {
173  public:
178  TDEStorageDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
179 
183  ~TDEStorageDevice();
184 
188  TQString diskLabel();
189 
193  TQString diskUUID();
194 
198  TDEDiskDeviceType::TDEDiskDeviceType diskType();
199 
203  TDEDiskDeviceStatus::TDEDiskDeviceStatus diskStatus();
204 
208  bool mediaInserted();
209 
213  TQString fileSystemName();
214 
218  TQString fileSystemUsage();
219 
223  TQStringList holdingDevices();
224 
228  TQStringList slaveDevices();
229 
240  TQString mountDevice(TQString mediaName=TQString::null, TDEStorageMountOptions mountOptions=TDEStorageMountOptions(), TQString* errRet=0, int* retcode=0);
241 
253  TQString mountEncryptedDevice(TQString passphrase, TQString mediaName=TQString::null, TDEStorageMountOptions mountOptions=TDEStorageMountOptions(), TQString* errRet=0, int* retcode=0);
254 
263  bool unmountDevice(TQString* errRet, int* retcode=0);
264 
268  TQString mountPath();
269 
273  unsigned long long deviceSize();
274 
278  TQString deviceFriendlySize();
279 
287  TQPixmap icon(TDEIcon::StdSizes size);
288 
294  TQString friendlyName();
295 
301  TQString detailedFriendlyName();
302 
308  TQString friendlyDeviceType();
309 
313  bool isDiskOfType(TDEDiskDeviceType::TDEDiskDeviceType tf);
314 
318  bool checkDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus sf);
319 
326  bool lockDriveMedia(bool lock);
327 
333  bool ejectDriveMedia();
334 
340  bool ejectDrive();
341 
347  static TQString determineFileSystemType(TQString path);
348 
355  void cryptSetOperationsUnlockPassword(TQByteArray password);
356 
361  void cryptClearOperationsUnlockPassword();
362 
368  bool cryptOperationsUnlockPasswordSet();
369 
380  TDELUKSResult::TDELUKSResult cryptCheckKey(unsigned int keyslot);
381 
393  TDELUKSResult::TDELUKSResult cryptAddKey(unsigned int keyslot, TQByteArray password);
394 
403  TDELUKSResult::TDELUKSResult cryptDelKey(unsigned int keyslot);
404 
408  unsigned int cryptKeySlotCount();
409 
413  TDELUKSKeySlotStatusList cryptKeySlotStatus();
414 
419  TQString cryptKeySlotFriendlyName(TDELUKSKeySlotStatus::TDELUKSKeySlotStatus status);
420 
421  protected:
428  void internalSetDeviceNode(TQString sn);
429 
434  void internalSetDiskLabel(TQString dn);
435 
440  void internalSetDiskUUID(TQString id);
441 
446  void internalSetDiskType(TDEDiskDeviceType::TDEDiskDeviceType tf);
447 
452  void internalSetDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus st);
453 
458  void internalSetMediaInserted(bool inserted);
459 
464  void internalSetFileSystemName(TQString fn);
465 
470  void internalSetFileSystemUsage(TQString fu);
471 
476  void internalSetHoldingDevices(TQStringList hd);
477 
482  void internalSetSlaveDevices(TQStringList sd);
483 
487  void internalInitializeLUKSIfNeeded();
488 
492  void internalGetLUKSKeySlotStatus();
493 
494  private:
495  TDEDiskDeviceType::TDEDiskDeviceType m_diskType;
496  TDEDiskDeviceStatus::TDEDiskDeviceStatus m_diskStatus;
497  TQString m_diskName;
498  TQString m_diskUUID;
499  TQString m_fileSystemName;
500  TQString m_fileSystemUsage;
501  bool m_mediaInserted;
502  TQString m_mountPath;
503  TQStringList m_holdingDevices;
504  TQStringList m_slaveDevices;
505  struct crypt_device* m_cryptDevice;
506  TQByteArray m_cryptDevicePassword;
507  TQString m_cryptDeviceType;
508  unsigned int m_cryptKeySlotCount;
509  TDELUKSKeySlotStatusList m_cryptKeyslotStatus;
510 
511  friend class TDEHardwareDevices;
512 };
513 
514 #endif // _TDESTORAGEDEVICE_H
TDELUKSKeySlotStatus
Definition: tdestoragedevice.h:130
TDEIcon::StdSizes
StdSizes
These are the standard sizes for icons.
Definition: kicontheme.h:112
TDELUKSResult
Definition: tdestoragedevice.h:157
TDEDiskDeviceType
Definition: tdestoragedevice.h:28
TDEDiskDeviceStatus
Definition: tdestoragedevice.h:99

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.8.8
This website is maintained by Timothy Pearson.