#ifndef NETWORK_H
#define NETWORK_H

#include <QUrl>
#include <QFile>
#include <QNetworkReply>

class MainWindow;

class ANetwork : public QObject {
Q_OBJECT
// Realising Singleton here
private:
    ANetwork();

public:
    static ANetwork* getInstance() {
        static ANetwork network;
        return &network;
    }
    QString query(QUrl url);
    QByteArray query_binary(QUrl url);

public slots:
    void getPatches();
    void getCoupon();
    void getServers();
    void getFootMessage();
    void getMicroPatch(int timestamp);

signals:
    void getPatchFinished(QString patchname, QString date);
    void getCouponFinished(QString coupon);
    void getServersFinished(QString server);
    void getFootMessageFinished(QString msg);
    void getMicroPatchFinished(QString filename);

    void updatePatchDates(QString name, QString date);

private:
    int getVersion(QString string);
    QNetworkReply* currentDownload;
    QFile output;

//private slots:
    //void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
    //void downloadFinished();
};

#endif // NETWORK_H
