We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

servercomm.h 1.16 KB
Newer Older
Mike Sheldon's avatar
Mike Sheldon committed
1 2 3 4 5
#ifndef SERVERCOMM_H
#define SERVERCOMM_H

#include <QObject>
#include <QString>
6
#include <QSettings>
Mike Sheldon's avatar
Mike Sheldon committed
7
#include <QtXml/QDomDocument>
Mike Sheldon's avatar
Mike Sheldon committed
8
#include <QtNetwork/QNetworkAccessManager>
Mike Sheldon's avatar
Mike Sheldon committed
9 10
#include <QList>
#include "track.h"
Mike Sheldon's avatar
Mike Sheldon committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24

class ServerComm : public QObject
{
    Q_OBJECT
public:
    explicit ServerComm(QObject *parent = 0);

private:
    QString ws_sk;
    QString scrobble_sk;
    QString np_url;
    QString scr_url;
    QString hs_url;
    QString ws_url;
25
    int currentSong;
26
    QSettings *settings;
Mike Sheldon's avatar
Mike Sheldon committed
27 28
    QList<Track> *playlist;
    void parseTrack(QDomNode trackNode);
Mike Sheldon's avatar
Mike Sheldon committed
29 30 31 32

signals:
    void loginFailed();
    void loginSuccessful();
33
    void tuned(QString stationName);
34
    void playing(QString artist, QString album, QString title, QString imageurl);
Mike Sheldon's avatar
Mike Sheldon committed
35

Mike Sheldon's avatar
Mike Sheldon committed
36
private slots:
Mike Sheldon's avatar
Mike Sheldon committed
37 38
    void wsLoginReply(QNetworkReply *reply);
    void scrobbleLoginReply(QNetworkReply *reply);
39
    void tuneReply(QNetworkReply *reply);
Mike Sheldon's avatar
Mike Sheldon committed
40 41 42 43 44 45 46
    void playlistReply(QNetworkReply *reply);

public slots:
    void login(const QString &username, const QString &password);
    void tuneStation(const QString &station);
    void getPlaylist();
    void play(int song);
47 48
    void next();
    void prev();
Mike Sheldon's avatar
Mike Sheldon committed
49

Mike Sheldon's avatar
Mike Sheldon committed
50 51 52
};

#endif // SERVERCOMM_H