/* Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef SIWEBSERVICECLIENT_H #define SIWEBSERVICECLIENT_H #include #include class QNetworkAccessManager; class QNetworkReply; #include #include namespace SiWeather { namespace Library { class SiWeatherStation; class SI_LIB_EXPORT SiWebserviceClient : public QObject { Q_OBJECT public: enum ReplyType{ Error = 1, StationsRegister = 2 }; SiWebserviceClient(QUrl baseUrl, QObject *parent = NULL); static QString apiVersion(); /** * @brief Registers a station at the server and emits error() or finishedStationsRegister() if finished. */ ReplyType stationsRegister(const SiWeather::Library::SiWeatherStation& station, QString& error); signals: void error(SiWeather::Library::SiWebserviceClient::ReplyType replyType, const QString &errorMessage) const; /** * @brief Generic finish signal for all requests. Use specialized finished signals instead! * * @see finishedStationsRegister */ void finished(SiWeather::Library::SiWebserviceClient::ReplyType replyType, bool result, const QByteArray &data) const; void finishedStationsRegister(bool result, const QUuid &uuid, const QString &message) const; private slots: void replyStationsRegister(); private: QNetworkReply* getNetworkReply(QObject *sender, ReplyType type) const; QUrl _baseUrl; QPointer _networkManager; }; }; }; Q_DECLARE_METATYPE(SiWeather::Library::SiWebserviceClient::ReplyType) #endif //SIWEBSERVICECLIENT_H