Permalink
Browse files

Merge pull request #1258 from Montellese/gsoc_xsp_and_or

smartplaylist extensions & extended filtering in JSON-RPC
  • Loading branch information...
2 parents 8aaa44d + 6558d1e commit 85ed7ecb5939f8f4bee40548adfccfc548e43c97 @Montellese Montellese committed Sep 3, 2012
@@ -150,12 +150,12 @@ bool CGUIDialogSmartPlaylistEditor::OnMessage(CGUIMessage& message)
void CGUIDialogSmartPlaylistEditor::OnRuleList(int item)
{
- if (item < 0 || item >= (int)m_playlist.m_playlistRules.size()) return;
+ if (item < 0 || item >= (int)m_playlist.m_ruleCombination.m_rules.size()) return;
- CSmartPlaylistRule rule = m_playlist.m_playlistRules[item];
+ CSmartPlaylistRule rule = m_playlist.m_ruleCombination.m_rules[item];
if (CGUIDialogSmartPlaylistRule::EditRule(rule,m_playlist.GetType()))
- m_playlist.m_playlistRules[item] = rule;
+ m_playlist.m_ruleCombination.m_rules[item] = rule;
UpdateButtons();
}
@@ -213,7 +213,7 @@ void CGUIDialogSmartPlaylistEditor::OnMatch()
{
CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_MATCH);
OnMessage(msg);
- m_playlist.m_matchAllRules = (msg.GetParam1() == 0);
+ m_playlist.m_ruleCombination.SetType(msg.GetParam1() == 0 ? CSmartPlaylistRuleCombination::CombinationAnd : CSmartPlaylistRuleCombination::CombinationOr);
UpdateButtons();
}
@@ -262,20 +262,20 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons()
SET_CONTROL_LABEL2(CONTROL_NAME, m_playlist.m_playlistName);
}
- CONTROL_ENABLE_ON_CONDITION(CONTROL_RULE_REMOVE, m_playlist.m_playlistRules.size() > 0);
- CONTROL_ENABLE_ON_CONDITION(CONTROL_MATCH, m_playlist.m_playlistRules.size() > 1);
+ CONTROL_ENABLE_ON_CONDITION(CONTROL_RULE_REMOVE, m_playlist.m_ruleCombination.m_rules.size() > 0);
+ CONTROL_ENABLE_ON_CONDITION(CONTROL_MATCH, m_playlist.m_ruleCombination.m_rules.size() > 1);
int currentItem = GetSelectedItem();
CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_RULE_LIST);
OnMessage(msgReset);
m_ruleLabels->Clear();
- for (unsigned int i = 0; i < m_playlist.m_playlistRules.size(); i++)
+ for (unsigned int i = 0; i < m_playlist.m_ruleCombination.m_rules.size(); i++)
{
CFileItemPtr item(new CFileItem("", false));
- if (m_playlist.m_playlistRules[i].m_field == FieldNone)
+ if (m_playlist.m_ruleCombination.m_rules[i].m_field == FieldNone)
item->SetLabel(g_localizeStrings.Get(21423));
else
- item->SetLabel(m_playlist.m_playlistRules[i].GetLocalizedRule(m_playlist.GetType()));
+ item->SetLabel(m_playlist.m_ruleCombination.m_rules[i].GetLocalizedRule(m_playlist.GetType()));
m_ruleLabels->Add(item);
}
CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_RULE_LIST, 0, 0, m_ruleLabels);
@@ -325,7 +325,7 @@ void CGUIDialogSmartPlaylistEditor::OnWindowLoaded()
msg.SetLabel(21426);
OnMessage(msg);
}
- SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_MATCH, m_playlist.m_matchAllRules ? 0 : 1);
+ SendMessage(GUI_MSG_ITEM_SELECT, CONTROL_MATCH, m_playlist.m_ruleCombination.GetType() == CSmartPlaylistRuleCombination::CombinationAnd ? 0 : 1);
// and now the limit spinner
{
CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_LIMIT, 0);
@@ -434,8 +434,8 @@ void CGUIDialogSmartPlaylistEditor::HighlightItem(int item)
void CGUIDialogSmartPlaylistEditor::OnRuleRemove(int item)
{
- if (item < 0 || item >= (int)m_playlist.m_playlistRules.size()) return;
- m_playlist.m_playlistRules.erase(m_playlist.m_playlistRules.begin() + item);
+ if (item < 0 || item >= (int)m_playlist.m_ruleCombination.m_rules.size()) return;
+ m_playlist.m_ruleCombination.m_rules.erase(m_playlist.m_ruleCombination.m_rules.begin() + item);
UpdateButtons();
if (item >= m_ruleLabels->Size())
@@ -453,10 +453,10 @@ void CGUIDialogSmartPlaylistEditor::OnRuleAdd()
CSmartPlaylistRule rule;
if (CGUIDialogSmartPlaylistRule::EditRule(rule,m_playlist.GetType()))
{
- if (m_playlist.m_playlistRules.size() == 1 && m_playlist.m_playlistRules[0].m_field == FieldNone)
- m_playlist.m_playlistRules[0] = rule;
+ if (m_playlist.m_ruleCombination.m_rules.size() == 1 && m_playlist.m_ruleCombination.m_rules[0].m_field == FieldNone)
+ m_playlist.m_ruleCombination.m_rules[0] = rule;
else
- m_playlist.m_playlistRules.push_back(rule);
+ m_playlist.m_ruleCombination.m_rules.push_back(rule);
}
UpdateButtons();
}
@@ -468,7 +468,7 @@ bool CGUIDialogSmartPlaylistEditor::NewPlaylist(const CStdString &type)
editor->m_path = "";
editor->m_playlist = CSmartPlaylist();
- editor->m_playlist.m_playlistRules.push_back(CSmartPlaylistRule());
+ editor->m_playlist.m_ruleCombination.m_rules.push_back(CSmartPlaylistRule());
editor->m_mode = type;
editor->Initialize();
editor->DoModal(g_windowManager.GetActiveWindow());
@@ -493,13 +493,13 @@ bool CGUIDialogSmartPlaylistEditor::EditPlaylist(const CStdString &path, const C
if (!editor->m_mode.Left(5).Equals("party"))
return false; // only edit normal playlists that exist
// party mode playlists can be editted even if they don't exist
- playlist.m_playlistRules.push_back(CSmartPlaylistRule());
+ playlist.m_ruleCombination.m_rules.push_back(CSmartPlaylistRule());
playlist.SetType(editor->m_mode == "partymusic" ? "songs" : "musicvideos");
}
editor->m_playlist = playlist;
- if (editor->m_playlist.m_playlistRules.size() <= 0)
- editor->m_playlist.m_playlistRules.push_back(CSmartPlaylistRule());
+ if (editor->m_playlist.m_ruleCombination.m_rules.size() <= 0)
+ editor->m_playlist.m_ruleCombination.m_rules.push_back(CSmartPlaylistRule());
editor->m_path = path;
editor->Initialize();
editor->DoModal(g_windowManager.GetActiveWindow());
@@ -50,14 +50,22 @@ JSONRPC_STATUS CAudioLibrary::GetArtists(const CStdString &method, ITransportLay
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
- if (filter.isMember("genre"))
+ else if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
- if (filter.isMember("albumid"))
+ else if (filter.isMember("albumid"))
albumID = (int)filter["albumid"].asInteger();
- if (filter.isMember("album"))
+ else if (filter.isMember("album"))
musicUrl.AddOption("album", filter["album"].asString());
- if (filter.isMember("songid"))
+ else if (filter.isMember("songid"))
songID = (int)filter["songid"].asInteger();
+ else if (filter.isObject())
+ {
+ CStdString xsp;
+ if (!GetXspFiltering("artists", filter, xsp))
+ return InvalidParams;
+
+ musicUrl.AddOption("xsp", xsp);
+ }
bool albumArtistsOnly = !g_guiSettings.GetBool("musiclibrary.showcompilationartists");
if (parameterObject["albumartistsonly"].isBoolean())
@@ -126,12 +134,20 @@ JSONRPC_STATUS CAudioLibrary::GetAlbums(const CStdString &method, ITransportLaye
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("artistid"))
artistID = (int)filter["artistid"].asInteger();
- if (filter.isMember("artist"))
+ else if (filter.isMember("artist"))
musicUrl.AddOption("artist", filter["artist"].asString());
- if (filter.isMember("genreid"))
+ else if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
- if (filter.isMember("genre"))
+ else if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
+ else if (filter.isObject())
+ {
+ CStdString xsp;
+ if (!GetXspFiltering("albums", filter, xsp))
+ return InvalidParams;
+
+ musicUrl.AddOption("xsp", xsp);
+ }
SortDescription sorting;
ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd);
@@ -185,16 +201,24 @@ JSONRPC_STATUS CAudioLibrary::GetSongs(const CStdString &method, ITransportLayer
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("artistid"))
artistID = (int)filter["artistid"].asInteger();
- if (filter.isMember("artist"))
+ else if (filter.isMember("artist"))
musicUrl.AddOption("artist", filter["artist"].asString());
- if (filter.isMember("genreid"))
+ else if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
- if (filter.isMember("genre"))
+ else if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
- if (filter.isMember("albumid"))
+ else if (filter.isMember("albumid"))
albumID = (int)filter["albumid"].asInteger();
- if (filter.isMember("album"))
+ else if (filter.isMember("album"))
musicUrl.AddOption("album", filter["album"].asString());
+ else if (filter.isObject())
+ {
+ CStdString xsp;
+ if (!GetXspFiltering("songs", filter, xsp))
+ return InvalidParams;
+
+ musicUrl.AddOption("xsp", xsp);
+ }
SortDescription sorting;
ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd);
@@ -25,6 +25,7 @@
#include "ServiceDescription.h"
#include "input/ButtonTranslator.h"
#include "interfaces/AnnouncementManager.h"
+#include "playlists/SmartPlayList.h"
#include "settings/AdvancedSettings.h"
#include "utils/log.h"
#include "utils/Variant.h"
@@ -45,6 +46,39 @@ void CJSONRPC::Initialize()
CButtonTranslator::GetActions(inputActions);
CJSONServiceDescription::AddEnum("Input.Action", inputActions);
+ // filter-related enums
+ vector<string> smartplaylistList;
+ CSmartPlaylist::GetAvailableOperators(smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Operators", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("movies", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.Movies", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("tvshows", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.TVShows", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("episodes", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.Episodes", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("musicvideos", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.MusicVideos", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("artists", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.Artists", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("albums", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.Albums", smartplaylistList);
+
+ smartplaylistList.clear();
+ CSmartPlaylist::GetAvailableFields("songs", smartplaylistList);
+ CJSONServiceDescription::AddEnum("List.Filter.Fields.Songs", smartplaylistList);
+
unsigned int size = sizeof(JSONRPC_SERVICE_TYPES) / sizeof(char*);
for (unsigned int index = 0; index < size; index++)
Oops, something went wrong. Retry.

0 comments on commit 85ed7ec

Please sign in to comment.