1 | /* |
2 | * qca_safeobj.h - Qt Cryptographic Architecture |
3 | * Copyright (C) 2008 Justin Karneges <justin@affinix.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) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public |
16 | * License along with this library; if not, write to the Free Software |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
18 | * 02110-1301 USA |
19 | * |
20 | */ |
21 | |
22 | #ifndef QCA_SAFEOBJ_H |
23 | #define QCA_SAFEOBJ_H |
24 | |
25 | // NOTE: this API is private to QCA |
26 | |
27 | #include <QSocketNotifier> |
28 | #include <cstdio> |
29 | |
30 | namespace QCA { |
31 | |
32 | class SafeSocketNotifier : public QObject |
33 | { |
34 | Q_OBJECT |
35 | public: |
36 | SafeSocketNotifier(qintptr socket, QSocketNotifier::Type type, QObject *parent = nullptr); |
37 | |
38 | ~SafeSocketNotifier() override; |
39 | |
40 | bool isEnabled() const |
41 | { |
42 | return sn->isEnabled(); |
43 | } |
44 | qintptr socket() const |
45 | { |
46 | return sn->socket(); |
47 | } |
48 | QSocketNotifier::Type type() const |
49 | { |
50 | return sn->type(); |
51 | } |
52 | |
53 | public Q_SLOTS: |
54 | void setEnabled(bool enable) |
55 | { |
56 | sn->setEnabled(enable); |
57 | } |
58 | |
59 | Q_SIGNALS: |
60 | void activated(); |
61 | |
62 | private: |
63 | QSocketNotifier *sn; |
64 | }; |
65 | |
66 | } |
67 | |
68 | #endif |
69 | |