This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
fanny-app/headers/serverconn.h
dorian c6e1e12cfe Finished up foodplan Display:
- now using QAbstractItem model
- added error handling so the app doesn't crash anymore when the data is invalid
2018-12-23 21:07:10 +01:00

65 lines
1.4 KiB
C++

#ifndef SERVERCONN_H
#define SERVERCONN_H
#include <QObject>
#include <QDir>
#include <QUrl>
#include <QtXml>
#include <QtNetwork>
#include <QAuthenticator>
#include <QDesktopServices>
#include <QXmlNamespaceSupport>
#include "headers/appsettings.h"
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras>
#endif
typedef struct strReturnData{
int status_code;
QString text;
}ReturnData_t;
class ServerConn : public QObject
{
Q_OBJECT
public:
QString username;
QString password;
QNetworkAccessManager *networkManager;
QNetworkAccessManager *refreshNetworkManager;
float progress;
public:
explicit ServerConn(QObject *parent = nullptr);
~ServerConn();
Q_INVOKABLE QString login(QString username, QString password, bool permanent);
Q_INVOKABLE int logout();
Q_INVOKABLE QString getDay(QString day);
Q_INVOKABLE int checkConn();
Q_INVOKABLE float getProgress();
Q_INVOKABLE int getFoodPlan();
Q_INVOKABLE QVariantMap getFoodPlanData(int index);
Q_INVOKABLE QVariantMap getEventData(int index);
Q_INVOKABLE int getEvents(QString day);
Q_INVOKABLE int getEventCount();
ReturnData_t senddata(QUrl serviceUrl, QUrlQuery postData);
QList<QList<QString>> m_weekplan;
signals:
public slots:
Q_INVOKABLE void updateProgress(qint64 read, qint64 total);
private:
QList<QStringList> m_eventlist;
};
extern ServerConn * pGlobalServConn;
#endif // SERVERCONN_H