File indexing completed on 2024-05-12 05:39:53

0001 /*************************************************************************
0002  *   Copyright (C) 2013 by Renaud Guezennec                              *
0003  *                                                                       *
0004  *   https://rolisteam.org/                                           *
0005  *                                                                       *
0006  *   rolisteam is free software; you can redistribute it and/or modify   *
0007  *   it under the terms of the GNU General Public License as published   *
0008  *   by the Free Software Foundation; either version 2 of the License,   *
0009  *   or (at your option) any later version.                              *
0010  *                                                                       *
0011  *   This program is distributed in the hope that it will be useful,     *
0012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of      *
0013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
0014  *   GNU General Public License for more details.                        *
0015  *                                                                       *
0016  *   You should have received a copy of the GNU General Public License   *
0017  *   along with this program; if not, write to the                       *
0018  *   Free Software Foundation, Inc.,                                     *
0019  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           *
0020  *************************************************************************/
0021 #ifndef IPCHECKER_H
0022 #define IPCHECKER_H
0023 
0024 #include <QNetworkAccessManager>
0025 #include <QObject>
0026 #include <QString>
0027 #include <core_global.h>
0028 #include <memory>
0029 /**
0030  * @brief The IpChecker class is dedicated to reach https://rolisteam.org/ip.php to read the public ip.
0031  */
0032 class CORE_EXPORT  IpChecker : public QObject
0033 {
0034     Q_OBJECT
0035     Q_PROPERTY(QString ipAddress READ ipAddress NOTIFY ipAddressChanged)
0036 public:
0037     /**
0038      * @brief IpChecker
0039      * @param parent
0040      */
0041     explicit IpChecker(QObject* parent= nullptr);
0042     QString ipAddress() const;
0043 
0044 signals:
0045     /**
0046      * @brief finished
0047      */
0048     void ipAddressChanged(QString);
0049     void finishedCheck();
0050 
0051 public slots:
0052     /**
0053      * @brief startCheck
0054      */
0055     void startCheck();
0056 
0057 private slots:
0058     /**
0059      * @brief readText
0060      * @param p
0061      */
0062     void readText(QNetworkReply* p);
0063 
0064 private:
0065     std::unique_ptr<QNetworkAccessManager> m_manager;
0066     QString m_ip;
0067 };
0068 
0069 #endif // IPCHECKER_H