Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gnu-fm
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
16
Issues
16
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gnu.io
gnu-fm
Commits
7afd3238
Commit
7afd3238
authored
Dec 31, 2013
by
Mike Sheldon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement login for sailfish client and add main menu
parent
fb629fd5
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
259 additions
and
565 deletions
+259
-565
harbour-librefm.pro
clients/sailfish/harbour-librefm.pro
+3
-1
harbour-librefm.pro.user
clients/sailfish/harbour-librefm.pro.user
+0
-529
harbour-librefm.qml
clients/sailfish/qml/harbour-librefm.qml
+32
-5
LoginPage.qml
clients/sailfish/qml/pages/LoginPage.qml
+20
-19
MenuPage.qml
clients/sailfish/qml/pages/MenuPage.qml
+66
-0
RadioPage.qml
clients/sailfish/qml/pages/RadioPage.qml
+127
-0
harbour-librefm.yaml
clients/sailfish/rpm/harbour-librefm.yaml
+10
-10
harbour-librefm.cpp
clients/sailfish/src/harbour-librefm.cpp
+1
-1
No files found.
clients/sailfish/harbour-librefm.pro
View file @
7afd3238
...
...
@@ -23,7 +23,9 @@ OTHER_FILES += qml/harbour-librefm.qml \
qml
/
images
/
librefm
-
tower
.
png
\
qml
/
images
/
librefm
-
logo
.
png
\
qml
/
images
/
librefm
.
svg
\
qml
/
images
/
empty
-
album
.
png
qml
/
images
/
empty
-
album
.
png
\
qml
/
pages
/
MenuPage
.
qml
\
qml
/
pages
/
RadioPage
.
qml
HEADERS
+=
\
src
/
settings
.
h
...
...
clients/sailfish/harbour-librefm.pro.user
deleted
100644 → 0
View file @
fb629fd5
This diff is collapsed.
Click to expand it.
clients/sailfish/qml/harbour-librefm.qml
View file @
7afd3238
...
...
@@ -6,9 +6,18 @@ ApplicationWindow
{
property
string
wsUrl
:
"http://libre.fm/2.0/"
;
property
string
wsKey
:
""
;
initialPage
:
LoginPage
{
}
property
string
wsUser
:
""
;
initialPage
:
Component
{
LoginPage
{
}
}
cover
:
Qt
.
resolvedUrl
(
"cover/CoverPage.qml"
)
Component
{
id
:
menuPage
MenuPage
{
}
}
Rectangle
{
id
:
errorRect
color
:
Theme
.
highlightColor
...
...
@@ -32,21 +41,39 @@ ApplicationWindow
}
}
function
request
(
url
,
callback
)
{
function
request
(
params
,
method
,
callback
)
{
var
xhr
=
new
XMLHttpRequest
();
xhr
.
onreadystatechange
=
(
function
(
mxhr
)
{
return
function
()
{
if
(
mxhr
.
readyState
===
XMLHttpRequest
.
DONE
)
{
callback
(
mxhr
);
}
}
})(
xhr
);
xhr
.
open
(
'GET'
,
url
,
true
);
xhr
.
send
(
''
);
if
(
method
===
"post"
)
{
xhr
.
open
(
'POST'
,
wsUrl
,
true
);
xhr
.
setRequestHeader
(
"Content-type"
,
"application/x-www-form-urlencoded"
);
xhr
.
setRequestHeader
(
"Content-length"
,
params
.
length
);
xhr
.
setRequestHeader
(
"Connection"
,
"close"
);
xhr
.
send
(
params
);
}
else
{
xhr
.
open
(
'GET'
,
wsUrl
+
"/?"
+
params
,
true
);
xhr
.
send
(
''
);
}
}
function
showError
(
e
)
{
console
.
log
(
e
.
text
);
errorBanner
.
text
=
e
.
nodeValue
;
errorBanner
.
text
=
e
.
childNodes
[
0
].
nodeValue
;
errorRect
.
visible
=
true
;
errorRectFadeOut
.
stop
();
errorRectFadeOut
.
start
();
console
.
log
(
e
.
nodeValue
);
}
function
playStation
(
s
)
{
console
.
log
(
"Lodaing station: "
+
s
);
var
component
=
Qt
.
createComponent
(
"pages/RadioPage.qml"
);
if
(
component
.
status
===
Component
.
Error
)
{
console
.
debug
(
"Error: "
+
component
.
errorString
()
);
}
var
radioPage
=
component
.
createObject
(
pageStack
,
{
station
:
s
});
pageStack
.
push
(
radioPage
);
}
}
clients/sailfish/qml/pages/LoginPage.qml
View file @
7afd3238
...
...
@@ -2,12 +2,11 @@ import QtQuick 2.0
import
Sailfish
.
Silica
1.0
Page
{
id
:
page
property
bool
loggingIn
:
false
;
Component.onCompleted
:
{
if
(
settings
.
value
(
"user"
,
false
)
!==
false
)
{
doLogin
(
settings
.
value
(
"user
"
),
settings
.
value
(
"auth
"
));
if
(
settings
.
value
(
"user
name
"
,
false
)
!==
false
)
{
doLogin
(
settings
.
value
(
"user
name"
),
settings
.
value
(
"authToken
"
));
}
}
...
...
@@ -16,7 +15,7 @@ Page {
source
:
"../images/librefm-logo.png"
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.top
:
parent
.
top
anchors.topMargin
:
10
0
anchors.topMargin
:
5
0
}
Column
{
...
...
@@ -28,7 +27,7 @@ Page {
anchors.leftMargin
:
10
anchors.rightMargin
:
10
anchors.top
:
logo
.
bottom
anchors.topMargin
:
10
0
anchors.topMargin
:
5
0
TextField
{
id
:
username
...
...
@@ -58,11 +57,6 @@ Page {
}
}
Item
{
height
:
10
width
:
1
}
Button
{
id
:
button
text
:
"Log in"
...
...
@@ -85,7 +79,7 @@ Page {
Label
{
width
:
parent
.
width
wrapMode
:
Text
.
WordWrap
font.p
ixelSize
:
20
font.p
ointSize
:
12
onLinkActivated
:
Qt
.
openUrlExternally
(
link
)
horizontalAlignment
:
Text
.
AlignHCenter
textFormat
:
Text
.
RichText
...
...
@@ -97,19 +91,26 @@ Page {
function
doLogin
(
user
,
auth
)
{
loggingIn
=
true
;
request
(
wsUrl
+
"?method=auth.getmobilesession&username="
+
user
+
"&authToken="
+
auth
,
function
(
doc
)
{
request
(
"method=auth.getmobilesession&username="
+
user
+
"&authToken="
+
auth
,
"get"
,
function
(
doc
)
{
loggingIn
=
false
;
console
.
log
(
doc
.
responseText
)
var
e
=
doc
.
responseXML
.
documentElement
;
for
(
var
i
=
0
;
i
<
e
.
childNodes
.
length
;
i
++
)
{
console
.
log
(
e
.
childNodes
[
i
]);
if
(
e
.
childNodes
[
i
].
nodeName
===
"error"
)
{
showError
(
e
.
childNodes
[
i
]);
}
if
(
e
.
childNodes
[
i
].
nodeName
===
"key"
)
{
settings
.
setValue
(
"username"
,
user
);
settings
.
setValue
(
"authToken"
,
auth
);
wsKey
=
e
.
childNodes
[
i
].
nodeValue
;
if
(
e
.
childNodes
[
i
].
nodeName
===
"session"
)
{
var
sess
=
e
.
childNodes
[
i
];
for
(
var
j
=
0
;
j
<
sess
.
childNodes
.
length
;
j
++
)
{
if
(
sess
.
childNodes
[
j
].
nodeName
===
"key"
)
{
settings
.
setValue
(
"username"
,
user
);
settings
.
setValue
(
"authToken"
,
auth
);
wsKey
=
sess
.
childNodes
[
j
].
childNodes
[
0
].
nodeValue
;
wsUser
=
user
;
pageStack
.
clear
();
pageStack
.
push
(
menuPage
);
console
.
log
(
wsKey
);
}
}
}
}
...
...
@@ -125,7 +126,7 @@ Page {
Column
{
anchors.centerIn
:
parent
anchors.verticalCenterOffset
:
2
0
anchors.verticalCenterOffset
:
10
0
visible
:
loggingIn
spacing
:
20
...
...
clients/sailfish/qml/pages/MenuPage.qml
0 → 100644
View file @
7afd3238
import
QtQuick
2.0
import
Sailfish
.
Silica
1.0
Page
{
SilicaFlickable
{
anchors.fill
:
parent
;
contentHeight
:
col
.
height
+
logo
.
height
;
contentWidth
:
parent
.
width
;
Image
{
id
:
logo
source
:
"../images/librefm-logo.png"
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.top
:
parent
.
top
anchors.topMargin
:
50
}
Column
{
id
:
col
;
anchors.top
:
logo
.
bottom
anchors.topMargin
:
50
;
width
:
parent
.
width
Button
{
text
:
"Your Loved Station"
anchors.horizontalCenter
:
parent
.
horizontalCenter
onClicked
:
{
playStation
(
"librefm://user/"
+
wsUser
+
"/loved"
);
}
}
Button
{
text
:
"Your Recommendations Station"
anchors.horizontalCenter
:
parent
.
horizontalCenter
onClicked
:
{
playStation
(
"librefm://user/"
+
wsUser
+
"/recommended"
);
}
}
Button
{
text
:
"Your Mix Station"
anchors.horizontalCenter
:
parent
.
horizontalCenter
onClicked
:
{
playStation
(
"librefm://user/"
+
wsUser
+
"/mix"
);
}
}
Button
{
text
:
"Tag Station"
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
Button
{
text
:
"Community Station"
anchors.horizontalCenter
:
parent
.
horizontalCenter
onClicked
:
{
playStation
(
"librefm://community/loved"
);
}
}
}
}
}
clients/sailfish/qml/pages/RadioPage.qml
0 → 100644
View file @
7afd3238
import
QtQuick
2.0
import
QtMultimedia
5.0
import
Sailfish
.
Silica
1.0
Page
{
property
string
station
:
""
;
Component.onCompleted
:
{
tune
(
station
);
}
MediaPlayer
{
id
:
player
}
Column
{
anchors.fill
:
parent
Label
{
id
:
stationName
anchors.horizontalCenter
:
parent
.
horizontalCenter
;
}
}
Row
{
id
:
controls
spacing
:
30
anchors.bottom
:
parent
.
bottom
Item
{
width
:
80
;
height
:
100
anchors.verticalCenter
:
parent
.
verticalCenter
Image
{
id
:
favIcon
anchors.centerIn
:
parent
opacity
:
enabled
?
(
starArea
.
pressed
?
0.4
:
1.0
)
:
0.2
source
:
"image://theme/icon-m-favorite"
}
MouseArea
{
id
:
starArea
anchors.fill
:
parent
anchors.margins
:
-
15
}
}
Item
{
width
:
80
;
height
:
100
anchors.verticalCenter
:
parent
.
verticalCenter
Image
{
anchors.centerIn
:
parent
source
:
"image://theme/icon-m-previous-song"
opacity
:
previous
.
pressed
?
0.4
:
1.0
}
MouseArea
{
id
:
previous
anchors.fill
:
parent
}
}
Item
{
width
:
80
;
height
:
100
anchors.verticalCenter
:
parent
.
verticalCenter
Image
{
anchors.centerIn
:
parent
source
:
player
.
playing
?
"image://theme/icon-m-pause"
:
"image://theme/icon-m-play"
opacity
:
play
.
pressed
?
0.4
:
1.0
}
MouseArea
{
id
:
play
anchors.fill
:
parent
}
}
Item
{
width
:
80
;
height
:
100
anchors.verticalCenter
:
parent
.
verticalCenter
Image
{
anchors.centerIn
:
parent
source
:
"image://theme/icon-m-next-song"
opacity
:
next
.
pressed
?
0.4
:
1.0
}
MouseArea
{
id
:
next
anchors.fill
:
parent
}
}
}
function
tune
(
s
)
{
console
.
log
(
"Tuning to: "
+
s
);
request
(
"method=radio.tune&station="
+
s
+
"&sk="
+
wsKey
,
"post"
,
function
(
doc
)
{
var
e
=
doc
.
responseXML
.
documentElement
;
console
.
log
(
doc
.
responseText
);
for
(
var
i
=
0
;
i
<
e
.
childNodes
.
length
;
i
++
)
{
if
(
e
.
childNodes
[
i
].
nodeName
===
"error"
)
{
showError
(
e
.
childNodes
[
i
]);
}
if
(
e
.
childNodes
[
i
].
nodeName
===
"station"
)
{
var
st
=
e
.
childNodes
[
i
];
for
(
var
j
=
0
;
j
<
st
.
childNodes
.
length
;
j
++
)
{
if
(
st
.
childNodes
[
j
].
nodeName
===
"name"
)
{
stationName
.
text
=
st
.
childNodes
[
j
].
childNodes
[
0
].
nodeValue
;
}
}
fetchPlaylist
();
}
}
});
}
function
fetchPlaylist
()
{
request
(
"method=radio.getplaylist&sk="
+
wsKey
,
"post"
,
function
(
doc
)
{
console
.
log
(
doc
.
responseText
)
;
var
e
=
doc
.
responseXML
.
documentElement
;
for
(
var
i
=
0
;
i
<
e
.
childNodes
.
length
;
i
++
)
{
console
.
log
(
e
.
childNodes
[
i
].
nodeName
);
}
});
}
}
clients/sailfish/rpm/harbour-librefm.yaml
View file @
7afd3238
...
...
@@ -12,18 +12,18 @@ Description: |
Configure
:
none
Builder
:
qtc5
PkgConfigBR
:
-
Qt5Quick
-
Qt5Qml
-
Qt5Core
-
sailfishapp >= 0.0.10
-
Qt5Core
-
Qt5Qml
-
Qt5Quick
Requires
:
-
sailfishsilica-qt5 >= 0.10.9
Files
:
-
'
%{_bindir}'
-
'
%{_datadir}/%{name}/qml'
-
'
%{_datadir}/applications/%{name}.desktop'
-
'
%{_datadir}/icons/hicolor/86x86/apps/%{name}.png'
-
/usr/bin
-
/usr/share/harbour-librefm
-
/usr/share/applications
-
/usr/share/icons/hicolor/86x86/apps
-
/usr/share/applications
-
/usr/share/harbour-librefm
-
/usr/bin
-
'
%{_datadir}/icons/hicolor/86x86/apps/%{name}.png'
-
'
%{_datadir}/applications/%{name}.desktop'
-
'
%{_datadir}/%{name}/qml'
-
'
%{_bindir}'
clients/sailfish/src/harbour-librefm.cpp
View file @
7afd3238
...
...
@@ -9,7 +9,7 @@
int
main
(
int
argc
,
char
*
argv
[])
{
QSettings
::
setPath
(
QSettings
::
NativeFormat
,
QSettings
::
UserScope
,
"/home/nemo/.local/share/harbour-librefm
/
"
);
QSettings
::
setPath
(
QSettings
::
NativeFormat
,
QSettings
::
UserScope
,
"/home/nemo/.local/share/harbour-librefm"
);
Settings
settings
;
QGuiApplication
*
app
=
SailfishApp
::
application
(
argc
,
argv
);
QQuickWindow
::
setDefaultAlphaBuffer
(
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment