| 1 | /* |
| 2 | * This file is part of libAuthentication |
| 3 | * |
| 4 | * Copyright (C) 2017-2020 Alberto Mardegan <[email protected]> |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public License |
| 8 | * version 2.1 as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, but |
| 11 | * 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 St, Fifth Floor, Boston, MA |
| 18 | * 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #ifndef OAP_QML_LOOPBACK_SERVER_H |
| 22 | #define OAP_QML_LOOPBACK_SERVER_H |
| 23 | |
| 24 | #include <LomiriOnlineAccountsPlugin/loopback-server.h> |
| 25 | |
| 26 | #include <QObject> |
| 27 | #include <QQmlParserStatus> |
| 28 | #include <QScopedPointer> |
| 29 | |
| 30 | namespace OnlineAccountsPlugin { |
| 31 | |
| 32 | class QmlLoopbackServerPrivate; |
| 33 | class QmlLoopbackServer: public LoopbackServer, public QQmlParserStatus |
| 34 | { |
| 35 | Q_OBJECT |
| 36 | Q_INTERFACES(QQmlParserStatus) |
| 37 | Q_PROPERTY(int port READ port WRITE setPort NOTIFY portChanged) |
| 38 | Q_PROPERTY(bool listening READ isListening WRITE setListening |
| 39 | NOTIFY callbackUrlChanged) |
| 40 | |
| 41 | public: |
| 42 | QmlLoopbackServer(QObject *parent = 0); |
| 43 | ~QmlLoopbackServer(); |
| 44 | |
| 45 | void setPort(int port); |
| 46 | int port() const; |
| 47 | |
| 48 | void setListening(bool isListening); |
| 49 | |
| 50 | void classBegin() override; |
| 51 | void componentComplete() override; |
| 52 | |
| 53 | Q_SIGNALS: |
| 54 | void portChanged(); |
| 55 | void callbackUrlChanged(); // to make the moc happy |
| 56 | |
| 57 | private: |
| 58 | Q_DECLARE_PRIVATE(QmlLoopbackServer) |
| 59 | QScopedPointer<QmlLoopbackServerPrivate> d_ptr; |
| 60 | }; |
| 61 | |
| 62 | } // namespace |
| 63 | |
| 64 | #endif // OAP_QML_LOOPBACK_SERVER_H |