Debian Codegraph @

online-accounts-plugins/lib/LomiriOnlineAccountsPlugin/loopback-server.h

raw symbols SCIP
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_LOOPBACK_SERVER_H
22 #define OAP_LOOPBACK_SERVER_H
23
24 #include "global.h"
25
26 #include <QByteArray>
27 #include <QObject>
28 #include <QScopedPointer>
29 #include <QUrl>
30
31 namespace OnlineAccountsPlugin {
32
33 class LoopbackServerPrivate;
34 class OAP_EXPORT LoopbackServer: public QObject
35 {
36 Q_OBJECT
37 Q_PROPERTY(QUrl callbackUrl READ callbackUrl NOTIFY callbackUrlChanged)
38 Q_PROPERTY(QByteArray servedHtml READ servedHtml WRITE setServedHtml
39 NOTIFY servedHtmlChanged)
40 Q_PROPERTY(int portIncrementAttempts READ portIncrementAttempts
41 WRITE setPortIncrementAttempts
42 NOTIFY portIncrementAttemptsChanged)
43
44 public:
45 LoopbackServer(QObject *parent = 0);
46 ~LoopbackServer();
47
48 Q_REQUIRED_RESULT bool listen(uint16_t port = 0);
49 void close();
50
51 bool isListening() const { return !callbackUrl().isEmpty(); }
52 uint16_t port() const;
53
54 void setPortIncrementAttempts(int maxAttempts);
55 int portIncrementAttempts() const;
56
57 void setServedHtml(const QByteArray &html);
58 QByteArray servedHtml() const;
59
60 QUrl callbackUrl() const;
61
62 Q_SIGNALS:
63 void portIncrementAttemptsChanged();
64 void servedHtmlChanged();
65 void callbackUrlChanged();
66 void visited(const QUrl &url);
67
68 private:
69 Q_DECLARE_PRIVATE(LoopbackServer)
70 QScopedPointer<LoopbackServerPrivate> d_ptr;
71 };
72
73 } // namespace
74
75 #endif // OAP_LOOPBACK_SERVER_H