Skip to content

Commit

Permalink
Merge branch 'HarryMuscle-DiscStub'
Browse files Browse the repository at this point in the history
* HarryMuscle-DiscStub:
  Improve handling of stub files for systems with no DVD drive
  Add second line to the PlayEject dialog
  Add second line to the PlayEject dialog
  • Loading branch information
Jonathan Marshall committed Apr 13, 2011
2 parents cd956c0 + 112d239 commit 92f5c61
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 27 deletions.
22 changes: 5 additions & 17 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
#include "guilib/GUIControlFactory.h"
#include "dialogs/GUIDialogCache.h"
#include "dialogs/GUIDialogPlayEject.h"
#include "utils/XMLUtils.h"
#include "addons/AddonInstaller.h"

#ifdef HAS_PERFORMANCE_SAMPLE
Expand Down Expand Up @@ -3556,28 +3557,15 @@ bool CApplication::PlayFile(const CFileItem& item, bool bRestart)
CUtil::ClearSubtitles();
}

#ifdef HAS_DVD_DRIVE
if (item.IsDiscStub())
{
// Figure out Line 1 of the dialog
CStdString strLine1;
if (item.GetVideoInfoTag())
{
strLine1 = item.GetVideoInfoTag()->m_strTitle;
}
else
{
strLine1 = URIUtils::GetFileName(item.m_strPath);
URIUtils::RemoveExtension(strLine1);
}

#ifdef HAS_DVD_DRIVE
// Display the Play Eject dialog
if (CGUIDialogPlayEject::ShowAndGetInput(219, 429, strLine1, NULL))
MEDIA_DETECT::CAutorun::PlayDisc();

if (CGUIDialogPlayEject::ShowAndGetInput(item))
return MEDIA_DETECT::CAutorun::PlayDisc();
#endif
return true;
}
#endif

if (item.IsPlayList())
return false;
Expand Down
48 changes: 40 additions & 8 deletions xbmc/dialogs/GUIDialogPlayEject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include "guilib/GUIWindowManager.h"
#include "storage/MediaManager.h"
#include "storage/IoSupport.h"
#include "utils/log.h"
#include "utils/URIUtils.h"
#include "utils/XMLUtils.h"
#include "video/VideoInfoTag.h"

#define ID_BUTTON_PLAY 11
#define ID_BUTTON_EJECT 10
Expand Down Expand Up @@ -84,26 +88,54 @@ void CGUIDialogPlayEject::OnInitWindow()
CGUIDialogYesNo::OnInitWindow();
}

bool CGUIDialogPlayEject::ShowAndGetInput(CVariant vHeading, CVariant vLine0,
CVariant vLine1, CVariant vLine2, unsigned int uiAutoCloseTime /* = 0 */)
bool CGUIDialogPlayEject::ShowAndGetInput(const CFileItem & item,
unsigned int uiAutoCloseTime /* = 0 */)
{
// Make sure we're actually dealing with a Disc Stub
if (!item.IsDiscStub())
return false;

// Create the dialog
CGUIDialogPlayEject * pDialog = (CGUIDialogPlayEject *)g_windowManager.
GetWindow(WINDOW_DIALOG_PLAY_EJECT);

if (!pDialog)
return false;

pDialog->SetHeading(vHeading);
pDialog->SetLine(0, vLine0);
pDialog->SetLine(1, vLine1);
pDialog->SetLine(2, vLine2);
// Figure out Line 1 of the dialog
CStdString strLine1;
if (item.GetVideoInfoTag())
{
strLine1 = item.GetVideoInfoTag()->m_strTitle;
}
else
{
strLine1 = URIUtils::GetFileName(item.m_strPath);
URIUtils::RemoveExtension(strLine1);
}

// Figure out Line 2 of the dialog
CStdString strLine2;
TiXmlDocument discStubXML;
if (discStubXML.LoadFile(item.m_strPath))
{
TiXmlElement * pRootElement = discStubXML.RootElement();
if (!pRootElement || strcmpi(pRootElement->Value(), "discstub") != 0)
CLog::Log(LOGERROR, "Error loading %s, no <discstub> node", item.m_strPath.c_str());
else
XMLUtils::GetString(pRootElement, "message", strLine2);
}

// Setup dialog parameters
pDialog->SetHeading(219);
pDialog->SetLine(0, 429);
pDialog->SetLine(1, strLine1);
pDialog->SetLine(2, strLine2);
pDialog->SetChoice(ID_BUTTON_PLAY - 10, 208);
pDialog->SetChoice(ID_BUTTON_EJECT - 10, 13391);

if (uiAutoCloseTime)
pDialog->SetAutoClose(uiAutoCloseTime);

// Display the dialog
pDialog->DoModal();

return pDialog->IsConfirmed();
Expand Down
4 changes: 2 additions & 2 deletions xbmc/dialogs/GUIDialogPlayEject.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*
*/

#include "FileItem.h"
#include "GUIDialogYesNo.h"
#include "utils/Variant.h"

Expand All @@ -31,8 +32,7 @@ class CGUIDialogPlayEject : public CGUIDialogYesNo
virtual bool OnMessage(CGUIMessage& message);
virtual void FrameMove();

static bool ShowAndGetInput(CVariant vHeading, CVariant vLine0, CVariant vLine1,
CVariant vLine2, unsigned int uiAutoCloseTime = 0);
static bool ShowAndGetInput(const CFileItem & item, unsigned int uiAutoCloseTime = 0);

protected:
virtual void OnInitWindow();
Expand Down

0 comments on commit 92f5c61

Please sign in to comment.