mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-20 18:06:14 -05:00
[lastfm/jsonapi/ws/main] New JSON-API-endpoints for Last.fm integration
In preparation for the new endpoints the following refactorings where done in lastfm.c: - Initialize lastfm.c in main.c instead of on first scrobble attempt (necessary to retrieve the correct lastfm status) - Return error messages if login attempt failed - Add api function for status and logout - Notify about Last.fm status changes Unrelated changes in lastfm.c are: - Refactoring of request_post - Add request parameters sorted alphabetically and remove calling the sort method in request_post
This commit is contained in:
@@ -137,6 +137,10 @@ process_notify_request(struct ws_session_data_notify *session_data, void *in, si
|
||||
{
|
||||
session_data->events |= LISTENER_SPOTIFY;
|
||||
}
|
||||
else if (0 == strcmp(event_type, "lastfm"))
|
||||
{
|
||||
session_data->events |= LISTENER_LASTFM;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -177,6 +181,10 @@ send_notify_reply(short events, struct lws* wsi)
|
||||
{
|
||||
json_object_array_add(notify, json_object_new_string("spotify"));
|
||||
}
|
||||
if (events & LISTENER_LASTFM)
|
||||
{
|
||||
json_object_array_add(notify, json_object_new_string("lastfm"));
|
||||
}
|
||||
|
||||
reply = json_object_new_object();
|
||||
json_object_object_add(reply, "notify", notify);
|
||||
@@ -258,7 +266,7 @@ static struct lws_protocols protocols[] =
|
||||
static void *
|
||||
websocket(void *arg)
|
||||
{
|
||||
listener_add(listener_cb, LISTENER_UPDATE | LISTENER_PAIRING | LISTENER_SPOTIFY);
|
||||
listener_add(listener_cb, LISTENER_UPDATE | LISTENER_PAIRING | LISTENER_SPOTIFY | LISTENER_LASTFM);
|
||||
|
||||
while(!ws_exit)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user