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

0001 /***************************************************************************
0002  *     Copyright (C) 2018 by Renaud Guezennec                              *
0003  *     https://rolisteam.org/                                           *
0004  *                                                                         *
0005  *   rolisteam is free software; you can redistribute it and/or modify     *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program 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         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 #ifndef UPLOADTOSERVER_H
0021 #define UPLOADTOSERVER_H
0022 
0023 #include <QObject>
0024 #include <vector>
0025 
0026 #include <common/common_types.h>
0027 #include "common/common_global.h"
0028 
0029 class QNetworkAccessManager;
0030 /**
0031  * @brief The LogUploader class dedicated to be call from a thread to send its log messages.
0032  */
0033 class COMMON_EXPORT LogUploader : public QObject
0034 {
0035     Q_OBJECT
0036 public:
0037     LogUploader();
0038 
0039     int appId() const;
0040     void setAppId(int appId);
0041 
0042     QString version() const;
0043     void setVersion(const QString& version);
0044 
0045     QString uuid() const;
0046     void setUuid(const QString& uuid);
0047 
0048     std::vector<common::Log> logs() const;
0049     void setLogs(const std::vector<common::Log>& logs);
0050 
0051     QString conf() const;
0052     void setConf(const QString& conf);
0053 
0054 public slots:
0055     void uploadLog();
0056 signals:
0057     void finished();
0058 
0059 private:
0060     std::vector<common::Log> m_logs;
0061     int m_appId{0};
0062     QString m_version;
0063     QString m_uuid;
0064     QString m_conf;
0065     QNetworkAccessManager* m_accessManager{nullptr};
0066     QByteArray m_postData;
0067 };
0068 
0069 #endif // UPLOADTOSERVER_H