• 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 #include "tqvariant.h"
25 #include "kdemacros.h"
26 
27 struct crypt_device;
28 
29 // Keep readDiskDeviceSubtypeFromString() in tdehardwaredevices.cpp in sync with this enum
30 namespace TDEDiskDeviceType {
31 #if __cplusplus >= 201103L
32 enum TDEDiskDeviceType : unsigned long long {
33 #else
34 enum TDEDiskDeviceType {
35 #endif
36  Null = 0x0000000000000000ULL,
37  MediaDevice = 0x0000000000000001ULL,
38  Floppy = 0x0000000000000002ULL,
39  CDROM = 0x0000000000000004ULL,
40  CDR = 0x0000000000000008ULL,
41  CDRW = 0x0000000000000010ULL,
42  CDMO = 0x0000000000000020ULL,
43  CDMRRW = 0x0000000000000040ULL,
44  CDMRRWW = 0x0000000000000080ULL,
45  DVDROM = 0x0000000000000100ULL,
46  DVDRAM = 0x0000000000000200ULL,
47  DVDR = 0x0000000000000400ULL,
48  DVDRW = 0x0000000000000800ULL,
49  DVDRDL = 0x0000000000001000ULL,
50  DVDRWDL = 0x0000000000002000ULL,
51  DVDPLUSR = 0x0000000000004000ULL,
52  DVDPLUSRW = 0x0000000000008000ULL,
53  DVDPLUSRDL = 0x0000000000010000ULL,
54  DVDPLUSRWDL = 0x0000000000020000ULL,
55  BDROM = 0x0000000000040000ULL,
56  BDR = 0x0000000000080000ULL,
57  BDRW = 0x0000000000100000ULL,
58  HDDVDROM = 0x0000000000200000ULL,
59  HDDVDR = 0x0000000000400000ULL,
60  HDDVDRW = 0x0000000000800000ULL,
61  Zip = 0x0000000001000000ULL,
62  Jaz = 0x0000000002000000ULL,
63  Camera = 0x0000000004000000ULL,
64  LUKS = 0x0000000008000000ULL,
65  OtherCrypted = 0x0000000010000000ULL,
66  CDAudio = 0x0000000020000000ULL,
67  CDVideo = 0x0000000040000000ULL,
68  DVDVideo = 0x0000000080000000ULL,
69  BDVideo = 0x0000000100000000ULL,
70  Flash = 0x0000000200000000ULL,
71  USB = 0x0000000400000000ULL,
72  Tape = 0x0000000800000000ULL,
73  HDD = 0x0000001000000000ULL,
74  Optical = 0x0000002000000000ULL,
75  RAM = 0x0000004000000000ULL,
76  Loop = 0x0000008000000000ULL,
77  CompactFlash = 0x0000010000000000ULL,
78  MemoryStick = 0x0000020000000000ULL,
79  SmartMedia = 0x0000040000000000ULL,
80  SDMMC = 0x0000080000000000ULL,
81  UnlockedCrypt = 0x0000100000000000ULL,
82  Other = 0x8000000000000000ULL
83 };
84 
85 inline TDEDiskDeviceType operator|(TDEDiskDeviceType a, TDEDiskDeviceType b)
86 {
87  return static_cast<TDEDiskDeviceType>(static_cast<unsigned long long>(a) | static_cast<unsigned long long>(b));
88 }
89 
90 inline TDEDiskDeviceType operator&(TDEDiskDeviceType a, TDEDiskDeviceType b)
91 {
92  return static_cast<TDEDiskDeviceType>(static_cast<unsigned long long>(a) & static_cast<unsigned long long>(b));
93 }
94 
95 inline TDEDiskDeviceType operator~(TDEDiskDeviceType a)
96 {
97  return static_cast<TDEDiskDeviceType>(~static_cast<unsigned long long>(a));
98 }
99 };
100 
101 namespace TDEDiskDeviceStatus {
102 enum TDEDiskDeviceStatus {
103  Null = 0x00000000,
104  Mountable = 0x00000001,
105  Removable = 0x00000002,
106  Inserted = 0x00000004,
107  Blank = 0x00000008,
108  UsedByDevice = 0x00000010,
109  UsesDevice = 0x00000020,
110  ContainsFilesystem = 0x00000040,
111  Hotpluggable KDE_DEPRECATED = 0x00000080 , //< @deprecated; use Removable instead
112  Hidden = 0x00000100,
113  Other = 0x80000000
114 };
115 
116 inline TDEDiskDeviceStatus operator|(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
117 {
118  return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) | static_cast<int>(b));
119 }
120 
121 inline TDEDiskDeviceStatus operator&(TDEDiskDeviceStatus a, TDEDiskDeviceStatus b)
122 {
123  return static_cast<TDEDiskDeviceStatus>(static_cast<int>(a) & static_cast<int>(b));
124 }
125 
126 inline TDEDiskDeviceStatus operator~(TDEDiskDeviceStatus a)
127 {
128  return static_cast<TDEDiskDeviceStatus>(~static_cast<int>(a));
129 }
130 };
131 
132 namespace TDELUKSKeySlotStatus {
133 enum TDELUKSKeySlotStatus {
134  Invalid = 0x00000000,
135  Inactive = 0x00000001,
136  Active = 0x00000002,
137  Last = 0x00000004,
138  Other = 0x80000000
139 };
140 
141 inline TDELUKSKeySlotStatus operator|(TDELUKSKeySlotStatus a, TDELUKSKeySlotStatus b)
142 {
143  return static_cast<TDELUKSKeySlotStatus>(static_cast<int>(a) | static_cast<int>(b));
144 }
145 
146 inline TDELUKSKeySlotStatus operator&(TDELUKSKeySlotStatus a, TDELUKSKeySlotStatus b)
147 {
148  return static_cast<TDELUKSKeySlotStatus>(static_cast<int>(a) & static_cast<int>(b));
149 }
150 
151 inline TDELUKSKeySlotStatus operator~(TDELUKSKeySlotStatus a)
152 {
153  return static_cast<TDELUKSKeySlotStatus>(~static_cast<int>(a));
154 }
155 };
156 
157 typedef TQValueList<TDELUKSKeySlotStatus::TDELUKSKeySlotStatus> TDELUKSKeySlotStatusList;
158 
159 namespace TDELUKSResult {
160 enum TDELUKSResult {
161  Invalid = 0x00000000,
162  Success = 0x00000001,
163  LUKSNotSupported = 0x00000002,
164  LUKSNotFound = 0x00000003,
165  InvalidKeyslot = 0x00000004,
166  KeyslotOpFailed = 0x00000005,
167  Other = 0x80000000
168 };
169 };
170 
171 typedef TQMap<TQString, TQString> TDEStorageMountOptions;
172 
173 class TDECORE_EXPORT TDEStorageDevice : public TDEGenericDevice
174 {
175  public:
180  TDEStorageDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null);
181 
185  ~TDEStorageDevice();
186 
190  TQString diskLabel();
191 
195  TQString diskUUID();
196 
200  TQString mappedName();
201 
205  TDEDiskDeviceType::TDEDiskDeviceType diskType();
206 
210  TDEDiskDeviceStatus::TDEDiskDeviceStatus diskStatus();
211 
215  bool mediaInserted();
216 
220  TQString fileSystemName();
221 
225  TQString fileSystemUsage();
226 
230  TQStringList holdingDevices();
231 
235  TQStringList slaveDevices();
236 
245  TQStringVariantMap mountDevice(TQString mediaName = TQString::null,
246  TDEStorageMountOptions mountOptions = TDEStorageMountOptions());
247 
253  TQStringVariantMap unmountDevice();
254 
262  TQStringVariantMap unlockDevice(const TQString &passphrase);
263 
269  TQStringVariantMap lockDevice();
270 
274  TQString mountPath();
275 
279  unsigned long long deviceSize();
280 
284  TQString deviceFriendlySize();
285 
293  TQPixmap icon(TDEIcon::StdSizes size);
294 
300  TQString friendlyName();
301 
307  TQString detailedFriendlyName();
308 
314  TQString friendlyDeviceType();
315 
319  bool isDiskOfType(TDEDiskDeviceType::TDEDiskDeviceType tf);
320 
324  bool checkDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus sf);
325 
332  bool lockDriveMedia(bool lock);
333 
339  bool ejectDriveMedia();
340 
346  TQStringVariantMap ejectDrive();
347 
354  void cryptSetOperationsUnlockPassword(TQByteArray password);
355 
360  void cryptClearOperationsUnlockPassword();
361 
367  bool cryptOperationsUnlockPasswordSet();
368 
379  TDELUKSResult::TDELUKSResult cryptCheckKey(unsigned int keyslot);
380 
392  TDELUKSResult::TDELUKSResult cryptAddKey(unsigned int keyslot, TQByteArray password);
393 
402  TDELUKSResult::TDELUKSResult cryptDelKey(unsigned int keyslot);
403 
407  unsigned int cryptKeySlotCount();
408 
412  TDELUKSKeySlotStatusList cryptKeySlotStatus();
413 
418  TQString cryptKeySlotFriendlyName(TDELUKSKeySlotStatus::TDELUKSKeySlotStatus status);
419 
420  protected:
427  void internalSetDeviceNode(TQString dn);
428 
433  void internalSetDiskLabel(TQString dn);
434 
439  void internalSetDiskUUID(TQString id);
440 
445  void internalSetDiskType(TDEDiskDeviceType::TDEDiskDeviceType tf);
446 
451  void internalSetDiskStatus(TDEDiskDeviceStatus::TDEDiskDeviceStatus st);
452 
457  void internalSetMediaInserted(bool inserted);
458 
463  void internalSetFileSystemName(TQString fn);
464 
469  void internalSetFileSystemUsage(TQString fu);
470 
475  void internalSetHoldingDevices(TQStringList hd);
476 
481  void internalSetSlaveDevices(TQStringList sd);
482 
486  void internalInitializeLUKSIfNeeded();
487 
491  void internalGetLUKSKeySlotStatus();
492 
496  void internalUpdateMappedName();
497 
501  void internalUpdateMountPath();
502 
503  private:
504  TQString m_mappedName; // Alternative name for a mapped device
505  TDEDiskDeviceType::TDEDiskDeviceType m_diskType;
506  TDEDiskDeviceStatus::TDEDiskDeviceStatus m_diskStatus;
507  TQString m_diskName;
508  TQString m_diskUUID;
509  TQString m_fileSystemName;
510  TQString m_fileSystemUsage;
511  bool m_mediaInserted;
512  TQString m_mountPath;
513  TQStringList m_holdingDevices;
514  TQStringList m_slaveDevices;
515  struct crypt_device* m_cryptDevice;
516  TQByteArray m_cryptDevicePassword;
517  TQString m_cryptDeviceType;
518  unsigned int m_cryptKeySlotCount;
519  TDELUKSKeySlotStatusList m_cryptKeyslotStatus;
520 
521  friend class TDEHardwareDevices;
522 };
523 
524 #endif // _TDESTORAGEDEVICE_H
TDEIcon::StdSizes
StdSizes
These are the standard sizes for icons.
Definition: kicontheme.h:112

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