File indexing completed on 2024-04-14 04:39:00

0001 /*
0002  * qca_safeobj.h - Qt Cryptographic Architecture
0003  * Copyright (C) 2008  Justin Karneges <justin@affinix.com>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Lesser General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2.1 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Lesser General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Lesser General Public
0016  * License along with this library; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0018  * 02110-1301  USA
0019  *
0020  */
0021 
0022 #ifndef QCA_SAFEOBJ_H
0023 #define QCA_SAFEOBJ_H
0024 
0025 // NOTE: this API is private to QCA
0026 
0027 #include <QSocketNotifier>
0028 #include <cstdio>
0029 
0030 namespace QCA {
0031 
0032 class SafeSocketNotifier : public QObject
0033 {
0034     Q_OBJECT
0035 public:
0036     SafeSocketNotifier(qintptr socket, QSocketNotifier::Type type, QObject *parent = nullptr);
0037 
0038     ~SafeSocketNotifier() override;
0039 
0040     bool isEnabled() const
0041     {
0042         return sn->isEnabled();
0043     }
0044     qintptr socket() const
0045     {
0046         return sn->socket();
0047     }
0048     QSocketNotifier::Type type() const
0049     {
0050         return sn->type();
0051     }
0052 
0053 public Q_SLOTS:
0054     void setEnabled(bool enable)
0055     {
0056         sn->setEnabled(enable);
0057     }
0058 
0059 Q_SIGNALS:
0060     void activated();
0061 
0062 private:
0063     QSocketNotifier *sn;
0064 };
0065 
0066 }
0067 
0068 #endif