Skip to content

Commit

Permalink
jsonrpc: merge Player.(Un)Shuffle into Player.SetShuffle with "shuffl…
Browse files Browse the repository at this point in the history
…e" parameter
  • Loading branch information
Montellese committed Oct 1, 2012
1 parent b2ca23c commit accafc5
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 53 deletions.
3 changes: 1 addition & 2 deletions xbmc/interfaces/json-rpc/JSONServiceDescription.cpp
Expand Up @@ -70,8 +70,7 @@ JsonRpcMethodMap CJSONServiceDescription::m_methodMaps[] = {
{ "Player.GoPrevious", CPlayerOperations::GoPrevious },
{ "Player.GoNext", CPlayerOperations::GoNext },
{ "Player.GoTo", CPlayerOperations::GoTo },
{ "Player.Shuffle", CPlayerOperations::Shuffle },
{ "Player.UnShuffle", CPlayerOperations::UnShuffle },
{ "Player.SetShuffle", CPlayerOperations::SetShuffle },
{ "Player.Repeat", CPlayerOperations::Repeat },
{ "Player.SetPartymode", CPlayerOperations::SetPartymode },

Expand Down
59 changes: 36 additions & 23 deletions xbmc/interfaces/json-rpc/PlayerOperations.cpp
Expand Up @@ -576,23 +576,53 @@ JSONRPC_STATUS CPlayerOperations::GoTo(const CStdString &method, ITransportLayer
return ACK;
}

JSONRPC_STATUS CPlayerOperations::Shuffle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
JSONRPC_STATUS CPlayerOperations::SetShuffle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
CGUIWindowSlideShow *slideshow = NULL;
CVariant shuffle = parameterObject["shuffle"];
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
case Audio:
CApplicationMessenger::Get().PlayListPlayerShuffle(GetPlaylist(GetPlayer(parameterObject["playerid"])), true);
OnPlaylistChanged();
{
int playlistid = GetPlaylist(GetPlayer(parameterObject["playerid"]));
if (g_playlistPlayer.IsShuffled(playlistid))
{
if ((shuffle.isBoolean() && !shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
{
CApplicationMessenger::Get().PlayListPlayerShuffle(playlistid, false);
OnPlaylistChanged();
}
}
else
{
if ((shuffle.isBoolean() && shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
{
CApplicationMessenger::Get().PlayListPlayerShuffle(playlistid, true);
OnPlaylistChanged();
}
}
break;
}

case Picture:
slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
if (slideshow && !slideshow->IsShuffled())
slideshow->Shuffle();
else if (!slideshow)
if (slideshow == NULL)
return FailedToExecute;
if (slideshow->IsShuffled())
{
if ((shuffle.isBoolean() && !shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
return FailedToExecute;
}
else
{
if ((shuffle.isBoolean() && shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
slideshow->Shuffle();
}
break;

default:
Expand All @@ -601,23 +631,6 @@ JSONRPC_STATUS CPlayerOperations::Shuffle(const CStdString &method, ITransportLa
return ACK;
}

JSONRPC_STATUS CPlayerOperations::UnShuffle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
case Audio:
CApplicationMessenger::Get().PlayListPlayerShuffle(GetPlaylist(GetPlayer(parameterObject["playerid"])), false);
OnPlaylistChanged();
break;

case Picture:
default:
return FailedToExecute;
}
return ACK;
}

JSONRPC_STATUS CPlayerOperations::Repeat(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
switch (GetPlayer(parameterObject["playerid"]))
Expand Down
3 changes: 1 addition & 2 deletions xbmc/interfaces/json-rpc/PlayerOperations.h
Expand Up @@ -55,8 +55,7 @@ namespace JSONRPC
static JSONRPC_STATUS GoPrevious(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS GoNext(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS GoTo(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS Shuffle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS UnShuffle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS SetShuffle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS Repeat(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS SetPartymode(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);

Expand Down
17 changes: 4 additions & 13 deletions xbmc/interfaces/json-rpc/ServiceDescription.h
Expand Up @@ -1384,23 +1384,14 @@ namespace JSONRPC
"],"
"\"returns\": \"string\""
"}",
"\"Player.Shuffle\": {"
"\"Player.SetShuffle\": {"
"\"type\": \"method\","
"\"description\": \"Shuffle items in the player\","
"\"description\": \"Shuffle/Unshuffle items in the player\","
"\"transport\": \"Response\","
"\"permission\": \"ControlPlayback\","
"\"params\": ["
"{ \"name\": \"playerid\", \"$ref\": \"Player.Id\", \"required\": true }"
"],"
"\"returns\": \"string\""
"}",
"\"Player.UnShuffle\": {"
"\"type\": \"method\","
"\"description\": \"Unshuffle items in the player\","
"\"transport\": \"Response\","
"\"permission\": \"ControlPlayback\","
"\"params\": ["
"{ \"name\": \"playerid\", \"$ref\": \"Player.Id\", \"required\": true }"
"{ \"name\": \"playerid\", \"$ref\": \"Player.Id\", \"required\": true },"
"{ \"name\": \"shuffle\", \"$ref\": \"Global.Toggle\", \"required\": true }"
"],"
"\"returns\": \"string\""
"}",
Expand Down
17 changes: 4 additions & 13 deletions xbmc/interfaces/json-rpc/methods.json
Expand Up @@ -317,23 +317,14 @@
],
"returns": "string"
},
"Player.Shuffle": {
"Player.SetShuffle": {
"type": "method",
"description": "Shuffle items in the player",
"description": "Shuffle/Unshuffle items in the player",
"transport": "Response",
"permission": "ControlPlayback",
"params": [
{ "name": "playerid", "$ref": "Player.Id", "required": true }
],
"returns": "string"
},
"Player.UnShuffle": {
"type": "method",
"description": "Unshuffle items in the player",
"transport": "Response",
"permission": "ControlPlayback",
"params": [
{ "name": "playerid", "$ref": "Player.Id", "required": true }
{ "name": "playerid", "$ref": "Player.Id", "required": true },
{ "name": "shuffle", "$ref": "Global.Toggle", "required": true }
],
"returns": "string"
},
Expand Down

0 comments on commit accafc5

Please sign in to comment.