Skip to content

Commit

Permalink
Merge branch 'mythsystem-rewrite'
Browse files Browse the repository at this point in the history
  • Loading branch information
Beirdo committed Jan 2, 2011
2 parents eab21fb + fceaa99 commit 0f063f5
Show file tree
Hide file tree
Showing 115 changed files with 3,340 additions and 1,857 deletions.
2 changes: 2 additions & 0 deletions README
@@ -0,0 +1,2 @@
Empty README.

18 changes: 9 additions & 9 deletions mythplugins/mytharchive/mytharchive/archiveutil.cpp
Expand Up @@ -20,6 +20,8 @@ using namespace std;
#include <mythmainwindow.h>
#include <mythdialogbox.h>
#include <util.h>
#include <mythsystem.h>
#include <exitcodes.h>

// mytharchive
#include "archiveutil.h"
Expand Down Expand Up @@ -102,7 +104,7 @@ void checkTempDirectory()
if (!dir.exists())
{
dir.mkdir(tempDir);
if( !chmod(qPrintable(tempDir), 0777) )
if( chmod(qPrintable(tempDir), 0777) )
VERBOSE(VB_IMPORTANT, QString("Failed to change permissions on archive directory: %1")
.arg(strerror(errno)));
}
Expand All @@ -111,7 +113,7 @@ void checkTempDirectory()
if (!dir.exists())
{
dir.mkdir(workDir);
if( !chmod(qPrintable(workDir), 0777) )
if( chmod(qPrintable(workDir), 0777) )
VERBOSE(VB_IMPORTANT, QString("Failed to change permissions on archive work directory: %1")
.arg(strerror(errno)));
}
Expand All @@ -120,7 +122,7 @@ void checkTempDirectory()
if (!dir.exists())
{
dir.mkdir(logDir);
if( !chmod(qPrintable(logDir), 0777) )
if( chmod(qPrintable(logDir), 0777) )
VERBOSE(VB_IMPORTANT, QString("Failed to change permissions on archive log directory: %1")
.arg(strerror(errno)));

Expand All @@ -129,7 +131,7 @@ void checkTempDirectory()
if (!dir.exists())
{
dir.mkdir(configDir);
if( !chmod(qPrintable(configDir), 0777) )
if( chmod(qPrintable(configDir), 0777) )
VERBOSE(VB_IMPORTANT, QString("Failed to change permissions on archive config directory: %1")
.arg(strerror(errno)));
}
Expand Down Expand Up @@ -233,16 +235,14 @@ bool getFileDetails(ArchiveItem *a)
inFile.replace("\"", "\\\"");
inFile.replace("`", "\\`");

QString outFile = tempDir + "/work/file.xml";
QString outFile = tempDir + "work/file.xml";

// call mytharchivehelper to get files stream info etc.
QString command = QString("mytharchivehelper -i \"%1\" \"%2\" %3 > /dev/null 2>&1")
.arg(inFile).arg(outFile).arg(lenMethod);

int res = system(qPrintable(command));
if (WIFEXITED(res))
res = WEXITSTATUS(res);
if (res != 0)
uint flags = kMSDontBlockInputDevs | kMSDontDisableDrawing;
if (myth_system(command, flags) != GENERIC_EXIT_OK)
return false;

QDomDocument doc("mydocument");
Expand Down
16 changes: 9 additions & 7 deletions mythplugins/mytharchive/mytharchive/exportnative.cpp
Expand Up @@ -22,6 +22,8 @@
#include <mythuibuttonlist.h>
#include <mythuiprogressbar.h>
#include <mythmainwindow.h>
#include <mythsystem.h>
#include <exitcodes.h>

// mytharchive
#include "exportnative.h"
Expand Down Expand Up @@ -464,17 +466,17 @@ void ExportNative::runScript()
commandline = "mytharchivehelper -n " + configDir + "/mydata.xml"; // job file
commandline += " > " + logDir + "/progress.log 2>&1 &"; // Logs

int state = system(qPrintable(commandline));

if (state != 0)
uint flags = kMSRunBackground | kMSDontBlockInputDevs |
kMSDontDisableDrawing;
uint retval = myth_system(commandline, flags);
if (retval != GENERIC_EXIT_RUNNING && retval != GENERIC_EXIT_OK)
{
ShowOkPopup(QObject::tr("It was not possible to create the DVD. "
"An error occured when running the scripts") );
return;
}
else
{
showLogViewer();
}

showLogViewer();
}

void ExportNative::handleAddRecording()
Expand Down
13 changes: 8 additions & 5 deletions mythplugins/mytharchive/mytharchive/importnative.cpp
Expand Up @@ -16,6 +16,8 @@
#include <mythuibutton.h>
#include <mythuibuttonlist.h>
#include <mythdialogbox.h>
#include <mythsystem.h>
#include <exitcodes.h>

// mytharchive
#include "importnative.h"
Expand Down Expand Up @@ -426,16 +428,17 @@ void ImportNative::finishedPressed()
commandline = "mytharchivehelper -f \"" + m_xmlFile + "\" " + chanID;
commandline += " > " + logDir + "/progress.log 2>&1 &";

