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

89 lines
2.4 KiB
C
Raw Normal View History

2019-01-19 23:03:50 +01:00
/*
Fannyapp - Application to view the cover plan of the Fanny-Leicht-Gymnasium ins Stuttgart Vaihingen, Germany
Copyright (C) 2019 Itsblue Development <development@itsblue.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2018-06-21 08:47:09 +02:00
#ifndef SERVERCONN_H
#define SERVERCONN_H
#include <QObject>
2018-06-21 16:41:02 +02:00
#include <QDir>
2018-06-21 18:36:46 +02:00
#include <QUrl>
#include <QTimer>
2018-06-21 08:47:09 +02:00
#include <QtNetwork>
#include <QAuthenticator>
2018-06-21 16:41:02 +02:00
#include <QDesktopServices>
#include "headers/appsettings.h"
#include "headers/filehelper.h"
2018-06-21 08:47:09 +02:00
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras>
#endif
2018-06-21 08:47:09 +02:00
class ServerConn : public QObject
{
Q_OBJECT
Q_PROPERTY(QString state READ getState NOTIFY stateChanged)
Q_PROPERTY(double downloadProgress READ getDownloadProgress NOTIFY downloadProgressChanged)
2018-06-21 16:41:02 +02:00
private:
QString state;
// can be: loggedIn ; notLoggedIn
2018-06-21 16:41:02 +02:00
QString username;
QString password;
QVariantMap senddata(QUrl serviceUrl, QUrlQuery postData, bool raw = false);
QList<int> apiVersion = {0,2,1};
FileHelper * fileHelper;
QString mDocumentsWorkPath;
double downloadProgress;
private slots:
void setState(QString state);
void updateDownloadProgress(qint64 read, qint64 total);
2018-06-21 16:41:02 +02:00
public:
2018-06-21 08:47:09 +02:00
explicit ServerConn(QObject *parent = nullptr);
2018-06-21 16:41:02 +02:00
~ServerConn();
public slots:
Q_INVOKABLE int login(QString username, QString password, bool permanent);
2018-06-21 16:41:02 +02:00
Q_INVOKABLE int logout();
2018-06-25 00:15:18 +02:00
Q_INVOKABLE int getFoodPlan();
Q_INVOKABLE int openEventPdf(QString day);
Q_INVOKABLE int getEvents(QString day);
2018-06-21 08:47:09 +02:00
Q_INVOKABLE double getDownloadProgress();
Q_INVOKABLE QString getState();
2018-06-22 09:36:20 +02:00
signals:
void stateChanged(QString newState);
void downloadProgressChanged();
2018-06-24 09:23:10 +02:00
public:
2019-02-16 21:24:50 +01:00
QList<QStringList> m_weekplan;
QList<QStringList> m_events;
2018-06-24 09:23:10 +02:00
2018-06-21 08:47:09 +02:00
};
extern ServerConn * pGlobalServConn;
2018-06-21 08:47:09 +02:00
#endif // SERVERCONN_H