Skip to content

Commit

Permalink
Respect viewMode
Browse files Browse the repository at this point in the history
Set and read viewMode, fixes xbmc#547
  • Loading branch information
Tobias Hieta committed Jul 29, 2013
1 parent cf49a82 commit e4e60d8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
14 changes: 14 additions & 0 deletions plex/Client/PlexMediaServerClient.cpp
Expand Up @@ -114,3 +114,17 @@ CPlexMediaServerClient::SetItemRating(const CFileItemPtr &item, float rating)
AddJob(new CPlexMediaServerClientJob(u));
}

void
CPlexMediaServerClient::SetViewMode(const CFileItem &item, int viewMode, int sortMode, int sortAsc)
{
CURL u(item.GetPath());
u.SetFileName("/:/viewChange");
u.SetOption("identifier", item.GetProperty("identifier").asString());
u.SetOption("viewGroup", item.GetProperty("viewGroup").asString());

u.SetOption("viewMode", boost::lexical_cast<CStdString>(viewMode));
u.SetOption("sortMode", boost::lexical_cast<CStdString>(sortMode));
u.SetOption("sortAsc", boost::lexical_cast<CStdString>(sortAsc));

AddJob(new CPlexMediaServerClientJob(u));
}
3 changes: 3 additions & 0 deletions plex/Client/PlexMediaServerClient.h
Expand Up @@ -65,6 +65,9 @@ class CPlexMediaServerClient : public CJobQueue
void ReportItemProgress(const CFileItemPtr& item, MediaState state, int64_t currentPosition = 0);
void ReportItemProgress(const CFileItemPtr& item, const CStdString& state, int64_t currentPosition = 0);

/* Set viewMode */
void SetViewMode(const CFileItem& item, int viewMode, int sortMode = -1, int sortAsc = 1);

private:
CStdString GetPrefix(const CFileItemPtr& item) const
{
Expand Down
14 changes: 13 additions & 1 deletion plex/FileSystem/PlexDirectory.cpp
Expand Up @@ -29,6 +29,8 @@
#include "Client/PlexServerDataLoader.h"
#include "Client/MyPlex/MyPlexManager.h"

#include "GUIViewState.h"

using namespace XFILE;

/* IDirectory Interface */
Expand Down Expand Up @@ -182,7 +184,7 @@ static AttributeMap g_attributeMap = boost::assign::list_of<AttributePair>
("bitrate", g_parserInt)
("samplingRate", g_parserInt)
("dialogNorm", g_parserInt)

("viewMode", g_parserInt)

("filters", g_parserBool)
("refreshing", g_parserBool)
Expand Down Expand Up @@ -337,6 +339,16 @@ CPlexDirectory::ReadMediaContainer(TiXmlElement* root, CFileItemList& mediaConta
CPlexDirectory::CopyAttributes(root, mediaContainer, m_url);
g_parserKey->Process(m_url, "key", m_url.GetFileName(), mediaContainer);

/* set the view mode */
if (mediaContainer.HasProperty("viewMode"))
{
int viewMode = mediaContainer.GetProperty("viewMode").asInteger();
mediaContainer.SetDefaultViewMode(viewMode);
CGUIViewState *state = CGUIViewState::GetViewState(0, mediaContainer);
state->SaveViewAsControl(viewMode);
}

/* now read all the childs to the mediaContainer */
ReadChildren(root, mediaContainer);

/* We just use the first item Type, it might be wrong and we should maybe have a look... */
Expand Down
6 changes: 1 addition & 5 deletions xbmc/windows/GUIMediaWindow.cpp
Expand Up @@ -529,11 +529,7 @@ bool CGUIMediaWindow::OnMessage(CGUIMessage& message)
#endif

/* PLEX */
/*
PlexMediaServerQueue::Get().onViewModeChanged(m_vecItems->GetProperty("identifier").asString(),
m_vecItems->GetPath(),
m_vecItems->GetProperty("viewGroup").asString(),
viewMode, -1, -1);*/
g_plexMediaServerClient.SetViewMode(*m_vecItems, viewMode);
m_vecItems->SetDefaultViewMode(viewMode);
/* END PLEX */

Expand Down

0 comments on commit e4e60d8

Please sign in to comment.