Skip to content

Commit

Permalink
�Stub files: Added possibility to set a shortcut to a external file
Browse files Browse the repository at this point in the history
  • Loading branch information
waven committed Mar 19, 2016
1 parent a7caa16 commit e34dc1d
Show file tree
Hide file tree
Showing 22 changed files with 299 additions and 72 deletions.
21 changes: 18 additions & 3 deletions addons/resource.language.en_gb/resources/strings.po
Expand Up @@ -1303,7 +1303,10 @@ msgctxt "#294"
msgid "Create bookmark"
msgstr ""

#empty string with id 295
#: xbmc/dialogs/GUIDialogPlayEject.cpp
msgctxt "#295"
msgid "Please attach storage device"
msgstr ""

msgctxt "#296"
msgid "Clear bookmarks"
Expand Down Expand Up @@ -2091,7 +2094,14 @@ msgctxt "#470"
msgid "Credits"
msgstr ""

#empty strings from id 471 to 473
#empty string with id 471

#: xbmc/dialogs/GUIDialogPlayEject.cpp
msgctxt "#472"
msgid "Please insert the following hard drive:"
msgstr ""

#empty string with id 473

msgctxt "#474"
msgid "Off"
Expand Down Expand Up @@ -6609,7 +6619,12 @@ msgctxt "#13459"
msgid "Use OMXPlayer for decoding of video files."
msgstr ""

#empty strings from id 13460 to 13504
#: xbmc/dialogs/GUIDialogPlayEject.cpp
msgctxt "#13460"
msgid "Close"
msgstr ""

#empty strings from id 13461 to 13504

#: system/settings/settings.xml
msgctxt "#13505"
Expand Down
2 changes: 2 additions & 0 deletions project/VS2010Express/XBMC.vcxproj
Expand Up @@ -1367,6 +1367,7 @@
<ClCompile Include="..\..\xbmc\utils\StreamDetails.cpp" />
<ClCompile Include="..\..\xbmc\utils\StreamUtils.cpp" />
<ClCompile Include="..\..\xbmc\utils\StringUtils.cpp" />
<ClCompile Include="..\..\xbmc\utils\StubUtil.cpp" />
<ClCompile Include="..\..\xbmc\utils\SystemInfo.cpp" />
<ClCompile Include="..\..\xbmc\utils\test\TestFileOperationJob.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
Expand Down Expand Up @@ -2196,6 +2197,7 @@
<ClInclude Include="..\..\xbmc\utils\StreamDetails.h" />
<ClInclude Include="..\..\xbmc\utils\StreamUtils.h" />
<ClInclude Include="..\..\xbmc\utils\StringUtils.h" />
<ClInclude Include="..\..\xbmc\utils\StubUtil.h" />
<ClInclude Include="..\..\xbmc\utils\SystemInfo.h" />
<ClCompile Include="..\..\xbmc\utils\test\TestGlobalsHandlingPattern1.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
Expand Down
6 changes: 6 additions & 0 deletions project/VS2010Express/XBMC.vcxproj.filters
Expand Up @@ -2096,6 +2096,9 @@
<ClCompile Include="..\..\xbmc\utils\POUtils.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\utils\StubUtil.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\XbmcContext.cpp" />
<ClCompile Include="..\..\xbmc\network\ZeroconfBrowser.cpp">
<Filter>network</Filter>
Expand Down Expand Up @@ -5165,6 +5168,9 @@
<ClInclude Include="..\..\xbmc\utils\POUtils.h">
<Filter>utils</Filter>
</ClInclude>
<ClInclude Include="..\..\xbmc\utils\StubUtil.h">
<Filter>utils</Filter>
</ClInclude>
<ClInclude Include="..\..\xbmc\network\ZeroconfBrowser.h">
<Filter>network</Filter>
</ClInclude>
Expand Down
44 changes: 39 additions & 5 deletions xbmc/Application.cpp
Expand Up @@ -70,6 +70,7 @@
#include "filesystem/SpecialProtocol.h"
#include "filesystem/DllLibCurl.h"
#include "filesystem/PluginDirectory.h"
#include "utils/StubUtil.h"
#ifdef HAS_FILESYSTEM_SAP
#include "filesystem/SAPDirectory.h"
#endif
Expand Down Expand Up @@ -3215,7 +3216,7 @@ PlayBackRet CApplication::PlayStack(const CFileItem& item, bool bRestart)
else
{
int duration;
if (!CDVDFileInfo::GetFileDuration((*m_currentStack)[i]->GetPath(), duration))
if (!CDVDFileInfo::GetFileDuration((*m_currentStack)[i]->GetPlayablePath(), duration))
{
m_currentStack->Clear();
return PLAYBACK_FAIL;
Expand Down Expand Up @@ -3321,6 +3322,27 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
return PLAYBACK_OK;
}

if (item.IsEfileStub())
{
if (!item.HasProperty("playable_path") || item.IsEfileStub(true))
{
CFileItem item_new(item);
item_new.SetPlayablePath(g_stubutil.GetXMLString(item.GetPath(), "efilestub", "path"));
return PlayFile(item_new, bRestart);
}
else
{
if (!CFile::Exists(item.GetPlayablePath()))
{
// Show PlayEject dialoge
if (CGUIDialogPlayEject::ShowAndGetInput(item))
return PlayFile(item, bRestart);

return PLAYBACK_OK;
}
}
}

if (item.IsPlayList())
return PLAYBACK_FAIL;

Expand All @@ -3341,7 +3363,7 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
}

