2021-07-18 21:09:04 -05:00
|
|
|
#pragma once
|
|
|
|
|
2021-07-25 01:11:40 -05:00
|
|
|
#include <QHash>
|
2021-07-18 21:09:04 -05:00
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QObject>
|
2021-07-25 01:11:40 -05:00
|
|
|
#include <QTimer>
|
2021-07-18 21:09:04 -05:00
|
|
|
|
|
|
|
class OpenLPClient: public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
2021-07-25 01:11:40 -05:00
|
|
|
struct Song {
|
|
|
|
QString name;
|
|
|
|
QString id;
|
|
|
|
};
|
2021-07-18 21:09:04 -05:00
|
|
|
static constexpr auto BaseUrl = "http://127.0.0.1:4316";
|
|
|
|
QNetworkAccessManager *m_nam = new QNetworkAccessManager(this);
|
2021-07-25 01:11:40 -05:00
|
|
|
QNetworkAccessManager *m_pollingNam = new QNetworkAccessManager(this);
|
|
|
|
QNetworkAccessManager *m_songListNam = new QNetworkAccessManager(this);
|
|
|
|
QNetworkAccessManager *m_slideListNam = new QNetworkAccessManager(this);
|
|
|
|
QTimer m_pollTimer;
|
|
|
|
QHash<QString, QString> m_songNameMap;
|
|
|
|
int m_currentServiceId = -1;
|
|
|
|
QString m_currentSongId;
|
2021-07-18 21:09:04 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit OpenLPClient(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void nextSlide();
|
|
|
|
|
|
|
|
void prevSlide();
|
|
|
|
|
|
|
|
void nextSong();
|
|
|
|
|
|
|
|
void prevSong();
|
|
|
|
|
|
|
|
void blankScreen();
|
|
|
|
|
|
|
|
void showSlides();
|
|
|
|
|
2021-07-25 01:11:40 -05:00
|
|
|
void changeSong(int it);
|
|
|
|
|
|
|
|
void changeSlide(int slide);
|
|
|
|
|
2021-07-18 21:09:04 -05:00
|
|
|
private:
|
|
|
|
void get(QString url);
|
|
|
|
|
2021-07-25 01:11:40 -05:00
|
|
|
void requestSongList();
|
|
|
|
|
|
|
|
void requestSlideList();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void poll();
|
|
|
|
|
|
|
|
void handleGeneralResponse(QNetworkReply *reply);
|
|
|
|
|
|
|
|
void handlePollResponse(QNetworkReply *reply);
|
|
|
|
|
|
|
|
void handleSongListResponse(QNetworkReply *reply);
|
|
|
|
|
|
|
|
void handleSlideListResponse(QNetworkReply *reply);
|
|
|
|
|
2021-07-18 21:09:04 -05:00
|
|
|
signals:
|
2021-07-25 01:11:40 -05:00
|
|
|
void pollUpdate(QString songId, int slideNum);
|
|
|
|
|
|
|
|
void songListUpdate(QStringList);
|
|
|
|
|
|
|
|
void slideListUpdate(QStringList, QStringList);
|
2021-07-18 21:09:04 -05:00
|
|
|
|
|
|
|
};
|
|
|
|
|