int state = system(qPrintable(commandline));

if (state != 0)
uint flags = kMSRunBackground | kMSDontBlockInputDevs |
kMSDontDisableDrawing;
uint retval = myth_system(commandline, flags);
if (retval != GENERIC_EXIT_RUNNING && retval != GENERIC_EXIT_OK)
{
ShowOkPopup(tr("It was not possible to import the Archive. "
" An error occured when running 'mytharchivehelper'") );
return;
}
else
showLogViewer();

showLogViewer();

m_previousScreen->Close();
Close();
Expand Down
8 changes: 5 additions & 3 deletions mythplugins/mytharchive/mytharchive/logviewer.cpp
Expand Up @@ -153,12 +153,14 @@ void LogViewer::updateLogItem(MythUIButtonListItem *item)
void LogViewer::cancelClicked(void)
{
QString tempDir = gCoreContext->GetSetting("MythArchiveTempDir", "");
QFile lockFile(tempDir + "/logs/mythburncancel.lck");

QString command("echo Cancel > " + tempDir + "/logs/mythburncancel.lck");
int res = system(qPrintable(command));
if (WIFEXITED(res) == 0)
if (!lockFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
VERBOSE(VB_IMPORTANT, "LogViewer: Failed to create mythburncancel.lck file");

lockFile.write("Cancel\n\r");
lockFile.close();

ShowOkPopup(QObject::tr("Background creation has been asked to stop.\n"
"This may take a few minutes."));
}
Expand Down
26 changes: 15 additions & 11 deletions mythplugins/mytharchive/mytharchive/mythburn.cpp
Expand Up @@ -25,6 +25,9 @@
#include <mythuicheckbox.h>
#include <mythuibuttonlist.h>
#include <mythuiprogressbar.h>
#include <util.h>
#include <mythsystem.h>
#include <exitcodes.h>

// mytharchive
#include "archiveutil.h"
Expand All @@ -36,6 +39,8 @@
#include "videoselector.h"
#include "logviewer.h"

using namespace std;

MythBurn::MythBurn(MythScreenStack *parent,
MythScreenType *destinationScreen,
MythScreenType *themeScreen,
Expand All @@ -49,12 +54,8 @@ MythBurn::MythBurn(MythScreenStack *parent,
// remove any old thumb images
QString thumbDir = getTempDirectory() + "/config/thumbs";
QDir dir(thumbDir);
if (dir.exists())
{
int res = system(qPrintable("rm -rf " + thumbDir));
if (!WIFEXITED(res) || WEXITSTATUS(res))
VERBOSE(VB_IMPORTANT, "MythBurn: Failed to clear thumb directory");
}
if (dir.exists() && !RemoveDirectory(dir))
VERBOSE(VB_IMPORTANT, "MythBurn: Failed to clear thumb directory");

m_bCreateISO = false;
m_bDoBurn = false;
Expand Down Expand Up @@ -942,9 +943,10 @@ void MythBurn::runScript()

gCoreContext->SaveSetting("MythArchiveLastRunStatus", "Running");

int state = system(qPrintable(commandline));

if (state != 0)
uint flags = kMSRunBackground | kMSDontBlockInputDevs |
kMSDontDisableDrawing;
uint retval = myth_system(commandline, flags);
if (retval != GENERIC_EXIT_RUNNING && retval != GENERIC_EXIT_OK)
{
ShowOkPopup(tr("It was not possible to create the DVD. "
" An error occured when running the scripts"));
Expand Down Expand Up @@ -1195,9 +1197,11 @@ void BurnMenu::doBurn(int mode)
commandline = "mytharchivehelper -b " + sArchiveFormat +
" " + sEraseDVDRW + " " + sNativeFormat;
commandline += " > " + logDir + "/progress.log 2>&1 &";
int state = system(qPrintable(commandline));

if (state != 0)
uint flags = kMSRunBackground | kMSDontBlockInputDevs |
kMSDontDisableDrawing;
uint retval = myth_system(commandline, flags);
if (retval != GENERIC_EXIT_RUNNING && retval != GENERIC_EXIT_OK)
{
showWarningDialog(QObject::tr("It was not possible to run "
"mytharchivehelper to burn the DVD."));
Expand Down
2 changes: 1 addition & 1 deletion mythplugins/mytharchive/mytharchive/recordingselector.cpp
Expand Up @@ -116,7 +116,7 @@ bool RecordingSelector::Create(void)

void RecordingSelector::Init(void)
{
QString message = tr("Retrieving Recording List.\nPlease Wait...");
QString message = tr("Retrieving Recording List. Please Wait...");

MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");

Expand Down
10 changes: 4 additions & 6 deletions mythplugins/mytharchive/mytharchive/thumbfinder.cpp
Expand Up @@ -352,22 +352,20 @@ QString ThumbFinder::createThumbDir(void)
if (!dir.exists())
{
dir.mkdir(thumbDir);
if( !chmod(qPrintable(thumbDir), 0777) )
if( chmod(qPrintable(thumbDir), 0777) )
VERBOSE(VB_IMPORTANT, QString("ThumbFinder: Failed to change permissions on thumb directory: %1")
.arg(strerror(errno)));
}

int x = 0;
QString path;
do
for (int x = 1; dir.exists(); x++)
{
x++;
path = QString(thumbDir + "/%1").arg(x);
dir.setPath(path);
} while (dir.exists());
}

dir.mkdir(path);
if( !chmod(qPrintable(path), 0777) )
if( chmod(qPrintable(path), 0777) )
VERBOSE(VB_IMPORTANT, QString("ThumbFinder: Failed to change permissions on thumb directory: %1")
.arg(strerror(errno)));

Expand Down
93 changes: 72 additions & 21 deletions mythplugins/mytharchive/mytharchive/videoselector.cpp
Expand Up @@ -28,12 +28,8 @@ VideoSelector::VideoSelector(MythScreenStack *parent, QList<ArchiveItem *> *arch
:MythScreenType(parent, "VideoSelector")
{
m_archiveList = archiveList;
m_currentParentalLevel = ParentalLevel::plNone;
m_currentParentalLevel = 1;
m_videoList = NULL;

m_parentalLevelChecker = new ParentalLevelChangeChecker();
connect(m_parentalLevelChecker, SIGNAL(SigResultReady(bool, ParentalLevel::Level)),
this, SLOT(parentalLevelChanged(bool, ParentalLevel::Level)));
}

VideoSelector::~VideoSelector(void)
Expand All @@ -44,8 +40,6 @@ VideoSelector::~VideoSelector(void)
while (!m_selectedList.isEmpty())
delete m_selectedList.takeFirst();
m_selectedList.clear();

delete m_parentalLevelChecker;
}

bool VideoSelector::Create(void)
Expand Down Expand Up @@ -92,8 +86,6 @@ bool VideoSelector::Create(void)

SetFocusWidget(m_videoButtonList);

setParentalLevel(ParentalLevel::plLowest);

updateSelectedList();
updateVideoList();

Expand All @@ -120,19 +112,19 @@ bool VideoSelector::keyPressEvent(QKeyEvent *event)
}
else if (action == "1")
{
setParentalLevel(ParentalLevel::plLowest);
setParentalLevel(1);
}
else if (action == "2")
{
setParentalLevel(ParentalLevel::plLow);
setParentalLevel(2);
}
else if (action == "3")
{
setParentalLevel(ParentalLevel::plMedium);
setParentalLevel(3);
}
else if (action == "4")
{
setParentalLevel(ParentalLevel::plHigh);
setParentalLevel(4);
}
else
handled = false;
Expand Down Expand Up @@ -529,20 +521,79 @@ void VideoSelector::updateSelectedList()
}
}

void VideoSelector::setParentalLevel(ParentalLevel::Level level)
void VideoSelector::setParentalLevel(int which_level)
{
m_parentalLevelChecker->Check(m_currentParentalLevel, level);
if (which_level < 1)
which_level = 1;

if (which_level > 4)
which_level = 4;

if ((which_level > m_currentParentalLevel) && !checkParentPassword())
which_level = m_currentParentalLevel;


if (m_currentParentalLevel != which_level)
{
m_currentParentalLevel = which_level;
updateVideoList();
m_plText->SetText(QString::number(which_level));
}
}

void VideoSelector::parentalLevelChanged(bool passwordValid, ParentalLevel::Level newLevel)
bool VideoSelector::checkParentPassword()
{
if (passwordValid)
QDateTime curr_time = QDateTime::currentDateTime();
QString last_time_stamp = gCoreContext->GetSetting("VideoPasswordTime");
QString password = gCoreContext->GetSetting("VideoAdminPassword");
if (password.length() < 1)
{
m_currentParentalLevel = newLevel;
updateVideoList();
m_plText->SetText(QString::number(newLevel));
return true;
}

// See if we recently (and succesfully) asked for a password
if (last_time_stamp.length() < 1)
{
// Probably first time used
}
else
ShowOkPopup(tr("You need to enter a valid password for this parental level"));
{
QDateTime last_time = QDateTime::fromString(last_time_stamp,
Qt::TextDate);
if (last_time.secsTo(curr_time) < 120)
{
// Two minute window
last_time_stamp = curr_time.toString(Qt::TextDate);
gCoreContext->SetSetting("VideoPasswordTime", last_time_stamp);
gCoreContext->SaveSetting("VideoPasswordTime", last_time_stamp);
return true;
}
}

// See if there is a password set
if (password.length() > 0)
{
bool ok = false;
MythPasswordDialog *pwd = new MythPasswordDialog(tr("Parental Pin:"),
&ok,
password,
GetMythMainWindow());
pwd->exec();
pwd->deleteLater();
if (ok)
{
// All is good
last_time_stamp = curr_time.toString(Qt::TextDate);
gCoreContext->SetSetting("VideoPasswordTime", last_time_stamp);
gCoreContext->SaveSetting("VideoPasswordTime", last_time_stamp);
return true;
}
}
else
{
return true;
}

return false;
}

0 comments on commit 0f063f5

Please sign in to comment.