#ifdef HAS_UPNP
if (URIUtils::IsUPnP(item.GetPath()))
if (URIUtils::IsUPnP(item.GetPlayablePath()))
{
CFileItem item_new(item);
if (XFILE::CUPnPDirectory::GetResource(item.GetURL(), item_new))
Expand All @@ -3354,7 +3376,21 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
// "seamless" seeking and total time of the movie etc.
// will recall with restart set to true
if (item.IsStack())
return PlayStack(item, bRestart);
{
std::string strPathFirstElement = CStackDirectory::GetFirstStackedFile(item.GetPath());
if (g_stubutil.IsEfileStub(strPathFirstElement) && !CFile::Exists(g_stubutil.GetXMLString(strPathFirstElement, "efilestub", "path"), false))
{
CFileItem item_new(item);
item_new.SetPath(strPathFirstElement);
item_new.SetPlayablePath(g_stubutil.GetXMLString(strPathFirstElement, "efilestub", "path"));
if (CGUIDialogPlayEject::ShowAndGetInput(item_new))
return PlayFile(item, bRestart);

return PLAYBACK_OK;
}
else
return PlayStack(item, bRestart);
}

CPlayerOptions options;

Expand Down Expand Up @@ -3399,8 +3435,6 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
std::string path = item.GetPath();
if (item.HasVideoInfoTag() && StringUtils::StartsWith(item.GetVideoInfoTag()->m_strFileNameAndPath, "removable://"))
path = item.GetVideoInfoTag()->m_strFileNameAndPath;
else if (item.HasProperty("original_listitem_url") && URIUtils::IsPlugin(item.GetProperty("original_listitem_url").asString()))
path = item.GetProperty("original_listitem_url").asString();
if(dbs.GetResumeBookMark(path, bookmark))
{
options.starttime = bookmark.timeInSeconds;
Expand Down
49 changes: 46 additions & 3 deletions xbmc/FileItem.cpp
Expand Up @@ -58,6 +58,7 @@
#include "utils/log.h"
#include "utils/Variant.h"
#include "utils/Mime.h"
#include "utils/StubUtil.h"

#include <assert.h>
#include <algorithm>
Expand Down Expand Up @@ -762,6 +763,17 @@ bool CFileItem::IsPVRRadioRDS() const
return HasPVRRadioRDSInfoTag();
}

bool CFileItem::IsStub(bool checkPlayablePath) const
{
std::string path;
if (checkPlayablePath)
path = GetPlayablePath();
else
path = GetPath();

return URIUtils::HasExtension(path, g_advancedSettings.m_discStubExtensions);
}

bool CFileItem::IsDiscStub() const
{
if (IsVideoDb() && HasVideoInfoTag())
Expand All @@ -770,7 +782,25 @@ bool CFileItem::IsDiscStub() const
return dbItem.IsDiscStub();
}

return URIUtils::HasExtension(m_strPath, g_advancedSettings.m_discStubExtensions);
if (IsStub())
return g_stubutil.CheckRootElement(m_strPath, "discstub");

return false;
}

bool CFileItem::IsEfileStub(bool checkPlayablePath) const
{
if (checkPlayablePath)
{
if (IsStub(true))
return g_stubutil.CheckRootElement(GetPlayablePath(), "efilestub");
}
else
{
if (IsStub())
return g_stubutil.CheckRootElement(GetPath(), "efilestub");
}
return false;
}

bool CFileItem::IsAudio() const
Expand Down Expand Up @@ -998,7 +1028,7 @@ bool CFileItem::IsStack() const

bool CFileItem::IsPlugin() const
{
return URIUtils::IsPlugin(m_strPath);
return URIUtils::IsPlugin(GetPlayablePath());
}

bool CFileItem::IsScript() const
Expand Down Expand Up @@ -1535,7 +1565,7 @@ void CFileItem::SetURL(const CURL& url)

