Commit 422cce91 authored by Mike Sheldon's avatar Mike Sheldon

Add support for tuning in to radio stations in the MeeGo client

parent 6e770a2c
......@@ -3,7 +3,6 @@ import com.nokia.meego 1.0
Page {
id: loginPage
property int buttonWidth: 300
anchors.margins: rootWin.pageMargin
Connections {
......
......@@ -3,7 +3,6 @@ import com.nokia.meego 1.0
Page {
id: menuPage
property int buttonWidth: 300
anchors.margins: rootWin.pageMargin
Image {
......@@ -19,7 +18,7 @@ Page {
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 40
anchors.horizontalCenter: parent.horizontalCenter
spacing: 200
spacing: 300
Column {
id: col_recent
......@@ -29,7 +28,6 @@ Page {
id: lbl_recent
text: "Recent Stations"
font.weight: Font.Bold
width: buttonWidth
}
ListModel {
......@@ -66,7 +64,7 @@ Page {
delegate: Item {
id: listItem
height: 44
width: buttonWidth
width: 300
BorderImage {
id: background
......
......@@ -3,91 +3,118 @@ import com.nokia.meego 1.0
Page {
id: stationPage
anchors.margins: rootWin.pageMargin
tools: commonTools
ButtonRow {
Connections {
target: serverComm
onTuned: {
lblStationName.text = stationName;
}
}
Column {
anchors.horizontalCenter: parent.horizontalCenter
exclusive: false
Button {
id: btnBan
Image {
anchors.centerIn: parent
anchors.verticalCenterOffset: -1
source: "ban.png"
}
}
spacing: 20
Button {
id: btnTag
Image {
anchors.centerIn: parent
source: "image://theme/icon-m-toolbar-tag" + (theme.inverted ? "-inverse" : "")
}
Image {
id: imgLibre
source: "librefm-logo.png"
anchors.horizontalCenter: parent.horizontalCenter
z: -1
}
Button {
id: btnPrevious
Image {
anchors.centerIn: parent
source: "image://theme/icon-m-toolbar-mediacontrol-previous" + (theme.inverted ? "-inverse" : "")
}
Label {
id: lblStationName
text: "Tuning in..."
anchors.horizontalCenter: parent.horizontalCenter
}
Button {
id: btnPlay
property bool playing: false;
Image {
id: imgPlay
anchors.centerIn: parent
visible: false
source: "image://theme/icon-m-toolbar-mediacontrol-play" + (theme.inverted ? "-inverse" : "")
ButtonRow {
exclusive: false
Button {
id: btnBan
Image {
anchors.centerIn: parent
anchors.verticalCenterOffset: -1
source: "ban.png"
}
}
Image {
id: imgPause
anchors.centerIn: parent
source: "image://theme/icon-m-toolbar-mediacontrol-pause" + (theme.inverted ? "-inverse" : "")
Button {
id: btnTag
Image {
anchors.centerIn: parent
source: "image://theme/icon-m-toolbar-tag" + (theme.inverted ? "-inverse" : "")
}
}
onClicked: {
if (imgPlay.visible) {
imgPlay.visible = false
imgPause.visible = true
} else {
imgPlay.visible = true
imgPause.visible = false
Button {
id: btnPrevious
Image {
anchors.centerIn: parent
source: "image://theme/icon-m-toolbar-mediacontrol-previous" + (theme.inverted ? "-inverse" : "")
}
}
Button {
id: btnPlay
property bool playing: false;
Image {
id: imgPlay
anchors.centerIn: parent
visible: false
source: "image://theme/icon-m-toolbar-mediacontrol-play" + (theme.inverted ? "-inverse" : "")
}
Image {
id: imgPause
anchors.centerIn: parent
source: "image://theme/icon-m-toolbar-mediacontrol-pause" + (theme.inverted ? "-inverse" : "")
}
onClicked: {
if (imgPlay.visible) {
imgPlay.visible = false
imgPause.visible = true
} else {
imgPlay.visible = true
imgPause.visible = false
}
}
}
Button {
id: btnNext
Image {
anchors.centerIn: parent
source: "image://theme/icon-m-toolbar-mediacontrol-next" + (theme.inverted ? "-inverse" : "")
}
}
Button {
id: btnSave
Image {
anchors.centerIn: parent
source: "image://theme/icon-m-common-save-as" + (theme.inverted ? "-inverse" : "")
scale: 0.8
Button {
id: btnNext
Image {
anchors.centerIn: parent
source: "image://theme/icon-m-toolbar-mediacontrol-next" + (theme.inverted ? "-inverse" : "")
}
}
Button {
id: btnSave
Image {
anchors.centerIn: parent
source: "image://theme/icon-m-common-save-as" + (theme.inverted ? "-inverse" : "")
scale: 0.8
}
}
}
Button {
id: btnLove
Image {
anchors.centerIn: parent
anchors.verticalCenterOffset: -1
source: "love.png"
Button {
id: btnLove
Image {
anchors.centerIn: parent
anchors.verticalCenterOffset: -1
source: "love.png"
}
}
}
}
......
......@@ -116,8 +116,35 @@ void ServerComm::tuneStation(const QString &station) {
QNetworkAccessManager *tune_netman = new QNetworkAccessManager(this);
connect(tune_netman, SIGNAL(finished(QNetworkReply*)), this, SLOT(tuneReply(QNetworkReply*)));
QUrl url = QUrl(ws_url);
url.addQueryItem("method", "radio.tune");
url.addQueryItem("sk", ws_sk);
url.addQueryItem("station", station);
tune_netman->get(QNetworkRequest(url));
QByteArray params;
params.append("method=radio.tune");
params.append("&sk="); params.append(ws_sk);
params.append("&station="); params.append(station);
tune_netman->post(QNetworkRequest(url), params);
}
void ServerComm::tuneReply(QNetworkReply *reply) {
QDomDocument xml("tuneresponse");
xml.setContent(reply);
QDomElement root = xml.documentElement();
QDomNode n = root.firstChild();
for(QDomNode n = root.firstChild(); !n.isNull(); n = n.nextSibling()) {
QDomElement e = n.toElement();
if(!e.isNull()) {
if(e.tagName() == "error") {
qWarning() << "Station tuning failed.";
}
if(e.tagName() == "station") {
for(QDomNode c = n.firstChild(); !c.isNull(); c = c.nextSibling()) {
QDomElement ce = c.toElement();
if(ce.tagName() == "name") {
QString stationName = ce.text().remove(0, 9); // Remove 'Libre.fm' from the start of station names
qDebug() << "Tuned to:" << stationName;
tuned(stationName);
}
}
}
}
}
}
......@@ -24,12 +24,14 @@ private:
signals:
void loginFailed();
void loginSuccessful();
void tuned(QString stationName);
public slots:
void login(const QString &username, const QString &password);
void tuneStation(const QString &station);
void wsLoginReply(QNetworkReply *reply);
void scrobbleLoginReply(QNetworkReply *reply);
void tuneReply(QNetworkReply *reply);
};
#endif // SERVERCOMM_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment