Skip to content

Commit

Permalink
Add support for file based stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
phate89 committed Aug 4, 2015
1 parent 10dcb91 commit 00d3ad0
Show file tree
Hide file tree
Showing 20 changed files with 353 additions and 66 deletions.
14 changes: 12 additions & 2 deletions addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,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 @@ -2070,7 +2073,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
2 changes: 2 additions & 0 deletions project/VS2010Express/XBMC.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@
<ClCompile Include="..\..\xbmc\filesystem\DirectoryFactory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\DirectoryHistory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\DllLibCurl.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\EFileFile.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\File.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\FileCache.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\FavouritesDirectory.cpp" />
Expand Down Expand Up @@ -1140,6 +1141,7 @@
<ClInclude Include="..\..\xbmc\filesystem\DirectoryHistory.h" />
<ClInclude Include="..\..\xbmc\filesystem\DllLibCurl.h" />
<ClInclude Include="..\..\xbmc\filesystem\DllLibNfs.h" />
<ClInclude Include="..\..\xbmc\filesystem\EFileFile.h" />
<ClInclude Include="..\..\xbmc\filesystem\File.h" />
<ClInclude Include="..\..\xbmc\filesystem\FileDirectoryFactory.h" />
<ClInclude Include="..\..\xbmc\filesystem\FileFactory.h" />
Expand Down
6 changes: 6 additions & 0 deletions project/VS2010Express/XBMC.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,9 @@
<ClCompile Include="..\..\xbmc\filesystem\DllLibCurl.cpp">
<Filter>filesystem</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\filesystem\EFileFile.cpp">
<Filter>filesystem</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\filesystem\File.cpp">
<Filter>filesystem</Filter>
</ClCompile>
Expand Down Expand Up @@ -4902,6 +4905,9 @@
<ClInclude Include="..\..\xbmc\filesystem\DllLibNfs.h">
<Filter>filesystem</Filter>
</ClInclude>
<ClCompile Include="..\..\xbmc\filesystem\EFileFile.h">
<Filter>filesystem</Filter>
</ClCompile>
<ClInclude Include="..\..\xbmc\filesystem\File.h">
<Filter>filesystem</Filter>
</ClInclude>
Expand Down
6 changes: 6 additions & 0 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3304,6 +3304,12 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
CUtil::ClearSubtitles();
}

if (item.IsEFileStub())
{
if (!CGUIDialogPlayEject::ShowAndGetInput(item))
return PLAYBACK_CANCELED;
}

if (item.IsDiscStub())
{
#ifdef HAS_DVD_DRIVE
Expand Down
52 changes: 20 additions & 32 deletions xbmc/FileItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ bool CFileItem::IsFileFolder(EFileFolderType types) const
|| IsAPK()
|| IsZIP()
|| IsRAR()
|| IsEFileStub()
|| IsRSS()
|| IsType(".ogg|.oga|.nsf|.sid|.sap|.xsp")
#if defined(TARGET_ANDROID)
Expand Down Expand Up @@ -901,7 +902,18 @@ bool CFileItem::IsNFO() const

bool CFileItem::IsDiscImage() const
{
return URIUtils::HasExtension(m_strPath, ".img|.iso|.nrg");
switch (m_isDiscImage)
{
case 0:
if (URIUtils::IsDiscImage(m_strPath))
m_isDiscImage = 1;
else
m_isDiscImage = 2;
case 1:
return true;
default:
return false;
}
}

bool CFileItem::IsOpticalMediaFile() const
Expand Down Expand Up @@ -954,6 +966,11 @@ bool CFileItem::IsZIP() const
return URIUtils::IsZIP(m_strPath);
}

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

bool CFileItem::IsCBZ() const
{
return URIUtils::HasExtension(m_strPath, ".cbz");
Expand Down Expand Up @@ -1447,36 +1464,7 @@ void CFileItem::SetFromSong(const CSong &song)

std::string CFileItem::GetOpticalMediaPath() const
{
std::string path;
std::string dvdPath;
path = URIUtils::AddFileToFolder(GetPath(), "VIDEO_TS.IFO");
if (CFile::Exists(path))
dvdPath = path;
else
{
dvdPath = URIUtils::AddFileToFolder(GetPath(), "VIDEO_TS");
path = URIUtils::AddFileToFolder(dvdPath, "VIDEO_TS.IFO");
dvdPath.clear();
if (CFile::Exists(path))
dvdPath = path;
}
#ifdef HAVE_LIBBLURAY
if (dvdPath.empty())
{
path = URIUtils::AddFileToFolder(GetPath(), "index.bdmv");
if (CFile::Exists(path))
dvdPath = path;
else
{
dvdPath = URIUtils::AddFileToFolder(GetPath(), "BDMV");
path = URIUtils::AddFileToFolder(dvdPath, "index.bdmv");
dvdPath.clear();
if (CFile::Exists(path))
dvdPath = path;
}
}
#endif
return dvdPath;
return URIUtils::GetOpticalMediaPath(GetPath());
}

/*
Expand Down Expand Up @@ -2894,7 +2882,7 @@ std::string CFileItem::GetBaseMoviePath(bool bUseFolderNames) const
{
std::string name2(strMovieName);
URIUtils::GetParentPath(name2,strMovieName);
if (URIUtils::IsInArchive(m_strPath))
if (URIUtils::IsInArchive(m_strPath) || URIUtils::IsEFileStub(m_strPath))
{
std::string strArchivePath;
URIUtils::GetParentPath(strMovieName, strArchivePath);
Expand Down
3 changes: 3 additions & 0 deletions xbmc/FileItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ class CFileItem :
*/
bool IsVideo() const;

bool IsEFileStub() const;

bool IsDiscStub() const;

/*!
Expand Down Expand Up @@ -470,6 +472,7 @@ class CFileItem :
std::string m_strLockCode;
int m_iHasLock; // 0 - no lock 1 - lock, but unlocked 2 - locked
int m_iBadPwdCount;
mutable int m_isDiscImage;

void SetCueDocument(const CCueDocumentPtr& cuePtr);
void LoadEmbeddedCue();
Expand Down
9 changes: 9 additions & 0 deletions xbmc/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#include "osx/DarwinUtils.h"
#endif
#include "filesystem/File.h"
#include "filesystem/EfileFile.h"
#include "settings/MediaSettings.h"
#include "settings/Settings.h"
#include "utils/StringUtils.h"
Expand Down Expand Up @@ -1184,6 +1185,14 @@ int CUtil::GetMatchingSource(const std::string& strPath1, VECSOURCES& VECSOURCES
bool bDummy;
return GetMatchingSource(strPath, VECSOURCES, bDummy);
}
if (StringUtils::StartsWithNoCase(strPath, "efile://"))
{
// get the original file name since it contains the efile
strPath = CEFileFile::GetOriginalPath(CURL(strPath));
bIsSourceName = false;
bool bDummy;
return GetMatchingSource(strPath, VECSOURCES, bDummy);
}

CLog::Log(LOGDEBUG,"CUtil::GetMatchingSource: no matching source found for [%s]", strPath1.c_str());
}
Expand Down
3 changes: 3 additions & 0 deletions xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "dialogs/GUIDialogOK.h"
#include "guilib/GUIWindowManager.h"
#include "Application.h"
#include "filesystem/EfileFile.h"
#include "filesystem/MusicDatabaseFile.h"
#include "FileItem.h"
#include "utils/RegExp.h"
Expand Down Expand Up @@ -164,6 +165,8 @@ void CExternalPlayer::Process()
else
mainFile = URIUtils::AddFileToFolder(base.Get(), url.GetFileName());
}
if (url.IsProtocol("efile"))
mainFile = CEFileFile::GetTranslatedPath(url);
}

if (m_filenameReplacers.size() > 0)
Expand Down
72 changes: 51 additions & 21 deletions xbmc/dialogs/GUIDialogPlayEject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
*
*/

#include "Autorun.h"
#include "filesystem/EFileFile.h"
#include "GUIDialogPlayEject.h"
#include "guilib/GUIWindowManager.h"
#include "storage/MediaManager.h"
#include "URL.h"
#include "utils/log.h"
#include "utils/URIUtils.h"
#include "utils/Variant.h"
#include "utils/XMLUtils.h"

Expand All @@ -30,6 +34,11 @@
#define ID_BUTTON_PLAY 11
#define ID_BUTTON_EJECT 10

using namespace XFILE;

std::string stubOriginal;
bool isDisc;

CGUIDialogPlayEject::CGUIDialogPlayEject()
: CGUIDialogYesNo(WINDOW_DIALOG_PLAY_EJECT)
{
Expand All @@ -46,7 +55,7 @@ bool CGUIDialogPlayEject::OnMessage(CGUIMessage& message)
int iControl = message.GetSenderId();
if (iControl == ID_BUTTON_PLAY)
{
if (g_mediaManager.IsDiscInDrive())
if (CFile::Exists(stubOriginal))
{
m_bConfirmed = true;
Close();
Expand All @@ -56,7 +65,13 @@ bool CGUIDialogPlayEject::OnMessage(CGUIMessage& message)
}
if (iControl == ID_BUTTON_EJECT)
{
g_mediaManager.ToggleTray();
#ifdef HAS_DVD_DRIVE
if (isDisc)
g_mediaManager.ToggleTray();
else
#endif
Close();

return true;
}
}
Expand All @@ -66,14 +81,16 @@ bool CGUIDialogPlayEject::OnMessage(CGUIMessage& message)

void CGUIDialogPlayEject::FrameMove()
{
CONTROL_ENABLE_ON_CONDITION(ID_BUTTON_PLAY, g_mediaManager.IsDiscInDrive());
if (isDisc)
stubOriginal = URIUtils::GetOpticalMediaPath();
CONTROL_ENABLE_ON_CONDITION(ID_BUTTON_PLAY, CFile::Exists(stubOriginal));

CGUIDialogYesNo::FrameMove();
}

void CGUIDialogPlayEject::OnInitWindow()
{
if (g_mediaManager.IsDiscInDrive())
if (CFile::Exists(stubOriginal))
{
m_defaultControl = ID_BUTTON_PLAY;
}
Expand All @@ -89,10 +106,33 @@ void CGUIDialogPlayEject::OnInitWindow()
bool CGUIDialogPlayEject::ShowAndGetInput(const CFileItem & item,
unsigned int uiAutoCloseTime /* = 0 */)
{
// Make sure we're actually dealing with a Disc Stub
if (!item.IsDiscStub())
// Make sure we're actually dealing with a Stub
if (!item.IsEFileStub() && !item.IsDiscStub())
return false;

CURL stubUrl = item.GetURL();
isDisc = item.IsDiscStub();

int headingStr;
int line0Str;
int ejectButtonStr;

if (isDisc)
{
headingStr = 219;
line0Str = 429;
ejectButtonStr = 13391;
}
else
{
stubOriginal = CEFileFile::GetTranslatedPath(stubUrl);
if (CFile::Exists(stubOriginal))
return true;
headingStr = 295;
line0Str = 472;
ejectButtonStr = 13460;
}

// Create the dialog
CGUIDialogPlayEject * pDialog = (CGUIDialogPlayEject *)g_windowManager.
GetWindow(WINDOW_DIALOG_PLAY_EJECT);
Expand All @@ -101,30 +141,20 @@ bool CGUIDialogPlayEject::ShowAndGetInput(const CFileItem & item,

// Figure out Lines 1 and 2 of the dialog
std::string strLine1, strLine2;
CXBMCTinyXML discStubXML;
if (discStubXML.LoadFile(item.GetPath()))
{
TiXmlElement * pRootElement = discStubXML.RootElement();
if (!pRootElement || strcmpi(pRootElement->Value(), "discstub") != 0)
CLog::Log(LOGERROR, "Error loading %s, no <discstub> node", item.GetPath().c_str());
else
{
XMLUtils::GetString(pRootElement, "title", strLine1);
XMLUtils::GetString(pRootElement, "message", strLine2);
}
}
CEFileFile::GetMessages(stubUrl, strLine1, strLine2);


// Use the label for Line 1 if not defined
if (strLine1.empty())
strLine1 = item.GetLabel();

// Setup dialog parameters
pDialog->SetHeading(CVariant{219});
pDialog->SetLine(0, CVariant{429});
pDialog->SetHeading(CVariant{headingStr});
pDialog->SetLine(0, CVariant{line0Str});
pDialog->SetLine(1, CVariant{std::move(strLine1)});
pDialog->SetLine(2, CVariant{std::move(strLine2)});
pDialog->SetChoice(ID_BUTTON_PLAY - 10, 208);
pDialog->SetChoice(ID_BUTTON_EJECT - 10, 13391);
pDialog->SetChoice(ID_BUTTON_EJECT - 10, ejectButtonStr);
if (uiAutoCloseTime)
pDialog->SetAutoClose(uiAutoCloseTime);

Expand Down
Loading

0 comments on commit 00d3ad0

Please sign in to comment.