const CURL CFileItem::GetURL() const
{
CURL url(m_strPath);
CURL url(GetPlayablePath());
return url;
}

Expand Down Expand Up @@ -3326,3 +3356,16 @@ double CFileItem::GetCurrentResumeTime() const
// Resume from start when resume points are invalid or the PVR server returns an error
return 0;
}

std::string CFileItem::GetPlayablePath() const
{
if (HasProperty("playable_path"))
return GetProperty("playable_path").asString();
else
return GetPath();
}

void CFileItem::SetPlayablePath(const std::string &path)
{
SetProperty("playable_path", path);
}
6 changes: 5 additions & 1 deletion xbmc/FileItem.h
Expand Up @@ -128,6 +128,9 @@ class CFileItem :
void SetPath(const std::string &path) { m_strPath = path; };
bool IsPath(const std::string& path, bool ignoreURLOptions = false) const;

std::string GetPlayablePath() const;
void SetPlayablePath(const std::string &path);

/*! \brief reset class to it's default values as per construction.
Free's all allocated memory.
\sa Initialize
Expand Down Expand Up @@ -156,8 +159,9 @@ class CFileItem :
\return true if item is video, false otherwise.
*/
bool IsVideo() const;

bool IsStub(bool checkPlayablePath = false) const;
bool IsDiscStub() const;
bool IsEfileStub(bool checkPlayablePath = false) const;

/*!
\brief Check whether an item is a picture item. Note that this returns true for
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
Expand Up @@ -102,7 +102,7 @@ bool CExternalPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &opti
m_bIsPlaying = true;
m_time = 0;
m_playbackStartTime = XbmcThreads::SystemClockMillis();
m_launchFilename = file.GetPath();
m_launchFilename = file.GetPlayablePath();
CLog::Log(LOGNOTICE, "%s: %s", __FUNCTION__, m_launchFilename.c_str());
Create();

Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/dvdplayer/DVDPlayer.cpp
Expand Up @@ -637,7 +637,7 @@ CDVDPlayer::~CDVDPlayer()

bool CDVDPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options)
{
CLog::Log(LOGNOTICE, "DVDPlayer: Opening: %s", CURL::GetRedacted(file.GetPath()).c_str());
CLog::Log(LOGNOTICE, "DVDPlayer: Opening: %s", CURL::GetRedacted(file.GetPlayablePath()).c_str());

// if playing a file close it first
// this has to be changed so we won't have to close it.
Expand All @@ -657,7 +657,7 @@ bool CDVDPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options)
m_PlayerOptions = options;
m_item = file;
m_mimetype = file.GetMimeType();
m_filename = file.GetPath();
m_filename = file.GetPlayablePath();

m_ready.Reset();

Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/playercorefactory/PlayerCoreFactory.cpp
Expand Up @@ -159,9 +159,9 @@ void CPlayerCoreFactory::GetPlayers( VECPLAYERCORES &vecCores, const bool audio,

void CPlayerCoreFactory::GetPlayers( const CFileItem& item, VECPLAYERCORES &vecCores) const
{
CURL url(item.GetPath());
CURL url(item.GetPlayablePath());

CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers(%s)", CURL::GetRedacted(item.GetPath()).c_str());
CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers(%s)", CURL::GetRedacted(item.GetPlayablePath()).c_str());

// Process rules
for(unsigned int i = 0; i < m_vecCoreSelectionRules.size(); i++)
Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/playercorefactory/PlayerSelectionRule.cpp
Expand Up @@ -154,15 +154,15 @@ void CPlayerSelectionRule::GetPlayers(const CFileItem& item, VECPLAYERCORES &vec
!MatchesRegExp(CStreamDetails::VideoAspectToAspectDescription(streamDetails.GetVideoAspect()), regExp)) return;
}

CURL url(item.GetPath());
CURL url(item.GetPlayablePath());

if (CompileRegExp(m_fileTypes, regExp) && !MatchesRegExp(url.GetFileType(), regExp)) return;

if (CompileRegExp(m_protocols, regExp) && !MatchesRegExp(url.GetProtocol(), regExp)) return;

if (CompileRegExp(m_mimeTypes, regExp) && !MatchesRegExp(item.GetMimeType(), regExp)) return;

if (CompileRegExp(m_fileName, regExp) && !MatchesRegExp(item.GetPath(), regExp)) return;
if (CompileRegExp(m_fileName, regExp) && !MatchesRegExp(item.GetPlayablePath(), regExp)) return;

CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: matches rule: %s", m_name.c_str());

Expand Down

0 comments on commit e34dc1d

Please sign in to comment.