1 | /* |
2 | Copyright 2009 Pino Toscano <pino@kde.org> |
3 | Copyright 2009-2012 Lukáš Tinkl <ltinkl@redhat.com> |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) version 3, or any |
9 | later version accepted by the membership of KDE e.V. (or its |
10 | successor approved by the membership of KDE e.V.), which shall |
11 | act as a proxy defined in Section 6 of version 3 of the license. |
12 | |
13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Lesser General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Lesser General Public |
19 | License along with this library. If not, see <http://www.gnu.org/licenses/>. |
20 | */ |
21 | |
22 | #ifndef UDISKS2STORAGEACCESS_H |
23 | #define UDISKS2STORAGEACCESS_H |
24 | |
25 | #include <solid/ifaces/storageaccess.h> |
26 | #include "udisksdeviceinterface.h" |
27 | |
28 | #include <QtDBus/QDBusMessage> |
29 | #include <QtDBus/QDBusError> |
30 | |
31 | namespace Solid |
32 | { |
33 | namespace Backends |
34 | { |
35 | namespace UDisks2 |
36 | { |
37 | class StorageAccess : public DeviceInterface, virtual public Solid::Ifaces::StorageAccess |
38 | { |
39 | Q_OBJECT |
40 | Q_INTERFACES(Solid::Ifaces::StorageAccess) |
41 | |
42 | public: |
43 | StorageAccess(Device *device); |
44 | virtual ~StorageAccess(); |
45 | |
46 | virtual bool isAccessible() const; |
47 | virtual QString filePath() const; |
48 | virtual bool isIgnored() const; |
49 | virtual bool setup(); |
50 | virtual bool teardown(); |
51 | |
52 | Q_SIGNALS: |
53 | void accessibilityChanged(bool accessible, const QString &udi); |
54 | void setupDone(Solid::ErrorType error, QVariant errorData, const QString &udi); |
55 | void teardownDone(Solid::ErrorType error, QVariant errorData, const QString &udi); |
56 | void setupRequested(const QString &udi); |
57 | void teardownRequested(const QString &udi); |
58 | |
59 | public Q_SLOTS: |
60 | Q_SCRIPTABLE Q_NOREPLY void passphraseReply(const QString & passphrase); |
61 | |
62 | private Q_SLOTS: |
63 | void slotDBusReply(const QDBusMessage & reply); |
64 | void slotDBusError(const QDBusError & error); |
65 | |
66 | void connectDBusSignals(); |
67 | |
68 | void slotSetupRequested(); |
69 | void slotSetupDone(int error, const QString &errorString); |
70 | void slotTeardownRequested(); |
71 | void slotTeardownDone(int error, const QString &errorString); |
72 | |
73 | void checkAccessibility(); |
74 | |
75 | private: |
76 | /// @return true if this device is luks and unlocked |
77 | bool isLuksDevice() const; |
78 | |
79 | void updateCache(); |
80 | |
81 | bool mount(); |
82 | bool unmount(); |
83 | |
84 | bool requestPassphrase(); |
85 | void callCryptoSetup( const QString & passphrase ); |
86 | bool callCryptoTeardown( bool actOnParent=false ); |
87 | |
88 | QString generateReturnObjectPath(); |
89 | QString clearTextPath() const; |
90 | |
91 | private: |
92 | bool m_isAccessible; |
93 | bool m_setupInProgress; |
94 | bool m_teardownInProgress; |
95 | bool m_passphraseRequested; |
96 | QString m_lastReturnObject; |
97 | |
98 | static const int s_unmountTimeout = 0x7fffffff; |
99 | }; |
100 | } |
101 | } |
102 | } |
103 | |
104 | #endif // UDISKS2STORAGEACCESS_H |
105 | |