1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
//===========================================
// Lumina-Desktop source code
// Copyright (c) 2017, Ken Moore
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
// This is a interface to the "pianobar" utility for streaming
// audio from the Pandora radio service
//===========================================
#ifndef _LUMINA_PIANOBAR_PROCESS_H
#define _LUMINA_PIANOBAR_PROCESS_H
#include <QObject>
#include <QWidget>
#include <QProcess>
#include <QTimer>
// #define PIANOBAR_FIFO QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/pianobar/ctl"
// #define PIANOBAR_CONFIG QString(getenv("XDG_CONFIG_HOME"))+"/lumina-desktop/pianobar/config"
class PianoBarProcess : public QObject{
Q_OBJECT
public:
enum State {Stopped, Running, Paused};
PianoBarProcess(QWidget *parent);
~PianoBarProcess();
State currentState();
//Interaction functions
bool isSetup(); //email/password already saved for use or not
void setLogin(QString email, QString pass);
QString email();
QString password();
void closePianoBar(); //"q"
QString currentStation(); //Re-direct for the "autostartStation()" function;
QStringList stations();
void setCurrentStation(QString station);
void deleteCurrentStation(); //"d"
//void createNewStation(); //"c"
void createStationFromCurrentSong(); //"v" -> "s"
void createStationFromCurrentArtist(); //"v" -> "a"
//Settings Manipulation
QString audioQuality(); // "audio_quality" = [low, medium, high]
void setAudioQuality(QString); // [low, medium, high]
QString autostartStation(); //"autostart_station" = ID
void setAutostartStation(QString);
QString proxy(); //"proxy" = URL (example: "http://USER:PASSWORD@HOST:PORT/" )
void setProxy(QString);
QString controlProxy(); //"control_proxy" = URL (example: "http://USER:PASSWORD@HOST:PORT/" )
void setControlProxy(QString);
private:
//Process
QProcess *PROC;
QStringList infoList;
void setupProcess();
void sendToProcess(QString);
//Settings file management
QStringList currentSettings; //cache of the settings file (file is really small);
QString settingsPath; //location of the settings file
QTimer *saveTimer;
void GenerateSettings();
bool loadSettings();
QString settingValue(QString);
void setSettingValue(QString,QString);
//Cached Info
QString cstation; //current station
QStringList stationList;
public slots:
void play(); // "P"
void pause(){ sendToProcess("S"); } //"S"
void volumeDown(){ sendToProcess("("); } //"("
void volumeUp(){ sendToProcess(")"); } //")"
void skipSong(){ sendToProcess("n"); } //"n"
void loveSong(){ sendToProcess("+"); } // "+"
void tiredSong(){ sendToProcess("t"); } // "t"
void banSong(){ sendToProcess("-"); } //"-"
void bookmarkSong(){ sendToProcess("b"); sendToProcess("s"); } //"b"->"s"
void bookmarkArtist(){ sendToProcess("b"); sendToProcess("a"); } //"b"->"a"
void explainSong(){ sendToProcess("e"); } //"e"
void requestHistory(){ sendToProcess("h"); } // "h" NOTE: Long series of interactive prompts - better to avoid for now
void requestSongInfo(){ sendToProcess("i"); } //"i" NOTE: This will re-print the current station/song information
void requestUpcoming(){ sendToProcess("u"); } //"u" NOTE: This will often return "(i) No songs in queue" - best to run this after a "Receiving new playlist" info message
private slots:
void ProcUpdate();
void saveSettingsFile();
signals:
void NewInformation(QString); //random status updates/information
void NowPlayingStation(QString, QString); //[name, id]
void NowPlayingSong(bool, QString,QString,QString, QString, QString); //[isLoved, title, artist, album, detailsURL, fromStation]
void TimeUpdate(int, int); //[current secs, total secs];
void NewList(QStringList); //arranged in order: 0-end
void StationListChanged(QStringList);
void currentStateChanged(PianoBarProcess::State);
};
#endif
|