diff --git a/mythplugins/mytharchive/mytharchive/archiveutil.cpp b/mythplugins/mytharchive/mytharchive/archiveutil.cpp index f1fdf4a8cb2..5ec843ef685 100644 --- a/mythplugins/mytharchive/mytharchive/archiveutil.cpp +++ b/mythplugins/mytharchive/mytharchive/archiveutil.cpp @@ -20,7 +20,7 @@ using namespace std; #include #include #include -#include +#include #include #include diff --git a/mythplugins/mytharchive/mytharchive/exportnative.cpp b/mythplugins/mytharchive/mytharchive/exportnative.cpp index 7420a48f6ed..222e49b72fc 100644 --- a/mythplugins/mytharchive/mytharchive/exportnative.cpp +++ b/mythplugins/mytharchive/mytharchive/exportnative.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include // mytharchive diff --git a/mythplugins/mytharchive/mytharchive/importnative.cpp b/mythplugins/mytharchive/mytharchive/importnative.cpp index b180675322e..33b80bbc322 100644 --- a/mythplugins/mytharchive/mytharchive/importnative.cpp +++ b/mythplugins/mytharchive/mytharchive/importnative.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include diff --git a/mythplugins/mytharchive/mytharchive/main.cpp b/mythplugins/mytharchive/mytharchive/main.cpp index b97ae2512bf..5c37077f612 100644 --- a/mythplugins/mytharchive/mytharchive/main.cpp +++ b/mythplugins/mytharchive/mytharchive/main.cpp @@ -22,7 +22,7 @@ using namespace std; #include #include #include -#include +#include #include #include #include diff --git a/mythplugins/mytharchive/mytharchive/mythburn.cpp b/mythplugins/mytharchive/mytharchive/mythburn.cpp index 8463da063d7..ea4f58a93a0 100644 --- a/mythplugins/mytharchive/mytharchive/mythburn.cpp +++ b/mythplugins/mytharchive/mytharchive/mythburn.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include diff --git a/mythplugins/mytharchive/mytharchivehelper/main.cpp b/mythplugins/mytharchive/mytharchivehelper/main.cpp index df4b201782b..492ca1881ee 100644 --- a/mythplugins/mytharchive/mytharchivehelper/main.cpp +++ b/mythplugins/mytharchive/mytharchivehelper/main.cpp @@ -62,7 +62,7 @@ using namespace std; #include #include #include -#include +#include #include #include diff --git a/mythplugins/mythbrowser/mythbrowser/bookmarkmanager.cpp b/mythplugins/mythbrowser/mythbrowser/bookmarkmanager.cpp index 40874859d17..1f7e5c9145d 100644 --- a/mythplugins/mythbrowser/mythbrowser/bookmarkmanager.cpp +++ b/mythplugins/mythbrowser/mythbrowser/bookmarkmanager.cpp @@ -12,7 +12,7 @@ using namespace std; #include #include #include -#include +#include // mythbrowser #include "bookmarkmanager.h" diff --git a/mythplugins/mythgallery/dcrawplugin/dcrawhandler.cpp b/mythplugins/mythgallery/dcrawplugin/dcrawhandler.cpp index 511c13b5c95..b0899e8223a 100644 --- a/mythplugins/mythgallery/dcrawplugin/dcrawhandler.cpp +++ b/mythplugins/mythgallery/dcrawplugin/dcrawhandler.cpp @@ -10,7 +10,7 @@ #include #include -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #include "../mythgallery/galleryutil.h" #include "mythlogging.h" @@ -64,7 +64,7 @@ bool DcrawHandler::read(QImage *image) arguments << path; uint flags = kMSRunShell | kMSStdOut | kMSBuffered; - MythSystem ms("dcraw", arguments, flags); + MythSystemLegacy ms("dcraw", arguments, flags); ms.Run(); if (ms.Wait() != GENERIC_EXIT_OK) return false; @@ -84,7 +84,7 @@ int DcrawHandler::loadThumbnail(QImage *image, QString fileName) arguments << "'" + fileName + "'"; uint flags = kMSRunShell | kMSStdOut | kMSBuffered; - MythSystem ms("dcraw", arguments, flags); + MythSystemLegacy ms("dcraw", arguments, flags); ms.Run(); if (ms.Wait() != GENERIC_EXIT_OK) return -1; diff --git a/mythplugins/mythgallery/mythgallery/iconview.cpp b/mythplugins/mythgallery/mythgallery/iconview.cpp index 93c2078a57e..d811333fe3b 100644 --- a/mythplugins/mythgallery/mythgallery/iconview.cpp +++ b/mythplugins/mythgallery/mythgallery/iconview.cpp @@ -37,7 +37,7 @@ using namespace std; // MythTV headers #include #include -#include +#include #include #include #include diff --git a/mythplugins/mythgallery/mythgallery/thumbgenerator.cpp b/mythplugins/mythgallery/mythgallery/thumbgenerator.cpp index cb01522f3fb..bf3fff09358 100644 --- a/mythplugins/mythgallery/mythgallery/thumbgenerator.cpp +++ b/mythplugins/mythgallery/mythgallery/thumbgenerator.cpp @@ -39,7 +39,7 @@ #include "config.h" #include "thumbgenerator.h" #include "galleryutil.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #include "mythlogging.h" @@ -304,7 +304,7 @@ void ThumbGenerator::loadFile(QImage& image, const QFileInfo& fi) args << "--infile" << '"' + fi.absoluteFilePath() + '"'; args << "--outfile" << '"' + tmpDir.filePath(thumbFile) + '"'; - MythSystem ms(cmd, args, kMSRunShell); + MythSystemLegacy ms(cmd, args, kMSRunShell); ms.SetDirectory(tmpDir.absolutePath()); ms.Run(); if (ms.Wait() == GENERIC_EXIT_OK) diff --git a/mythplugins/mythgame/mythgame/gamehandler.cpp b/mythplugins/mythgame/mythgame/gamehandler.cpp index 54d873d11d1..f8c3de25099 100644 --- a/mythplugins/mythgame/mythgame/gamehandler.cpp +++ b/mythplugins/mythgame/mythgame/gamehandler.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/mythplugins/mythmusic/mythmusic/cdrip.cpp b/mythplugins/mythmusic/mythmusic/cdrip.cpp index bf43e40df42..75cfa34f5bc 100644 --- a/mythplugins/mythmusic/mythmusic/cdrip.cpp +++ b/mythplugins/mythmusic/mythmusic/cdrip.cpp @@ -39,7 +39,7 @@ using namespace std; #include #include #include -#include +#include // MythUI headers #include diff --git a/mythplugins/mythmusic/mythmusic/playlist.cpp b/mythplugins/mythmusic/mythmusic/playlist.cpp index d7d45a0c7e4..953619d1f7d 100644 --- a/mythplugins/mythmusic/mythmusic/playlist.cpp +++ b/mythplugins/mythmusic/mythmusic/playlist.cpp @@ -24,7 +24,7 @@ using namespace std; #include #include #include -#include +#include #include const char *kID0err = "Song with ID of 0 in playlist, this shouldn't happen."; @@ -1336,7 +1336,7 @@ int Playlist::CreateCDMP3(void) kMSDontDisableDrawing | kMSDontBlockInputDevs | kMSRunBackground; - m_proc = new MythSystem(command, args, flags); + m_proc = new MythSystemLegacy(command, args, flags); connect(m_proc, SIGNAL(readDataReady(int)), this, SLOT(mkisofsData(int)), Qt::DirectConnection); @@ -1387,7 +1387,7 @@ int Playlist::CreateCDMP3(void) kMSDontDisableDrawing | kMSDontBlockInputDevs | kMSRunBackground; - m_proc = new MythSystem(command, args, flags); + m_proc = new MythSystemLegacy(command, args, flags); connect(m_proc, SIGNAL(readDataReady(int)), this, SLOT(cdrecordData(int)), Qt::DirectConnection); connect(m_proc, SIGNAL(finished()), diff --git a/mythplugins/mythmusic/mythmusic/playlist.h b/mythplugins/mythmusic/mythmusic/playlist.h index 67298be299d..0a17e2cd319 100644 --- a/mythplugins/mythmusic/mythmusic/playlist.h +++ b/mythplugins/mythmusic/mythmusic/playlist.h @@ -13,7 +13,7 @@ class PlaylistContainer; class Playlist; -class MythSystem; +class MythSystemLegacy; enum InsertPLOption { @@ -129,7 +129,7 @@ class Playlist : public QObject bool m_changed; bool m_doSave; MythProgressDialog *m_progress; - MythSystem *m_proc; + MythSystemLegacy *m_proc; uint m_procExitVal; }; diff --git a/mythplugins/mythnetvision/mythnetvision/netsearch.cpp b/mythplugins/mythnetvision/mythnetvision/netsearch.cpp index 83e6cc564f3..e8c0fbe4bd3 100644 --- a/mythplugins/mythnetvision/mythnetvision/netsearch.cpp +++ b/mythplugins/mythnetvision/mythnetvision/netsearch.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/mythplugins/mythnetvision/mythnetvision/nettree.cpp b/mythplugins/mythnetvision/mythnetvision/nettree.cpp index 7e7843f0e98..817de26a304 100644 --- a/mythplugins/mythnetvision/mythnetvision/nettree.cpp +++ b/mythplugins/mythnetvision/mythnetvision/nettree.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/mythplugins/mythnews/mythnews/mythnews.cpp b/mythplugins/mythnews/mythnews/mythnews.cpp index 815e06395ec..cebca4e43d5 100644 --- a/mythplugins/mythnews/mythnews/mythnews.cpp +++ b/mythplugins/mythnews/mythnews/mythnews.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/mythplugins/mythweather/mythweather/weatherSource.cpp b/mythplugins/mythweather/mythweather/weatherSource.cpp index 3d2d2ffc634..271f8f1a0d2 100644 --- a/mythplugins/mythweather/mythweather/weatherSource.cpp +++ b/mythplugins/mythweather/mythweather/weatherSource.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include // MythWeather headers @@ -29,7 +29,7 @@ QStringList WeatherSource::ProbeTypes(QString workingDirectory, uint flags = kMSRunShell | kMSStdOut | kMSBuffered | kMSDontDisableDrawing | kMSDontBlockInputDevs; - MythSystem ms(program, arguments, flags); + MythSystemLegacy ms(program, arguments, flags); ms.SetDirectory(workingDirectory); ms.Run(); if (ms.Wait() != GENERIC_EXIT_OK) @@ -72,7 +72,7 @@ bool WeatherSource::ProbeTimeouts(QString workingDirectory, uint flags = kMSRunShell | kMSStdOut | kMSBuffered | kMSDontDisableDrawing | kMSDontBlockInputDevs; - MythSystem ms(program, arguments, flags); + MythSystemLegacy ms(program, arguments, flags); ms.SetDirectory(workingDirectory); ms.Run(); if (ms.Wait() != GENERIC_EXIT_OK) @@ -135,7 +135,7 @@ bool WeatherSource::ProbeInfo(ScriptInfo &info) uint flags = kMSRunShell | kMSStdOut | kMSBuffered | kMSDontDisableDrawing | kMSDontBlockInputDevs; - MythSystem ms(info.program, arguments, flags); + MythSystemLegacy ms(info.program, arguments, flags); ms.SetDirectory(info.path); ms.Run(); if (ms.Wait() != GENERIC_EXIT_OK) @@ -385,7 +385,7 @@ QStringList WeatherSource::getLocationList(const QString &str) uint flags = kMSRunShell | kMSStdOut | kMSBuffered | kMSDontDisableDrawing | kMSDontBlockInputDevs; - MythSystem ms(program, args, flags); + MythSystemLegacy ms(program, args, flags); ms.SetDirectory(m_info->path); ms.Run(); @@ -487,7 +487,7 @@ void WeatherSource::startUpdate(bool forceUpdate) uint flags = kMSRunShell | kMSStdOut | kMSBuffered | kMSRunBackground | kMSDontDisableDrawing | kMSDontBlockInputDevs; - m_ms = new MythSystem(program, args, flags); + m_ms = new MythSystemLegacy(program, args, flags); m_ms->SetDirectory(m_info->path); connect(m_ms, SIGNAL(finished()), this, SLOT(processExit())); diff --git a/mythplugins/mythweather/mythweather/weatherSource.h b/mythplugins/mythweather/mythweather/weatherSource.h index 37c1b0aca59..3785fd8a056 100644 --- a/mythplugins/mythweather/mythweather/weatherSource.h +++ b/mythplugins/mythweather/mythweather/weatherSource.h @@ -5,7 +5,7 @@ #include #include #include -#include "mythsystem.h" +#include "mythsystemlegacy.h" // MythWeather headers #include "weatherUtils.h" @@ -90,7 +90,7 @@ class WeatherSource : public QObject bool m_ready; bool m_inuse; ScriptInfo *m_info; - MythSystem *m_ms; + MythSystemLegacy *m_ms; QString m_dir; QString m_locale; QString m_cachefile; diff --git a/mythtv/libs/libmyth/mediamonitor-unix.cpp b/mythtv/libs/libmyth/mediamonitor-unix.cpp index 7cb480c2eec..35e648764ab 100644 --- a/mythtv/libs/libmyth/mediamonitor-unix.cpp +++ b/mythtv/libs/libmyth/mediamonitor-unix.cpp @@ -40,7 +40,7 @@ using namespace std; #include "mythcdrom.h" #include "mythhdd.h" #include "mythlogging.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #if HAVE_LIBUDEV @@ -372,8 +372,8 @@ QString MediaMonitorUnix::GetDeviceFile(const QString &sysfs) if (VERBOSE_LEVEL_CHECK(VB_MEDIA, LOG_DEBUG)) flags |= kMSStdErr; - // TODO: change this to a MythSystem on the stack? - MythSystem *udevinfo = new MythSystem("udevinfo", args, flags); + // TODO: change this to a MythSystemLegacy on the stack? + MythSystemLegacy *udevinfo = new MythSystemLegacy("udevinfo", args, flags); udevinfo->Run(4); if( udevinfo->Wait() != GENERIC_EXIT_OK ) { diff --git a/mythtv/libs/libmyth/mythcontext.cpp b/mythtv/libs/libmyth/mythcontext.cpp index cff5044a2d3..ac1d90b9b07 100644 --- a/mythtv/libs/libmyth/mythcontext.cpp +++ b/mythtv/libs/libmyth/mythcontext.cpp @@ -36,7 +36,7 @@ using namespace std; #include "mythxmlclient.h" #include "upnp.h" #include "mythlogging.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythmiscutil.h" #include "mythplugin.h" diff --git a/mythtv/libs/libmyth/mythmediamonitor.cpp b/mythtv/libs/libmyth/mythmediamonitor.cpp index 3e3a168f3e1..90cef5fdead 100644 --- a/mythtv/libs/libmyth/mythmediamonitor.cpp +++ b/mythtv/libs/libmyth/mythmediamonitor.cpp @@ -23,7 +23,7 @@ using namespace std; #include "mythdate.h" #include "mythlogging.h" #include "mythmainwindow.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythmiscutil.h" #ifdef USING_DARWIN_DA diff --git a/mythtv/libs/libmyth/netgrabbermanager.cpp b/mythtv/libs/libmyth/netgrabbermanager.cpp index 5a64448bc59..8ffa514a5e2 100644 --- a/mythtv/libs/libmyth/netgrabbermanager.cpp +++ b/mythtv/libs/libmyth/netgrabbermanager.cpp @@ -6,11 +6,11 @@ #include "mythdirs.h" #include "mythcontext.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #include "mythdate.h" #include "mythlogging.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "netgrabbermanager.h" #include "netutils.h" @@ -50,7 +50,7 @@ void GrabberScript::run() QMutexLocker locker(&m_lock); QString commandline = m_commandline; - MythSystem getTree(commandline, QStringList("-T"), + MythSystemLegacy getTree(commandline, QStringList("-T"), kMSRunShell | kMSStdOut | kMSBuffered); getTree.Run(900); uint status = getTree.Wait(); @@ -264,7 +264,7 @@ void Search::executeSearch(const QString &script, const QString &query, uint pag resetSearch(); LOG(VB_GENERAL, LOG_DEBUG, "Search::executeSearch"); - m_searchProcess = new MythSystem(); + m_searchProcess = new MythSystemLegacy(); connect(m_searchProcess, SIGNAL(finished()), this, SLOT(slotProcessSearchExit())); @@ -283,7 +283,7 @@ void Search::executeSearch(const QString &script, const QString &query, uint pag args.append("-S"); QString term = query; - args.append(MythSystem::ShellEscape(term)); + args.append(MythSystemLegacy::ShellEscape(term)); LOG(VB_GENERAL, LOG_DEBUG, LOC + QString("Internet Search Query: %1 %2") .arg(cmd).arg(args.join(" "))); diff --git a/mythtv/libs/libmyth/netgrabbermanager.h b/mythtv/libs/libmyth/netgrabbermanager.h index 3ac3de7198e..c8b637804ae 100644 --- a/mythtv/libs/libmyth/netgrabbermanager.h +++ b/mythtv/libs/libmyth/netgrabbermanager.h @@ -11,7 +11,7 @@ #include "rssparse.h" #include "mythexp.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" class MPUBLIC GrabberScript : public QObject, public MThread { @@ -160,7 +160,7 @@ class MPUBLIC Search : public QObject private: - MythSystem *m_searchProcess; + MythSystemLegacy *m_searchProcess; QByteArray m_data; QDomDocument m_document; diff --git a/mythtv/libs/libmythbase/dbutil.cpp b/mythtv/libs/libmythbase/dbutil.cpp index e8fab216572..a564b8abb0b 100644 --- a/mythtv/libs/libmythbase/dbutil.cpp +++ b/mythtv/libs/libmythbase/dbutil.cpp @@ -20,7 +20,7 @@ #include "mythdb.h" #include "mythdirs.h" #include "mythlogging.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #define LOC QString("DBUtil: ") diff --git a/mythtv/libs/libmythbase/exitcodes.h b/mythtv/libs/libmythbase/exitcodes.h index ac28e9f1db3..795e15f28c3 100644 --- a/mythtv/libs/libmythbase/exitcodes.h +++ b/mythtv/libs/libmythbase/exitcodes.h @@ -24,7 +24,7 @@ #define GENERIC_EXIT_TIMEOUT 141 ///< Process timed out #define GENERIC_EXIT_RUNNING 142 ///< Process is running #define GENERIC_EXIT_PIPE_FAILURE 143 ///< Error creating I/O pipes -#define GENERIC_EXIT_NO_HANDLER 144 ///< No MythSystem Handler +#define GENERIC_EXIT_NO_HANDLER 144 ///< No MythSystemLegacy Handler #define GENERIC_EXIT_DAEMONIZING_ERROR 145 ///< Error daemonizing or execl #define GENERIC_EXIT_NO_RECORDING_DATA 146 ///< No program/recording data #define GENERIC_EXIT_REMOTE_FILE 147 ///< Can't transcode a remote file @@ -32,7 +32,7 @@ #define GENERIC_EXIT_WRITE_FRAME_ERROR 149 ///< Frame write error #define GENERIC_EXIT_DEADLOCK 150 ///< Transcode deadlock detected #define GENERIC_EXIT_IN_USE 151 ///< Recording in use, can't flag -#define GENERIC_EXIT_START 152 ///< MythSystem process starting +#define GENERIC_EXIT_START 152 ///< MythSystemLegacy process starting #define GENERIC_EXIT_DB_NOTIMEZONE 153 ///< Missing DB time zone support #endif // __MYTH_EXIT_CODES__ diff --git a/mythtv/libs/libmythbase/hardwareprofile.cpp b/mythtv/libs/libmythbase/hardwareprofile.cpp index 3c55c04dca6..0fb8455df60 100644 --- a/mythtv/libs/libmythbase/hardwareprofile.cpp +++ b/mythtv/libs/libmythbase/hardwareprofile.cpp @@ -9,7 +9,7 @@ #include "mythcorecontext.h" #include "mythdirs.h" #include "mythlogging.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #include "mythdate.h" @@ -51,7 +51,7 @@ void HardwareProfile::GenerateUUIDs(void) QString cmd = GetShareDir() + "hardwareprofile/sendProfile.py"; QStringList args; args << "-p"; - MythSystem system(cmd, args, kMSRunShell | kMSStdOut | kMSBuffered); + MythSystemLegacy system(cmd, args, kMSRunShell | kMSStdOut | kMSBuffered); system.Run(); system.Wait(); @@ -183,7 +183,7 @@ bool HardwareProfile::SubmitProfile(void) QStringList args; args << "--submitOnly"; args << "-a"; - MythSystem system(cmd, args, kMSRunShell | kMSStdOut | kMSBuffered); + MythSystemLegacy system(cmd, args, kMSRunShell | kMSStdOut | kMSBuffered); system.Run(); if (system.Wait() == GENERIC_EXIT_OK) @@ -212,7 +212,7 @@ bool HardwareProfile::DeleteProfile(void) QString cmd = GetShareDir() + "hardwareprofile/deleteProfile.py"; QStringList args; - MythSystem system(cmd, args, kMSRunShell | kMSStdOut | kMSBuffered); + MythSystemLegacy system(cmd, args, kMSRunShell | kMSStdOut | kMSBuffered); system.Run(); if (system.Wait() == GENERIC_EXIT_OK) @@ -246,7 +246,7 @@ QString HardwareProfile::GetHardwareProfile() const QString cmd = GetShareDir() + "hardwareprofile/sendProfile.py"; QStringList args; args << "-p"; - MythSystem system(cmd, args, kMSRunShell | kMSStdOut | kMSBuffered); + MythSystemLegacy system(cmd, args, kMSRunShell | kMSStdOut | kMSBuffered); system.Run(); system.Wait(); diff --git a/mythtv/libs/libmythbase/lcddevice.cpp b/mythtv/libs/libmythbase/lcddevice.cpp index b7fa7612275..68e9873f608 100644 --- a/mythtv/libs/libmythbase/lcddevice.cpp +++ b/mythtv/libs/libmythbase/lcddevice.cpp @@ -29,7 +29,7 @@ #include "mythdirs.h" #include "mythevent.h" #include "mythsocket.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" diff --git a/mythtv/libs/libmythbase/libmythbase.pro b/mythtv/libs/libmythbase/libmythbase.pro index 090ccfb3c31..8661f69fbb5 100644 --- a/mythtv/libs/libmythbase/libmythbase.pro +++ b/mythtv/libs/libmythbase/libmythbase.pro @@ -28,6 +28,7 @@ HEADERS += mythscheduler.h filesysteminfo.h hardwareprofile.h serverpool.h HEADERS += plist.h bswap.h signalhandling.h mythtimezone.h mythdate.h HEADERS += mythplugin.h mythpluginapi.h HEADERS += ffmpeg-mmx.h +HEADERS += mythsystemlegacy.h SOURCES += mthread.cpp mthreadpool.cpp SOURCES += mythsocket.cpp @@ -44,6 +45,7 @@ SOURCES += referencecounter.cpp mythcommandlineparser.cpp SOURCES += filesysteminfo.cpp hardwareprofile.cpp serverpool.cpp SOURCES += plist.cpp signalhandling.cpp mythtimezone.cpp mythdate.cpp SOURCES += mythplugin.cpp +SOURCES += mythsystemlegacy.cpp # This stuff is not Qt5 compatible.. contains(QT_VERSION, ^4\\.[0-9]\\..*) { @@ -76,7 +78,7 @@ inc.files += referencecounter.h mythcommandlineparser.h mthread.h mthreadpool.h inc.files += filesysteminfo.h hardwareprofile.h bonjourregister.h serverpool.h inc.files += plist.h bswap.h signalhandling.h ffmpeg-mmx.h mythdate.h inc.files += mythplugin.h mythpluginapi.h mythqtcompat.h -inc.files += remotefile.h +inc.files += remotefile.h mythsystemlegacy.h # This stuff is not Qt5 compatible.. contains(QT_VERSION, ^4\\.[0-9]\\..*) { diff --git a/mythtv/libs/libmythbase/logging.cpp b/mythtv/libs/libmythbase/logging.cpp index 6435e5aaa33..8c8b50781ab 100644 --- a/mythtv/libs/libmythbase/logging.cpp +++ b/mythtv/libs/libmythbase/logging.cpp @@ -22,7 +22,7 @@ using namespace std; #include "mythdb.h" #include "mythdirs.h" #include "mythcorecontext.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythsignalingtimer.h" #include "dbutil.h" #include "exitcodes.h" @@ -493,7 +493,7 @@ void LoggerThread::launchLogServer(void) QStringList args; args << "--daemon" << logPropagateArgs; - MythSystem ms(GetInstallPrefix() + "/bin/mythlogserver", args, mask); + MythSystemLegacy ms(GetInstallPrefix() + "/bin/mythlogserver", args, mask); ms.Run(); ms.Wait(0); } diff --git a/mythtv/libs/libmythbase/mythcorecontext.cpp b/mythtv/libs/libmythbase/mythcorecontext.cpp index ced85bf03dc..8894b90ae2c 100644 --- a/mythtv/libs/libmythbase/mythcorecontext.cpp +++ b/mythtv/libs/libmythbase/mythcorecontext.cpp @@ -31,7 +31,7 @@ using namespace std; #include "mythdownloadmanager.h" #include "mythcorecontext.h" #include "mythsocket.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mthreadpool.h" #include "exitcodes.h" #include "mythlogging.h" @@ -143,7 +143,7 @@ MythCoreContextPrivate::~MythCoreContextPrivate() MThreadPool::ShutdownAllPools(); - ShutdownMythSystem(); + ShutdownMythSystemLegacy(); ShutdownMythDownloadManager(); diff --git a/mythtv/libs/libmythbase/mythdbcon.cpp b/mythtv/libs/libmythbase/mythdbcon.cpp index 72f419282e7..5d6444895e5 100644 --- a/mythtv/libs/libmythbase/mythdbcon.cpp +++ b/mythtv/libs/libmythbase/mythdbcon.cpp @@ -17,7 +17,7 @@ #include "mythdb.h" #include "mythcorecontext.h" #include "mythlogging.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #include "mthread.h" #include "mythdate.h" diff --git a/mythtv/libs/libmythbase/mythmedia.cpp b/mythtv/libs/libmythbase/mythmedia.cpp index a15962ce773..8783042634a 100644 --- a/mythtv/libs/libmythbase/mythmedia.cpp +++ b/mythtv/libs/libmythbase/mythmedia.cpp @@ -16,7 +16,7 @@ #include "mythconfig.h" #include "mythlogging.h" #include "mythmiscutil.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" using namespace std; diff --git a/mythtv/libs/libmythbase/mythmiscutil.cpp b/mythtv/libs/libmythbase/mythmiscutil.cpp index ff8330acd5e..f02b004b176 100644 --- a/mythtv/libs/libmythbase/mythmiscutil.cpp +++ b/mythtv/libs/libmythbase/mythmiscutil.cpp @@ -49,7 +49,7 @@ using namespace std; #include "mythlogging.h" #include "mythsocket.h" #include "mythcoreutil.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythconfig.h" // for CONFIG_DARWIN diff --git a/mythtv/libs/libmythbase/mythsystem.cpp b/mythtv/libs/libmythbase/mythsystem.cpp index ae983fb0ec9..6f03f903b27 100644 --- a/mythtv/libs/libmythbase/mythsystem.cpp +++ b/mythtv/libs/libmythbase/mythsystem.cpp @@ -1,524 +1,213 @@ -/// -*- Mode: c++ -*- +// POSIX header +#include // for SIGXXX -// compat header -#include "compat.h" +// Qt headers +#include +#include -// Own header +// MythTV headers +#include "mythsystemlegacy.h" #include "mythsystem.h" - -// C++/C headers -#include -#include -#include -#include -#include -#include // for kill() and SIGXXX -#include - -// QT headers -#include - -// libmythbase headers -#include "referencecounter.h" -#include "mythcorecontext.h" -#include "mythevent.h" -#include "mythlogging.h" #include "exitcodes.h" -#if CONFIG_CYGWIN || defined(_WIN32) -#include "mythsystemwindows.h" -#else -#include "mythsystemunix.h" -#endif - - -/******************************* - * MythSystem method defines - ******************************/ - -void MythSystem::initializePrivate(void) -{ - m_nice = 0; - m_ioprio = 0; -#if CONFIG_CYGWIN || defined(_WIN32) - d = new MythSystemWindows(this); -#else - d = new MythSystemUnix(this); -#endif -} - -MythSystem::MythSystem() -{ - setObjectName("MythSystem()"); - m_semReady.release(1); // initialize - initializePrivate(); -} - -MythSystem::MythSystem(const QString &command, uint flags) -{ - setObjectName(QString("MythSystem(%1)").arg(command)); - m_semReady.release(1); // initialize - initializePrivate(); - SetCommand(command, flags); -} - -/** \fn MythSystem::setCommand(const QString &command) - * \brief Resets an existing MythSystem object to a new command - */ -void MythSystem::SetCommand(const QString &command, uint flags) -{ - if (flags & kMSRunShell) - { - SetCommand(command, QStringList(), flags); - } - else - { - QString abscommand; - QStringList args; - if (!d->ParseShell(command, abscommand, args)) - { - LOG(VB_GENERAL, LOG_ERR, - QString("MythSystem(%1) command not understood") - .arg(command)); - m_status = GENERIC_EXIT_INVALID_CMDLINE; - return; - } - - SetCommand(abscommand, args, flags); - } -} - - -MythSystem::MythSystem(const QString &command, - const QStringList &args, uint flags) -{ - m_semReady.release(1); // initialize - initializePrivate(); - SetCommand(command, args, flags); -} - -/** \fn MythSystem::setCommand(const QString &command, - const QStringList &args) - * \brief Resets an existing MythSystem object to a new command - */ -void MythSystem::SetCommand(const QString &command, - const QStringList &args, uint flags) -{ - m_status = GENERIC_EXIT_START; - m_command = QString(command).trimmed(); - m_args = QStringList(args); - - ProcessFlags(flags); - - // add logging arguments - if (GetSetting("PropagateLogs")) - { - if (GetSetting("UseShell") && m_args.isEmpty()) - { - m_command += logPropagateArgs; - if (!logPropagateQuiet()) - m_command += " --quiet"; - } - else - { - m_args << logPropagateArgList; - if (!logPropagateQuiet()) - m_args << "--quiet"; - } - } - - // check for execute rights - if (!GetSetting("UseShell") && access(command.toUtf8().constData(), X_OK)) - { - LOG(VB_GENERAL, LOG_ERR, - QString("MythSystem(%1) command not executable, ") - .arg(command) + ENO); - m_status = GENERIC_EXIT_CMD_NOT_FOUND; - } - - m_logcmd = (m_command + " " + m_args.join(" ")).trimmed(); +// temporary debugging headers +#include +using namespace std; - if (GetSetting("AnonLog")) - { - m_logcmd.truncate(m_logcmd.indexOf(" ")); - m_logcmd.append(" (anonymized)"); - } -} - -MythSystem::MythSystem(const MythSystem &other) : - d(other.d), - m_status(other.m_status), - - m_command(other.m_command), - m_logcmd(other.m_logcmd), - m_args(other.m_args), - m_directory(other.m_directory), - - m_settings(other.m_settings) +class MythSystemLegacyWrapper : public MythSystem { - m_semReady.release(other.m_semReady.available()); -} - -// QBuffers may also need freeing -MythSystem::~MythSystem(void) -{ - if (GetStatus() == GENERIC_EXIT_RUNNING) + public: + static MythSystemLegacyWrapper *Create( + const QStringList &args, + uint flags, + QString startPath, + Priority cpuPriority, + Priority diskPriority) { - Term(true); - Wait(); - } - d->DecrRef(); -} + if (args.empty()) + return NULL; + QString program = args[0]; + QStringList other_args = args.mid(1); -void MythSystem::SetDirectory(const QString &directory) -{ - m_settings["SetDirectory"] = true; - m_directory = QString(directory); -} - -bool MythSystem::SetNice(int nice) -{ - if (!d || (GetStatus() != GENERIC_EXIT_START)) - return false; - - m_nice = nice; - return true; -} - -bool MythSystem::SetIOPrio(int prio) -{ - if (!d || (GetStatus() != GENERIC_EXIT_START)) - return false; - - m_ioprio = prio; - return true; -} + MythSystemLegacy *legacy = + new MythSystemLegacy(args.join(" "), flags); -/// \brief Runs a command inside the /bin/sh shell. Returns immediately -void MythSystem::Run(time_t timeout) -{ - if (!d) - m_status = GENERIC_EXIT_NO_HANDLER; - - if (GetStatus() != GENERIC_EXIT_START) - { - emit error(GetStatus()); - return; - } - - // Handle any locking of drawing, etc - HandlePreRun(); + if (!startPath.isEmpty()) + legacy->SetDirectory(startPath); - d->Fork(timeout); + MythSystemLegacyWrapper *wrapper = + new MythSystemLegacyWrapper(legacy, flags); - if (GetStatus() == GENERIC_EXIT_RUNNING) - { - m_semReady.acquire(1); - emit started(); - d->Manage(); - } - else - { - emit error(GetStatus()); + // TODO implement cpuPriority and diskPriority + return wrapper; } -} -// should there be a separate 'getstatus' call? or is using -// Wait() for that purpose sufficient? -uint MythSystem::Wait(time_t timeout) -{ - if (!d) - m_status = GENERIC_EXIT_NO_HANDLER; - - if ((GetStatus() != GENERIC_EXIT_RUNNING) || GetSetting("RunInBackground")) - return GetStatus(); - - if (GetSetting("ProcessEvents")) + ~MythSystemLegacyWrapper(void) { - if (timeout > 0) - timeout += time(NULL); - - while (!timeout || time(NULL) < timeout) - { - // loop until timeout hits or process ends - if (m_semReady.tryAcquire(1,100)) - { - m_semReady.release(1); - break; - } - - qApp->processEvents(); - } + Wait(0); } - else - { - if (timeout > 0) - { - if (m_semReady.tryAcquire(1, timeout*1000)) - m_semReady.release(1); - } - else - { - m_semReady.acquire(1); - m_semReady.release(1); - } - } - return GetStatus(); -} - -void MythSystem::Term(bool force) -{ - if (!d) - m_status = GENERIC_EXIT_NO_HANDLER; - - if (m_status != GENERIC_EXIT_RUNNING) - return; - - d->Term(force); -} -void MythSystem::Signal(MythSignal sig) -{ - if (!d) - m_status = GENERIC_EXIT_NO_HANDLER; - - if (m_status != GENERIC_EXIT_RUNNING) - return; - - int posix_signal = SIGTRAP; - switch (sig) + virtual uint GetFlags(void) const MOVERRIDE { - case kSignalHangup: posix_signal = SIGHUP; break; - case kSignalInterrupt: posix_signal = SIGINT; break; - case kSignalContinue: posix_signal = SIGCONT; break; - case kSignalQuit: posix_signal = SIGQUIT; break; - case kSignalKill: posix_signal = SIGKILL; break; - case kSignalUser1: posix_signal = SIGUSR1; break; - case kSignalUser2: posix_signal = SIGUSR2; break; - case kSignalTerm: posix_signal = SIGTERM; break; - case kSignalStop: posix_signal = SIGSTOP; break; + return m_flags; } - // The default less switch above will cause a compiler warning - // if someone adds a signal without updating the switch, but in - // case that is missed print out a message. - if (SIGTRAP == posix_signal) + /// Returns the starting path of the program + virtual QString GetStartingPath(void) const MOVERRIDE { - LOG(VB_SYSTEM, LOG_ERR, "Programmer error: Unknown signal"); - return; + return m_legacy->GetDirectory(); } - d->Signal(posix_signal); -} - - -void MythSystem::ProcessFlags(uint flags) -{ - if (m_status != GENERIC_EXIT_START) + /// Return the CPU Priority of the program + virtual Priority GetCPUPriority(void) const MOVERRIDE { - LOG(VB_SYSTEM, LOG_DEBUG, QString("status: %1").arg(m_status)); - return; + return kNormalPriority; } - m_settings["IsInUI"] = gCoreContext->HasGUI() && gCoreContext->IsUIThread(); - - if (flags & kMSRunBackground) - m_settings["RunInBackground"] = true; - - if (m_command.endsWith("&")) + /// Return the Disk Priority of the program + virtual Priority GetDiskPriority(void) const MOVERRIDE { - if (!GetSetting("RunInBackground")) - LOG(VB_SYSTEM, LOG_DEBUG, "Adding background flag"); - - // Remove the & - m_command.chop(1); - m_command = m_command.trimmed(); - m_settings["RunInBackground"] = true; - m_settings["UseShell"] = true; - m_settings["IsInUI"] = false; + return kNormalPriority; } - if (GetSetting("IsInUI")) + /// Blocks until child process is collected or timeout reached. + /// Returns true if program has exited and has been collected. + /// WARNING if program returns 142 then we will forever + /// think it is running even though it is not. + /// WARNING The legacy timeout is in seconds not milliseconds, + /// timeout will be rounded. + virtual bool Wait(uint timeout_ms) MOVERRIDE { - // Check for UI-only locks - m_settings["BlockInputDevs"] = !(flags & kMSDontBlockInputDevs); - m_settings["DisableDrawing"] = !(flags & kMSDontDisableDrawing); - m_settings["ProcessEvents"] = flags & kMSProcessEvents; - m_settings["DisableUDP"] = flags & kMSDisableUDPListener; + timeout_ms = (timeout_ms >= 1000) ? timeout_ms + 500 : + ((timeout_ms == 0) ? 0 : 1000); + uint legacy_wait_ret = m_legacy->Wait(timeout_ms / 1000); + if (GENERIC_EXIT_RUNNING == legacy_wait_ret) + return false; + return true; } - if (flags & kMSStdIn) - m_settings["UseStdin"] = true; - if (flags & kMSStdOut) - m_settings["UseStdout"] = true; - if (flags & kMSStdErr) - m_settings["UseStderr"] = true; - if (flags & kMSRunShell) - m_settings["UseShell"] = true; - if (flags & kMSNoRunShell) // override for use with myth_system - m_settings["UseShell"] = false; - if (flags & kMSAbortOnJump) - m_settings["AbortOnJump"] = true; - if (flags & kMSSetPGID) - m_settings["SetPGID"] = true; - if (flags & kMSAutoCleanup && GetSetting("RunInBackground")) - m_settings["AutoCleanup"] = true; - if (flags & kMSAnonLog) - m_settings["AnonLog"] = true; - if (flags & kMSLowExitVal) - m_settings["OnlyLowExitVal"] = true; - if (flags & kMSPropagateLogs) - m_settings["PropagateLogs"] = true; -} - -QByteArray MythSystem::Read(int size) -{ - return m_stdbuff[1].read(size); -} - -QByteArray MythSystem::ReadErr(int size) -{ - return m_stdbuff[2].read(size); -} - -QByteArray& MythSystem::ReadAll(void) -{ - return m_stdbuff[1].buffer(); -} - -QByteArray& MythSystem::ReadAllErr(void) -{ - return m_stdbuff[2].buffer(); -} - -int MythSystem::Write(const QByteArray &ba) -{ - if (!GetSetting("UseStdin")) - return 0; - - m_stdbuff[0].buffer().append(ba.constData()); - return ba.size(); -} - -void MythSystem::HandlePreRun(void) -{ - // This needs to be a send event so that the MythUI locks the input devices - // immediately instead of after existing events are processed - // since this function could be called inside one of those events. - if (GetSetting("BlockInputDevs")) + /// Returns the standard input stream for the program + /// if the kMSStdIn flag was passed to the constructor. + virtual QIODevice *GetStandardInputStream(void) MOVERRIDE { - QEvent event(MythEvent::kLockInputDevicesEventType); - QCoreApplication::sendEvent(gCoreContext->GetGUIObject(), &event); + return NULL; } - // This needs to be a send event so that the listener is disabled - // immediately instead of after existing events are processed, since the - // listen server must be terminated before the spawned application tries - // to start its own - if (GetSetting("DisableUDP")) + /// Returns the standard output stream for the program + /// if the kMSStdOut flag was passed to the constructor. + virtual QIODevice *GetStandardOutputStream(void) MOVERRIDE { - QEvent event(MythEvent::kDisableUDPListenerEventType); - QCoreApplication::sendEvent(gCoreContext->GetGUIObject(), &event); + return NULL; } - // This needs to be a send event so that the MythUI m_drawState change is - // flagged immediately instead of after existing events are processed - // since this function could be called inside one of those events. - if (GetSetting("DisableDrawing")) + /// Returns the standard error stream for the program + /// if the kMSStdErr flag was passed to the constructor. + virtual QIODevice *GetStandardErrorStream(void) MOVERRIDE { - QEvent event(MythEvent::kPushDisableDrawingEventType); - QCoreApplication::sendEvent(gCoreContext->GetGUIObject(), &event); + return NULL; } -} -void MythSystem::HandlePostRun(void) -{ - // Since this is *not* running in the UI thread (but rather the signal - // handler thread), we need to use postEvents - if (GetSetting("DisableDrawing")) + /// Sends the selected signal to the program + virtual void Signal(MythSignal sig) MOVERRIDE { - QEvent *event = new QEvent(MythEvent::kPopDisableDrawingEventType); - QCoreApplication::postEvent(gCoreContext->GetGUIObject(), event); + m_legacy->Signal(sig); } - // This needs to be a post event so we do not try to start listening on - // the UDP ports before the child application has stopped and terminated - if (GetSetting("DisableUDP")) + /** \brief returns the exit code, if any, that the program returned. + * + * Returns -1 if the program exited without exit code. + * Returns -2 if the program has not yet been collected. + * Returns an exit code 0..255 if the program exited with exit code. + */ + virtual int GetExitCode(void) const MOVERRIDE { - QEvent event(MythEvent::kEnableUDPListenerEventType); - QCoreApplication::sendEvent(gCoreContext->GetGUIObject(), &event); + // FIXME doesn't actually know why program exited. + // if program returns 142 then we will forever + // think it is running even though it is not. + int status = m_legacy->GetStatus(); + if (GENERIC_EXIT_RUNNING == status) + return -2; + return status; } - // This needs to be a post event so that the MythUI unlocks input devices - // after all existing (blocked) events are processed and ignored. - if (GetSetting("BlockInputDevs")) + /** \brief returns the signal, if any, that killed the program. + * + * If the program was killed by a signal this returns the signal + * that killed the program or signal unknown if it was not one of + * the common signals. If the program is still running or if the + * program did not exit due to a signal this returns kSignalNone. + * + * Note: Platform agnostic code should only rely on kSignalNone + * vs non-kSignalNone values, since querying the actual + * signal is not possible on many platforms. + * + * TODO: Should we just return a tristate: killed by signal, + * still running, exited normally? + * TODO: Should we just eliminate this entirely, i.e. a + * limited interface is just telling us if GetExitCode() + * will return -2 or -1, or 0..255, so it is redundant. + */ + virtual MythSignal GetSignal(void) const MOVERRIDE { - QEvent *event = new QEvent(MythEvent::kUnlockInputDevicesEventType); - QCoreApplication::postEvent(gCoreContext->GetGUIObject(), event); + return kSignalNone; +/* + int status = m_legacy->GetStatus(); + if (!WIFSIGNALED(status)) + return kSignalNone; + int posix_signal = -1; // sentinel, POSIX signals are all positive +#ifdef WSTOPSIG + posix_signal = WSTOPSIG(status); +#endif + switch (posix_signal) + { + case SIGHUP: return kSignalHangup; + case SIGINT: return kSignalInterrupt; + case SIGCONT: return kSignalContinue; + case SIGQUIT: return kSignalQuit; + case SIGSEGV: return kSignalSegfault; + case SIGKILL: return kSignalKill; + case SIGUSR1: return kSignalUser1; + case SIGUSR2: return kSignalUser2; + case SIGTERM: return kSignalTerm; + case SIGSTOP: return kSignalStop; + default: return kSignalUnknown; + } +*/ } -} -void MythSystem::JumpAbort(void) -{ - if (!d) - return; - - LOG(VB_SYSTEM, LOG_DEBUG, "Triggering Abort on Jumppoint"); - d->JumpAbort(); -} - -QString MythSystem::ShellEscape(const QString &in) -{ - QString out = in; - - if (out.contains("\"")) - out = out.replace("\"", "\\\""); - - if (out.contains("\'")) - out = out.replace("\'", "\\\'"); - - if (out.contains(" ")) + private: + MythSystemLegacyWrapper(MythSystemLegacy *legacy, uint flags) : + m_legacy(legacy), m_flags(flags) { - out.prepend("\""); - out.append("\""); + m_legacy->Run(); } - return out; -} - -MythSystemPrivate::MythSystemPrivate(const QString &debugName) : - ReferenceCounter(debugName) -{ -} + private: + MythSystemLegacy *m_legacy; + uint m_flags; +}; -uint myth_system(const QString &command, uint flags, uint timeout) +MythSystem *MythSystem::Create( + const QStringList &args, + uint flags, + QString startPath, + Priority cpuPriority, + Priority diskPriority) { - flags |= kMSRunShell | kMSAutoCleanup; - MythSystem *ms = new MythSystem(command, flags); - ms->Run(timeout); - uint result = ms->Wait(0); - if (!ms->GetSetting("RunInBackground")) - delete ms; - - return result; + return MythSystemLegacyWrapper::Create( + args, flags, startPath, cpuPriority, diskPriority); } -void myth_system_jump_abort(void) +MythSystem *MythSystem::Create( + QString args, + uint flags, + QString startPath, + Priority cpuPriority, + Priority diskPriority) { - MythSystem ms; - ms.JumpAbort(); + return MythSystem::Create( + args.split(QRegExp("\\s+")), flags, startPath, + cpuPriority, diskPriority); } - -extern "C" { - unsigned int myth_system_c(char *command, uint flags, uint timeout) - { - QString cmd(command); - return myth_system(cmd, flags, timeout); - } -} - -/* - * vim:ts=4:sw=4:ai:et:si:sts=4 - */ diff --git a/mythtv/libs/libmythbase/mythsystem.h b/mythtv/libs/libmythbase/mythsystem.h index 69490b5adae..1d42bedae3c 100644 --- a/mythtv/libs/libmythbase/mythsystem.h +++ b/mythtv/libs/libmythbase/mythsystem.h @@ -3,27 +3,15 @@ #ifndef MYTHSYSTEM_H_ #define MYTHSYSTEM_H_ -#include "mythbaseexp.h" - -// Note: The FIXME were added 2013-05-18, as part of a multi-pass -// cleanup of MythSystem. -// -// MythSystem exists because the Qt QProcess has caused us numerous -// headaches, most importantly: -// http://code.mythtv.org/trac/ticket/7135 -// https://bugreports.qt-project.org/browse/QTBUG-5990 -// QProcess also demands that the thread in which it is used -// and created run a Qt event loop, which MythSystem does not -// require. A number of MythTV threads do not run an event loop -// so this requirement is a bit onerous. -// -// MythSystem has grown a bit fat around the middle as functionality -// has been added and as a core functionality class is due for a code -// review and some cleanup. - // C headers #include +// Qt headers +#include + +// MythTV headers +#include "mythbaseexp.h" + typedef enum MythSystemMask { kMSNone = 0x00000000, kMSDontBlockInputDevs = 0x00000001, ///< avoid blocking LIRC & Joystick Menu @@ -36,197 +24,145 @@ typedef enum MythSystemMask { kMSStdErr = 0x00000080, ///< allow access to stderr kMSBuffered = 0x00000100, ///< buffer the IO channels kMSRunShell = 0x00000200, ///< run process through shell - kMSNoRunShell = 0x00000400, ///< do NOT run process through shell kMSAnonLog = 0x00000800, ///< anonymize the logs - kMSAbortOnJump = 0x00001000, ///< abort this process on a jumppoint kMSSetPGID = 0x00002000, ///< set the process group id - kMSAutoCleanup = 0x00004000, ///< automatically delete if + kMSAutoCleanup = 0x00004000, ///< automatically delete if /// backgrounded kMSLowExitVal = 0x00008000, ///< allow exit values 0-127 only kMSDisableUDPListener = 0x00010000, ///< disable MythMessage UDP listener /// for the duration of application. - kMSPropagateLogs = 0x00020000, ///< add arguments for MythTV log + kMSPropagateLogs = 0x00020000, ///< add arguments for MythTV log /// propagation -} MythSystemFlag; - -#ifdef __cplusplus - -#include -#include -#include -#include -#include -#include // FIXME: This shouldn't be needed, Setting_t is not public +} MythSystemMask; typedef enum MythSignal { + kSignalNone, + kSignalUnknown, kSignalHangup, kSignalInterrupt, kSignalContinue, kSignalQuit, + kSignalSegfault, kSignalKill, kSignalUser1, kSignalUser2, kSignalTerm, kSignalStop, + // add more signals for benefit of GetSignal() } MythSignal; -// FIXME: _t is not how we name types in MythTV... -typedef QMap Setting_t; - -void MBASE_PUBLIC ShutdownMythSystem(void); - -// FIXME: Does MythSystem really need to inherit from QObject? -// we can probably create a private class that inherits -// from QObject to avoid exposing lots of thread-unsafe -// methods & complicated life-time management. -class MythSystemPrivate; -class MBASE_PUBLIC MythSystem : public QObject +class QStringList; +class QIODevice; + +/** \brief class for managing sub-processes. + * + * This is a hopefully simple interface for managing sub-processes. + * + * The general usage is: + * { + * QScopedPointer sys(MythSystem::Create("touch /tmp/i.am.legend")); + * } + */ +class MBASE_PUBLIC MythSystem { - Q_OBJECT - public: - MythSystem(); - MythSystem(const QString &, uint); - MythSystem(const QString &, const QStringList &, uint); - // FIXME: Do we really need to expose a public copy-constructor? - // FIXME: Should operator=() also be provided or banned? - MythSystem(const MythSystem &other); - ~MythSystem(void); - - // FIXME: We should not allow a MythSystem to be reused for a new command. - void SetCommand(const QString &, uint); - // FIXME: We should not allow a MythSystem to be reused for a new command. - void SetCommand(const QString &, const QStringList &, uint); - // FIXME: This should only be in the constructor - void SetDirectory(const QString &); - // FIXME: This should only be in the constructor - bool SetNice(int nice); - // FIXME: This should only be in the constructor - bool SetIOPrio(int prio); - - // FIXME: Forks, should be called Start() for consistency with MThread. - // FIXME: Do we need this call at all? - void Run(time_t timeout = 0); - // FIXME: This should just return a bool telling us if we hit the timeout. - uint Wait(time_t timeout = 0); - - int Write(const QByteArray&); - QByteArray Read(int size); - QByteArray ReadErr(int size); - // FIXME: We should not return a reference here - QByteArray& ReadAll(); - // FIXME: We should not return a reference here - QByteArray& ReadAllErr(); - - // FIXME: Can Term be wrapped into Signal? - void Term(bool force = false); - void Signal(MythSignal); - - // FIXME: Should be documented, and maybe should be called AbortJump() - void JumpAbort(void); - - // FIXME: Should be IsBackground() + documented - bool isBackground(void) { return GetSetting("RunInBackground"); } - // FIXME: Should be IsAutoCleanupProcess() + documented - bool doAutoCleanup(void) { return GetSetting("AutoCleanup"); } - // FIXME: No idea what this is querying but should be StudlyCase - // and should be documented - bool onlyLowExitVal(void) { return GetSetting("OnlyLowExitVal"); } - // FIXME: Why is this public? - void HandlePreRun(void); - // FIXME: Why is this public? - void HandlePostRun(void); - - // FIXME: Rename "GetExitStatus" and document that this does not - // block until an exit status exists. - // FIXME: Document what this actually returns. - uint GetStatus(void) { return m_status; } - // FIXME Make private. - void SetStatus(uint status) { m_status = status; } - - // FIXME: We should not return a reference here, add a Set if necessary - // Do we even need this function? Should it then be better named? - QString& GetLogCmd(void) { return m_logcmd; } - // FIXME: We should not return a reference here - QString& GetDirectory(void) { return m_directory; } - - // FIXME: Eliminate or make private, we don't allow any settings - // that can not be enumerated. - bool GetSetting(const char *setting) - { return m_settings.value(QString(setting)); } - - // FIXME: We should not return a reference here - QString& GetCommand(void) { return m_command; } - // FIXME: Eliminate. We should not allow setting the command - // after construcion. - void SetCommand(QString &cmd) { m_command = cmd; } - - // FIXME: We should not return a reference here - // FIXME: Rename "GetArguments" - QStringList &GetArgs(void) { return m_args; } - // FIXME: Eliminate. We should not allow setting the arguements - // after construcion. - void SetArgs(QStringList &args) { m_args = args; } - - int GetNice(void) { return m_nice; } - int GetIOPrio(void) { return m_ioprio; } - - // FIXME: We should not return a pointer to a QBuffer - QBuffer *GetBuffer(int index) { return &m_stdbuff[index]; } - - // FIXME: We should not make locking public - void Unlock(void) { m_semReady.release(1); } - - friend class MythSystemPrivate; - - // FIXME: This should be an independent function living elsewhere - static QString ShellEscape(const QString &str); - - // FIXME: Do we really need to expose Qt signals? - // If so why are they lower case? - signals: - void started(void); - void finished(void); - void error(uint status); - void readDataReady(int fd); - - private: - void initializePrivate(void); - MythSystemPrivate *d; // FIXME we generally call this m_priv in MythTV + /// Priorities that can be used for cpu and disk usage of child process + typedef enum Priority { + kIdlePriority = 0, ///< run only when no one else wants to + kLowestPriority, + kLowPriority, + kNormalPriority, ///< run as a normal program + kHighPriority, + kHighestPriority, + kTimeCriticalPriority, + kInheritPriority, ///< Use parent priority + } Priority; + + static MythSystem *Create( + const QStringList &args, + uint flags = kMSNone, + QString startPath = QString(), + Priority cpuPriority = kInheritPriority, + Priority diskPriority = kInheritPriority); + + static MythSystem *Create( + QString args, + uint flags = kMSNone, + QString startPath = QString(), + Priority cpuPriority = kInheritPriority, + Priority diskPriority = kInheritPriority); + + virtual ~MythSystem(void) {} + + /// Returns the flags passed to the constructor + virtual uint GetFlags(void) const = 0; + + /// Returns the starting path of the program + virtual QString GetStartingPath(void) const = 0; + + /// Return the CPU Priority of the program + virtual Priority GetCPUPriority(void) const = 0; + + /// Return the Disk Priority of the program + virtual Priority GetDiskPriority(void) const = 0; + + /** Blocks until child process is collected or timeout reached. + * If the timeout is not provided or a timeout of 0 is provided + * this will block until the sub-program exits. + * \return true if program has exited and has been collected. + */ + virtual bool Wait(uint timeout_ms = 0) = 0; + + /// Returns the standard input stream for the program + /// if the kMSStdIn flag was passed to the constructor. + virtual QIODevice *GetStandardInputStream(void) = 0; + + /// Returns the standard output stream for the program + /// if the kMSStdOut flag was passed to the constructor. + virtual QIODevice *GetStandardOutputStream(void) = 0; + + /// Returns the standard error stream for the program + /// if the kMSStdErr flag was passed to the constructor. + virtual QIODevice *GetStandardErrorStream(void) = 0; + + /// Sends the selected signal to the program + virtual void Signal(MythSignal) = 0; + + /** \brief returns the exit code, if any, that the program returned. + * + * Returns -1 if the program exited without exit code. + * Returns -2 if the program has not yet been collected. + * Returns an exit code 0..255 if the program exited with exit code. + */ + virtual int GetExitCode(void) const = 0; + + /** \brief returns the signal, if any, that killed the program. + * + * If the program was killed by a signal this returns the signal + * that killed the program or signal unknown if it was not one of + * the common signals. If the program is still running or if the + * program did not exit due to a signal this returns kSignalNone. + * + * Note: Platform agnostic code should only rely on kSignalNone + * vs non-kSignalNone values, since querying the actual + * signal is not possible on many platforms. + * + * TODO: Should we just return a tristate: killed by signal, + * still running, exited normally? + * TODO: Should we just eliminate this entirely, i.e. a + * limited interface is just telling us if GetExitCode() + * will return -2 or -1, or 0..255, so it is redundant. + */ + virtual MythSignal GetSignal(void) const = 0; protected: - void ProcessFlags(uint flags); - - // FIXME if we already have a private helper, why all this? - uint m_status; - QSemaphore m_semReady; + MythSystem() {} - QString m_command; - QString m_logcmd; - QStringList m_args; - QString m_directory; - - int m_nice; - int m_ioprio; - - Setting_t m_settings; - QBuffer m_stdbuff[3]; + private: + MythSystem(const MythSystem&); // no-implementation + MythSystem& operator= (const MythSystem&); // no-implementation }; - - -MBASE_PUBLIC uint myth_system(const QString &command, - uint flags = kMSNone, - uint timeout = 0); -MBASE_PUBLIC void myth_system_jump_abort(void); -#endif // __cplusplus - -#ifdef __cplusplus -extern "C" -#endif // __cplusplus -MBASE_PUBLIC uint myth_system_c(char *command, uint flags, uint timeout); - #endif // MYTHSYSTEM_H_ -/* - * vim:ts=4:sw=4:ai:et:si:sts=4 - */ + +/* vim:ts=4:sw=4:ai:et:si:sts=4 */ diff --git a/mythtv/libs/libmythbase/mythsystemlegacy.cpp b/mythtv/libs/libmythbase/mythsystemlegacy.cpp new file mode 100644 index 00000000000..ee4bca7395b --- /dev/null +++ b/mythtv/libs/libmythbase/mythsystemlegacy.cpp @@ -0,0 +1,506 @@ +/// -*- Mode: c++ -*- + +// compat header +#include "compat.h" + +// Own header +#include "mythsystemlegacy.h" + +// C++/C headers +#include +#include +#include +#include +#include +#include // for kill() and SIGXXX +#include + +// QT headers +#include + +// libmythbase headers +#include "referencecounter.h" +#include "mythcorecontext.h" +#include "mythevent.h" +#include "mythlogging.h" +#include "exitcodes.h" + +#if CONFIG_CYGWIN || defined(_WIN32) +#include "mythsystemwindows.h" +#else +#include "mythsystemunix.h" +#endif + + +/******************************* + * MythSystemLegacy method defines + ******************************/ + +void MythSystemLegacy::initializePrivate(void) +{ + m_nice = 0; + m_ioprio = 0; +#if CONFIG_CYGWIN || defined(_WIN32) + d = new MythSystemLegacyWindows(this); +#else + d = new MythSystemLegacyUnix(this); +#endif +} + +MythSystemLegacy::MythSystemLegacy() +{ + setObjectName("MythSystemLegacy()"); + m_semReady.release(1); // initialize + initializePrivate(); +} + +MythSystemLegacy::MythSystemLegacy(const QString &command, uint flags) +{ + setObjectName(QString("MythSystemLegacy(%1)").arg(command)); + m_semReady.release(1); // initialize + initializePrivate(); + SetCommand(command, flags); +} + +/** \fn MythSystemLegacy::setCommand(const QString &command) + * \brief Resets an existing MythSystemLegacy object to a new command + */ +void MythSystemLegacy::SetCommand(const QString &command, uint flags) +{ + if (flags & kMSRunShell) + { + SetCommand(command, QStringList(), flags); + } + else + { + QString abscommand; + QStringList args; + if (!d->ParseShell(command, abscommand, args)) + { + LOG(VB_GENERAL, LOG_ERR, + QString("MythSystemLegacy(%1) command not understood") + .arg(command)); + m_status = GENERIC_EXIT_INVALID_CMDLINE; + return; + } + + SetCommand(abscommand, args, flags); + } +} + + +MythSystemLegacy::MythSystemLegacy(const QString &command, + const QStringList &args, uint flags) +{ + m_semReady.release(1); // initialize + initializePrivate(); + SetCommand(command, args, flags); +} + +/** \fn MythSystemLegacy::setCommand(const QString &command, + const QStringList &args) + * \brief Resets an existing MythSystemLegacy object to a new command + */ +void MythSystemLegacy::SetCommand(const QString &command, + const QStringList &args, uint flags) +{ + m_status = GENERIC_EXIT_START; + m_command = QString(command).trimmed(); + m_args = QStringList(args); + + ProcessFlags(flags); + + // add logging arguments + if (GetSetting("PropagateLogs")) + { + if (GetSetting("UseShell") && m_args.isEmpty()) + { + m_command += logPropagateArgs; + if (!logPropagateQuiet()) + m_command += " --quiet"; + } + else + { + m_args << logPropagateArgList; + if (!logPropagateQuiet()) + m_args << "--quiet"; + } + } + + // check for execute rights + if (!GetSetting("UseShell") && access(command.toUtf8().constData(), X_OK)) + { + LOG(VB_GENERAL, LOG_ERR, + QString("MythSystemLegacy(%1) command not executable, ") + .arg(command) + ENO); + m_status = GENERIC_EXIT_CMD_NOT_FOUND; + } + + m_logcmd = (m_command + " " + m_args.join(" ")).trimmed(); + + if (GetSetting("AnonLog")) + { + m_logcmd.truncate(m_logcmd.indexOf(" ")); + m_logcmd.append(" (anonymized)"); + } +} + + +MythSystemLegacy::MythSystemLegacy(const MythSystemLegacy &other) : + d(other.d), + m_status(other.m_status), + + m_command(other.m_command), + m_logcmd(other.m_logcmd), + m_args(other.m_args), + m_directory(other.m_directory), + + m_settings(other.m_settings) +{ + m_semReady.release(other.m_semReady.available()); +} + +// QBuffers may also need freeing +MythSystemLegacy::~MythSystemLegacy(void) +{ + if (GetStatus() == GENERIC_EXIT_RUNNING) + { + Term(true); + Wait(); + } + d->DecrRef(); +} + + +void MythSystemLegacy::SetDirectory(const QString &directory) +{ + m_settings["SetDirectory"] = true; + m_directory = QString(directory); +} + +bool MythSystemLegacy::SetNice(int nice) +{ + if (!d || (GetStatus() != GENERIC_EXIT_START)) + return false; + + m_nice = nice; + return true; +} + +bool MythSystemLegacy::SetIOPrio(int prio) +{ + if (!d || (GetStatus() != GENERIC_EXIT_START)) + return false; + + m_ioprio = prio; + return true; +} + +/// \brief Runs a command inside the /bin/sh shell. Returns immediately +void MythSystemLegacy::Run(time_t timeout) +{ + if (!d) + m_status = GENERIC_EXIT_NO_HANDLER; + + if (GetStatus() != GENERIC_EXIT_START) + { + emit error(GetStatus()); + return; + } + + // Handle any locking of drawing, etc + HandlePreRun(); + + d->Fork(timeout); + + if (GetStatus() == GENERIC_EXIT_RUNNING) + { + m_semReady.acquire(1); + emit started(); + d->Manage(); + } + else + { + emit error(GetStatus()); + } +} + +// should there be a separate 'getstatus' call? or is using +// Wait() for that purpose sufficient? +uint MythSystemLegacy::Wait(time_t timeout) +{ + if (!d) + m_status = GENERIC_EXIT_NO_HANDLER; + + if ((GetStatus() != GENERIC_EXIT_RUNNING) || GetSetting("RunInBackground")) + return GetStatus(); + + if (GetSetting("ProcessEvents")) + { + if (timeout > 0) + timeout += time(NULL); + + while (!timeout || time(NULL) < timeout) + { + // loop until timeout hits or process ends + if (m_semReady.tryAcquire(1,100)) + { + m_semReady.release(1); + break; + } + + qApp->processEvents(); + } + } + else + { + if (timeout > 0) + { + if (m_semReady.tryAcquire(1, timeout*1000)) + m_semReady.release(1); + } + else + { + m_semReady.acquire(1); + m_semReady.release(1); + } + } + return GetStatus(); +} + +void MythSystemLegacy::Term(bool force) +{ + if (!d) + m_status = GENERIC_EXIT_NO_HANDLER; + + if (m_status != GENERIC_EXIT_RUNNING) + return; + + d->Term(force); +} + +void MythSystemLegacy::Signal(MythSignal sig) +{ + if (!d) + m_status = GENERIC_EXIT_NO_HANDLER; + + if (m_status != GENERIC_EXIT_RUNNING) + return; + + int posix_signal = SIGTRAP; + switch (sig) + { + case kSignalHangup: posix_signal = SIGHUP; break; + case kSignalInterrupt: posix_signal = SIGINT; break; + case kSignalContinue: posix_signal = SIGCONT; break; + case kSignalQuit: posix_signal = SIGQUIT; break; + case kSignalSegfault: posix_signal = SIGSEGV; break; + case kSignalKill: posix_signal = SIGKILL; break; + case kSignalUser1: posix_signal = SIGUSR1; break; + case kSignalUser2: posix_signal = SIGUSR2; break; + case kSignalTerm: posix_signal = SIGTERM; break; + case kSignalStop: posix_signal = SIGSTOP; break; + } + + // The default less switch above will cause a compiler warning + // if someone adds a signal without updating the switch, but in + // case that is missed print out a message. + if (SIGTRAP == posix_signal) + { + LOG(VB_SYSTEM, LOG_ERR, "Programmer error: Unknown signal"); + return; + } + + d->Signal(posix_signal); +} + + +void MythSystemLegacy::ProcessFlags(uint flags) +{ + if (m_status != GENERIC_EXIT_START) + { + LOG(VB_SYSTEM, LOG_DEBUG, QString("status: %1").arg(m_status)); + return; + } + + m_settings["IsInUI"] = gCoreContext->HasGUI() && gCoreContext->IsUIThread(); + + if (flags & kMSRunBackground) + m_settings["RunInBackground"] = true; + + if (m_command.endsWith("&")) + { + if (!GetSetting("RunInBackground")) + LOG(VB_SYSTEM, LOG_DEBUG, "Adding background flag"); + + // Remove the & + m_command.chop(1); + m_command = m_command.trimmed(); + m_settings["RunInBackground"] = true; + m_settings["UseShell"] = true; + m_settings["IsInUI"] = false; + } + + if (GetSetting("IsInUI")) + { + // Check for UI-only locks + m_settings["BlockInputDevs"] = !(flags & kMSDontBlockInputDevs); + m_settings["DisableDrawing"] = !(flags & kMSDontDisableDrawing); + m_settings["ProcessEvents"] = flags & kMSProcessEvents; + m_settings["DisableUDP"] = flags & kMSDisableUDPListener; + } + + if (flags & kMSStdIn) + m_settings["UseStdin"] = true; + if (flags & kMSStdOut) + m_settings["UseStdout"] = true; + if (flags & kMSStdErr) + m_settings["UseStderr"] = true; + if (flags & kMSRunShell) + m_settings["UseShell"] = true; + if (flags & kMSSetPGID) + m_settings["SetPGID"] = true; + if (flags & kMSAutoCleanup && GetSetting("RunInBackground")) + m_settings["AutoCleanup"] = true; + if (flags & kMSAnonLog) + m_settings["AnonLog"] = true; + if (flags & kMSLowExitVal) + m_settings["OnlyLowExitVal"] = true; + if (flags & kMSPropagateLogs) + m_settings["PropagateLogs"] = true; +} + +QByteArray MythSystemLegacy::Read(int size) +{ + return m_stdbuff[1].read(size); +} + +QByteArray MythSystemLegacy::ReadErr(int size) +{ + return m_stdbuff[2].read(size); +} + +QByteArray& MythSystemLegacy::ReadAll(void) +{ + return m_stdbuff[1].buffer(); +} + +QByteArray& MythSystemLegacy::ReadAllErr(void) +{ + return m_stdbuff[2].buffer(); +} + +int MythSystemLegacy::Write(const QByteArray &ba) +{ + if (!GetSetting("UseStdin")) + return 0; + + m_stdbuff[0].buffer().append(ba.constData()); + return ba.size(); +} + +void MythSystemLegacy::HandlePreRun(void) +{ + // This needs to be a send event so that the MythUI locks the input devices + // immediately instead of after existing events are processed + // since this function could be called inside one of those events. + if (GetSetting("BlockInputDevs")) + { + QEvent event(MythEvent::kLockInputDevicesEventType); + QCoreApplication::sendEvent(gCoreContext->GetGUIObject(), &event); + } + + // This needs to be a send event so that the listener is disabled + // immediately instead of after existing events are processed, since the + // listen server must be terminated before the spawned application tries + // to start its own + if (GetSetting("DisableUDP")) + { + QEvent event(MythEvent::kDisableUDPListenerEventType); + QCoreApplication::sendEvent(gCoreContext->GetGUIObject(), &event); + } + + // This needs to be a send event so that the MythUI m_drawState change is + // flagged immediately instead of after existing events are processed + // since this function could be called inside one of those events. + if (GetSetting("DisableDrawing")) + { + QEvent event(MythEvent::kPushDisableDrawingEventType); + QCoreApplication::sendEvent(gCoreContext->GetGUIObject(), &event); + } +} + +void MythSystemLegacy::HandlePostRun(void) +{ + // Since this is *not* running in the UI thread (but rather the signal + // handler thread), we need to use postEvents + if (GetSetting("DisableDrawing")) + { + QEvent *event = new QEvent(MythEvent::kPopDisableDrawingEventType); + QCoreApplication::postEvent(gCoreContext->GetGUIObject(), event); + } + + // This needs to be a post event so we do not try to start listening on + // the UDP ports before the child application has stopped and terminated + if (GetSetting("DisableUDP")) + { + QEvent event(MythEvent::kEnableUDPListenerEventType); + QCoreApplication::sendEvent(gCoreContext->GetGUIObject(), &event); + } + + // This needs to be a post event so that the MythUI unlocks input devices + // after all existing (blocked) events are processed and ignored. + if (GetSetting("BlockInputDevs")) + { + QEvent *event = new QEvent(MythEvent::kUnlockInputDevicesEventType); + QCoreApplication::postEvent(gCoreContext->GetGUIObject(), event); + } +} + +QString MythSystemLegacy::ShellEscape(const QString &in) +{ + QString out = in; + + if (out.contains("\"")) + out = out.replace("\"", "\\\""); + + if (out.contains("\'")) + out = out.replace("\'", "\\\'"); + + if (out.contains(" ")) + { + out.prepend("\""); + out.append("\""); + } + + return out; +} + +MythSystemLegacyPrivate::MythSystemLegacyPrivate(const QString &debugName) : + ReferenceCounter(debugName) +{ +} + +uint myth_system(const QString &command, uint flags, uint timeout) +{ + flags |= kMSRunShell | kMSAutoCleanup; + MythSystemLegacy *ms = new MythSystemLegacy(command, flags); + ms->Run(timeout); + uint result = ms->Wait(0); + if (!ms->GetSetting("RunInBackground")) + delete ms; + + return result; +} + +extern "C" { + unsigned int myth_system_c(char *command, uint flags, uint timeout) + { + QString cmd(command); + return myth_system(cmd, flags, timeout); + } +} + +/* + * vim:ts=4:sw=4:ai:et:si:sts=4 + */ diff --git a/mythtv/libs/libmythbase/mythsystemlegacy.h b/mythtv/libs/libmythbase/mythsystemlegacy.h new file mode 100644 index 00000000000..990d842c11c --- /dev/null +++ b/mythtv/libs/libmythbase/mythsystemlegacy.h @@ -0,0 +1,192 @@ +/// -*- Mode: c++ -*- + +#ifndef _MYTHSYSTEMLEGACY_H_ +#define _MYTHSYSTEMLEGACY_H_ + +#include "mythbaseexp.h" + +// Note: The FIXME were added 2013-05-18, as part of a multi-pass +// cleanup of MythSystemLegacy. +// +// MythSystemLegacy exists because the Qt QProcess has caused us numerous +// headaches, most importantly: +// http://code.mythtv.org/trac/ticket/7135 +// https://bugreports.qt-project.org/browse/QTBUG-5990 +// QProcess also demands that the thread in which it is used +// and created run a Qt event loop, which MythSystemLegacy does not +// require. A number of MythTV threads do not run an event loop +// so this requirement is a bit onerous. +// +// MythSystemLegacy has grown a bit fat around the middle as functionality +// has been added and as a core functionality class is due for a code +// review and some cleanup. + +// C headers +#include + +#ifdef __cplusplus + +#include "mythsystem.h" // included for MythSystemFlag and MythSignal +typedef MythSystemMask MythSystemFlag; + +#include +#include +#include +#include +#include +#include // FIXME: This shouldn't be needed, Setting_t is not public + +// FIXME: _t is not how we name types in MythTV... +typedef QMap Setting_t; + +void MBASE_PUBLIC ShutdownMythSystemLegacy(void); + +// FIXME: Does MythSystemLegacy really need to inherit from QObject? +// we can probably create a private class that inherits +// from QObject to avoid exposing lots of thread-unsafe +// methods & complicated life-time management. +class MythSystemLegacyPrivate; +class MBASE_PUBLIC MythSystemLegacy : public QObject +{ + Q_OBJECT + + public: + MythSystemLegacy(); + MythSystemLegacy(const QString &, uint); + MythSystemLegacy(const QString &, const QStringList &, uint); + // FIXME: Do we really need to expose a public copy-constructor? + // FIXME: Should operator=() also be provided or banned? + MythSystemLegacy(const MythSystemLegacy &other); + ~MythSystemLegacy(void); + + // FIXME: We should not allow a MythSystemLegacy to be reused for a new command. + void SetCommand(const QString &, uint); + // FIXME: We should not allow a MythSystemLegacy to be reused for a new command. + void SetCommand(const QString &, const QStringList &, uint); + // FIXME: This should only be in the constructor + void SetDirectory(const QString &); + // FIXME: This should only be in the constructor + bool SetNice(int nice); + // FIXME: This should only be in the constructor + bool SetIOPrio(int prio); + + // FIXME: Forks, should be called Start() for consistency with MThread. + // FIXME: Do we need this call at all? + void Run(time_t timeout = 0); + // FIXME: This should just return a bool telling us if we hit the timeout. + uint Wait(time_t timeout = 0); + + int Write(const QByteArray&); + QByteArray Read(int size); + QByteArray ReadErr(int size); + // FIXME: We should not return a reference here + QByteArray& ReadAll(); + // FIXME: We should not return a reference here + QByteArray& ReadAllErr(); + + // FIXME: Can Term be wrapped into Signal? + void Term(bool force = false); + void Signal(MythSignal); + + // FIXME: Should be IsBackground() + documented + bool isBackground(void) { return GetSetting("RunInBackground"); } + // FIXME: Should be IsAutoCleanupProcess() + documented + bool doAutoCleanup(void) { return GetSetting("AutoCleanup"); } + // FIXME: No idea what this is querying but should be StudlyCase + // and should be documented + bool onlyLowExitVal(void) { return GetSetting("OnlyLowExitVal"); } + // FIXME: Why is this public? + void HandlePreRun(void); + // FIXME: Why is this public? + void HandlePostRun(void); + + // FIXME: Rename "GetExitStatus" and document that this does not + // block until an exit status exists. + // FIXME: Document what this actually returns. + uint GetStatus(void) { return m_status; } + // FIXME Make private. + void SetStatus(uint status) { m_status = status; } + + // FIXME: We should not return a reference here, add a Set if necessary + // Do we even need this function? Should it then be better named? + QString& GetLogCmd(void) { return m_logcmd; } + // FIXME: We should not return a reference here + QString& GetDirectory(void) { return m_directory; } + + // FIXME: Eliminate or make private, we don't allow any settings + // that can not be enumerated. + bool GetSetting(const char *setting) + { return m_settings.value(QString(setting)); } + + // FIXME: We should not return a reference here + QString& GetCommand(void) { return m_command; } + // FIXME: Eliminate. We should not allow setting the command + // after construcion. + void SetCommand(QString &cmd) { m_command = cmd; } + + // FIXME: We should not return a reference here + // FIXME: Rename "GetArguments" + QStringList &GetArgs(void) { return m_args; } + // FIXME: Eliminate. We should not allow setting the arguements + // after construcion. + void SetArgs(QStringList &args) { m_args = args; } + + int GetNice(void) { return m_nice; } + int GetIOPrio(void) { return m_ioprio; } + + // FIXME: We should not return a pointer to a QBuffer + QBuffer *GetBuffer(int index) { return &m_stdbuff[index]; } + + // FIXME: We should not make locking public + void Unlock(void) { m_semReady.release(1); } + + friend class MythSystemLegacyPrivate; + + // FIXME: This should be an independent function living elsewhere + static QString ShellEscape(const QString &str); + + // FIXME: Do we really need to expose Qt signals? + // If so why are they lower case? + signals: + void started(void); + void finished(void); + void error(uint status); + void readDataReady(int fd); + + private: + void initializePrivate(void); + MythSystemLegacyPrivate *d; // FIXME we generally call this m_priv in MythTV + + protected: + void ProcessFlags(uint flags); + + // FIXME if we already have a private helper, why all this? + uint m_status; + QSemaphore m_semReady; + + QString m_command; + QString m_logcmd; + QStringList m_args; + QString m_directory; + + int m_nice; + int m_ioprio; + + Setting_t m_settings; + QBuffer m_stdbuff[3]; +}; + +MBASE_PUBLIC uint myth_system(const QString &command, + uint flags = kMSNone, + uint timeout = 0); +#endif // __cplusplus + +#ifdef __cplusplus +extern "C" +#endif // __cplusplus +MBASE_PUBLIC uint myth_system_c(char *command, uint flags, uint timeout); + +#endif // _MYTHSYSTEMLEGACY_H_ +/* + * vim:ts=4:sw=4:ai:et:si:sts=4 + */ diff --git a/mythtv/libs/libmythbase/mythsystemprivate.h b/mythtv/libs/libmythbase/mythsystemprivate.h index ffcba883ab3..520d7eb2577 100644 --- a/mythtv/libs/libmythbase/mythsystemprivate.h +++ b/mythtv/libs/libmythbase/mythsystemprivate.h @@ -13,7 +13,7 @@ // MythTV header #include "referencecounter.h" #include "mythbaseexp.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" class QStringList; class QString; @@ -21,13 +21,13 @@ class QBuffer; // FIXME: do we really need reference counting? // it shouldn't be difficult to track the lifetime of a private object. -// FIXME: This should not live in the same header as MythSystem -class MythSystemPrivate : public QObject, public ReferenceCounter +// FIXME: This should not live in the same header as MythSystemLegacy +class MythSystemLegacyPrivate : public QObject, public ReferenceCounter { Q_OBJECT public: - MythSystemPrivate(const QString &debugName); + MythSystemLegacyPrivate(const QString &debugName); virtual void Fork(time_t timeout) = 0; virtual void Manage(void) = 0; @@ -41,7 +41,7 @@ class MythSystemPrivate : public QObject, public ReferenceCounter protected: // FIXME: QPointer uses global hash & is deprecated for good reason - QPointer m_parent; + QPointer m_parent; uint GetStatus(void) { return m_parent->GetStatus(); } void SetStatus(uint status) { m_parent->SetStatus(status); } diff --git a/mythtv/libs/libmythbase/mythsystemunix.cpp b/mythtv/libs/libmythbase/mythsystemunix.cpp index 0915dfcec3d..17f363442e4 100644 --- a/mythtv/libs/libmythbase/mythsystemunix.cpp +++ b/mythtv/libs/libmythbase/mythsystemunix.cpp @@ -1,6 +1,6 @@ // Own header -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythsystemunix.h" #include "mythmiscutil.h" @@ -44,25 +44,25 @@ if( (x) >= 0 ) { \ typedef struct { - MythSystemUnix *ms; + MythSystemLegacyUnix *ms; int type; } FDType_t; typedef QMap FDMap_t; /********************************** - * MythSystemManager method defines + * MythSystemLegacyManager method defines *********************************/ static bool run_system = true; -static MythSystemManager *manager = NULL; -static MythSystemSignalManager *smanager = NULL; -static MythSystemIOHandler *readThread = NULL; -static MythSystemIOHandler *writeThread = NULL; +static MythSystemLegacyManager *manager = NULL; +static MythSystemLegacySignalManager *smanager = NULL; +static MythSystemLegacyIOHandler *readThread = NULL; +static MythSystemLegacyIOHandler *writeThread = NULL; static MSList_t msList; static QMutex listLock; static FDMap_t fdMap; static QMutex fdLock; -void ShutdownMythSystem(void) +void ShutdownMythSystemLegacy(void) { run_system = false; if (manager) @@ -75,7 +75,7 @@ void ShutdownMythSystem(void) writeThread->wait(); } -MythSystemIOHandler::MythSystemIOHandler(bool read) : +MythSystemLegacyIOHandler::MythSystemLegacyIOHandler(bool read) : MThread(QString("SystemIOHandler%1").arg(read ? "R" : "W")), m_pWaitLock(), m_pWait(), m_pLock(), m_pMap(PMap_t()), m_maxfd(-1), m_read(read) @@ -83,7 +83,7 @@ MythSystemIOHandler::MythSystemIOHandler(bool read) : m_readbuf[0] = '\0'; } -void MythSystemIOHandler::run(void) +void MythSystemLegacyIOHandler::run(void) { RunProlog(); LOG(VB_GENERAL, LOG_INFO, QString("Starting IO manager (%1)") @@ -126,7 +126,7 @@ void MythSystemIOHandler::run(void) if( retval == -1 ) LOG(VB_SYSTEM, LOG_ERR, - QString("MythSystemIOHandler: select(%1, %2) failed: %3") + QString("MythSystemLegacyIOHandler: select(%1, %2) failed: %3") .arg(m_maxfd+1).arg(m_read).arg(strerror(errno))); else if( retval > 0 ) @@ -152,7 +152,7 @@ void MythSystemIOHandler::run(void) RunEpilog(); } -void MythSystemIOHandler::HandleRead(int fd, QBuffer *buff) +void MythSystemLegacyIOHandler::HandleRead(int fd, QBuffer *buff) { int len; errno = 0; @@ -168,19 +168,19 @@ void MythSystemIOHandler::HandleRead(int fd, QBuffer *buff) { buff->buffer().append(m_readbuf, len); - // Get the corresponding MythSystem instance, and the stdout/stderr + // Get the corresponding MythSystemLegacy instance, and the stdout/stderr // type fdLock.lock(); FDType_t *fdType = fdMap.value(fd); fdLock.unlock(); // Emit the data ready signal (1 = stdout, 2 = stderr) - MythSystemUnix *ms = fdType->ms; + MythSystemLegacyUnix *ms = fdType->ms; emit ms->readDataReady(fdType->type); } } -void MythSystemIOHandler::HandleWrite(int fd, QBuffer *buff) +void MythSystemLegacyIOHandler::HandleWrite(int fd, QBuffer *buff) { if( buff->atEnd() ) { @@ -208,7 +208,7 @@ void MythSystemIOHandler::HandleWrite(int fd, QBuffer *buff) buff->seek(pos+rlen); } -void MythSystemIOHandler::insert(int fd, QBuffer *buff) +void MythSystemLegacyIOHandler::insert(int fd, QBuffer *buff) { m_pLock.lock(); m_pMap.insert(fd, buff); @@ -217,7 +217,7 @@ void MythSystemIOHandler::insert(int fd, QBuffer *buff) wake(); } -void MythSystemIOHandler::remove(int fd) +void MythSystemLegacyIOHandler::remove(int fd) { m_pLock.lock(); if (m_read) @@ -232,13 +232,13 @@ void MythSystemIOHandler::remove(int fd) m_pLock.unlock(); } -void MythSystemIOHandler::wake() +void MythSystemLegacyIOHandler::wake() { QMutexLocker locker(&m_pWaitLock); m_pWait.wakeAll(); } -void MythSystemIOHandler::BuildFDs() +void MythSystemLegacyIOHandler::BuildFDs() { // build descriptor list FD_ZERO(&m_fds); @@ -252,12 +252,12 @@ void MythSystemIOHandler::BuildFDs() } } -MythSystemManager::MythSystemManager() : MThread("SystemManager") +MythSystemLegacyManager::MythSystemLegacyManager() : MThread("SystemManager") { m_jumpAbort = false; } -void MythSystemManager::run(void) +void MythSystemLegacyManager::run(void) { RunProlog(); LOG(VB_GENERAL, LOG_INFO, "Starting process manager"); @@ -281,7 +281,7 @@ void MythSystemManager::run(void) } m_mapLock.unlock(); - MythSystemUnix *ms; + MythSystemLegacyUnix *ms; pid_t pid; int status; @@ -437,7 +437,7 @@ void MythSystemManager::run(void) RunEpilog(); } -void MythSystemManager::append(MythSystemUnix *ms) +void MythSystemLegacyManager::append(MythSystemLegacyUnix *ms) { m_mapLock.lock(); ms->IncrRef(); @@ -470,7 +470,7 @@ void MythSystemManager::append(MythSystemUnix *ms) } } -void MythSystemManager::jumpAbort(void) +void MythSystemLegacyManager::jumpAbort(void) { m_jumpLock.lock(); m_jumpAbort = true; @@ -479,12 +479,12 @@ void MythSystemManager::jumpAbort(void) // spawn separate thread for signals to prevent manager // thread from blocking in some slot -MythSystemSignalManager::MythSystemSignalManager() : +MythSystemLegacySignalManager::MythSystemLegacySignalManager() : MThread("SystemSignalManager") { } -void MythSystemSignalManager::run(void) +void MythSystemLegacySignalManager::run(void) { RunProlog(); LOG(VB_GENERAL, LOG_INFO, "Starting process signal handler"); @@ -504,7 +504,7 @@ void MythSystemSignalManager::run(void) listLock.unlock(); break; } - MythSystemUnix *ms = msList.takeFirst(); + MythSystemLegacyUnix *ms = msList.takeFirst(); listLock.unlock(); // This can happen if it has been deleted already @@ -546,11 +546,11 @@ void MythSystemSignalManager::run(void) } /******************************* - * MythSystem method defines + * MythSystemLegacy method defines ******************************/ -MythSystemUnix::MythSystemUnix(MythSystem *parent) : - MythSystemPrivate("MythSystemUnix") +MythSystemLegacyUnix::MythSystemLegacyUnix(MythSystemLegacy *parent) : + MythSystemLegacyPrivate("MythSystemLegacyUnix") { m_parent = parent; @@ -563,34 +563,34 @@ MythSystemUnix::MythSystemUnix(MythSystem *parent) : // Start the threads if they haven't been started yet. if( manager == NULL ) { - manager = new MythSystemManager; + manager = new MythSystemLegacyManager; manager->start(); } if( smanager == NULL ) { - smanager = new MythSystemSignalManager; + smanager = new MythSystemLegacySignalManager; smanager->start(); } if( readThread == NULL ) { - readThread = new MythSystemIOHandler(true); + readThread = new MythSystemLegacyIOHandler(true); readThread->start(); } if( writeThread == NULL ) { - writeThread = new MythSystemIOHandler(false); + writeThread = new MythSystemLegacyIOHandler(false); writeThread->start(); } } -MythSystemUnix::~MythSystemUnix(void) +MythSystemLegacyUnix::~MythSystemLegacyUnix(void) { } -bool MythSystemUnix::ParseShell(const QString &cmd, QString &abscmd, +bool MythSystemLegacyUnix::ParseShell(const QString &cmd, QString &abscmd, QStringList &args) { QList whitespace; whitespace << ' ' << '\t' << '\n' << '\r'; @@ -716,7 +716,7 @@ bool MythSystemUnix::ParseShell(const QString &cmd, QString &abscmd, return true; } -void MythSystemUnix::Term(bool force) +void MythSystemLegacyUnix::Term(bool force) { int status = GetStatus(); if( (status != GENERIC_EXIT_RUNNING && status != GENERIC_EXIT_TIMEOUT) || @@ -736,7 +736,7 @@ void MythSystemUnix::Term(bool force) } } -void MythSystemUnix::Signal( int sig ) +void MythSystemLegacyUnix::Signal( int sig ) { int status = GetStatus(); if( (status != GENERIC_EXIT_RUNNING && status != GENERIC_EXIT_TIMEOUT) || @@ -753,7 +753,7 @@ void MythSystemUnix::Signal( int sig ) } #define MAX_BUFLEN 1024 -void MythSystemUnix::Fork(time_t timeout) +void MythSystemLegacyUnix::Fork(time_t timeout) { QString LOC_ERR = QString("myth_system('%1'): Error: ").arg(GetLogCmd()); @@ -1056,21 +1056,21 @@ void MythSystemUnix::Fork(time_t timeout) } } -void MythSystemUnix::Manage(void) +void MythSystemLegacyUnix::Manage(void) { if( manager == NULL ) { - manager = new MythSystemManager; + manager = new MythSystemLegacyManager; manager->start(); } manager->append(this); } -void MythSystemUnix::JumpAbort(void) +void MythSystemLegacyUnix::JumpAbort(void) { if( manager == NULL ) { - manager = new MythSystemManager; + manager = new MythSystemLegacyManager; manager->start(); } manager->jumpAbort(); diff --git a/mythtv/libs/libmythbase/mythsystemunix.h b/mythtv/libs/libmythbase/mythsystemunix.h index afd894d7fa5..8eef979257b 100644 --- a/mythtv/libs/libmythbase/mythsystemunix.h +++ b/mythtv/libs/libmythbase/mythsystemunix.h @@ -18,20 +18,20 @@ #include "mythsystemprivate.h" #include "mythbaseexp.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mthread.h" -class MythSystemUnix; +class MythSystemLegacyUnix; -typedef QMap > MSMap_t; +typedef QMap > MSMap_t; typedef QMap PMap_t; -typedef QList > MSList_t; +typedef QList > MSList_t; -class MythSystemIOHandler: public MThread +class MythSystemLegacyIOHandler: public MThread { public: - MythSystemIOHandler(bool read); - ~MythSystemIOHandler() { wait(); } + MythSystemLegacyIOHandler(bool read); + ~MythSystemLegacyIOHandler() { wait(); } void run(void); void insert(int fd, QBuffer *buff); @@ -54,13 +54,13 @@ class MythSystemIOHandler: public MThread char m_readbuf[65536]; }; -class MythSystemManager : public MThread +class MythSystemLegacyManager : public MThread { public: - MythSystemManager(); - ~MythSystemManager() { wait(); } + MythSystemLegacyManager(); + ~MythSystemLegacyManager() { wait(); } void run(void); - void append(MythSystemUnix *); + void append(MythSystemLegacyUnix *); void jumpAbort(void); private: MSMap_t m_pMap; @@ -69,23 +69,23 @@ class MythSystemManager : public MThread QMutex m_jumpLock; }; -class MythSystemSignalManager : public MThread +class MythSystemLegacySignalManager : public MThread { public: - MythSystemSignalManager(); - ~MythSystemSignalManager() { wait(); } + MythSystemLegacySignalManager(); + ~MythSystemLegacySignalManager() { wait(); } void run(void); private: }; -class MBASE_PUBLIC MythSystemUnix : public MythSystemPrivate +class MBASE_PUBLIC MythSystemLegacyUnix : public MythSystemLegacyPrivate { Q_OBJECT public: - MythSystemUnix(MythSystem *parent); - ~MythSystemUnix(); + MythSystemLegacyUnix(MythSystemLegacy *parent); + ~MythSystemLegacyUnix(); virtual void Fork(time_t timeout) MOVERRIDE; virtual void Manage(void) MOVERRIDE; @@ -97,9 +97,9 @@ class MBASE_PUBLIC MythSystemUnix : public MythSystemPrivate virtual bool ParseShell(const QString &cmd, QString &abscmd, QStringList &args) MOVERRIDE; - friend class MythSystemManager; - friend class MythSystemSignalManager; - friend class MythSystemIOHandler; + friend class MythSystemLegacyManager; + friend class MythSystemLegacySignalManager; + friend class MythSystemLegacyIOHandler; private: pid_t m_pid; diff --git a/mythtv/libs/libmythbase/mythsystemwindows.cpp b/mythtv/libs/libmythbase/mythsystemwindows.cpp index 8b57d9985f3..fd8ad8795cd 100644 --- a/mythtv/libs/libmythbase/mythsystemwindows.cpp +++ b/mythtv/libs/libmythbase/mythsystemwindows.cpp @@ -3,7 +3,7 @@ #include "compat.h" // Own header -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythsystemwindows.h" // C++/C headers @@ -45,25 +45,25 @@ if( (x) ) { \ typedef struct { - MythSystemWindows *ms; + MythSystemLegacyWindows *ms; int type; } FDType_t; typedef QMap FDMap_t; /********************************** - * MythSystemManager method defines + * MythSystemLegacyManager method defines *********************************/ static bool run_system = true; -static MythSystemManager *manager = NULL; -static MythSystemSignalManager *smanager = NULL; -static MythSystemIOHandler *readThread = NULL; -static MythSystemIOHandler *writeThread = NULL; +static MythSystemLegacyManager *manager = NULL; +static MythSystemLegacySignalManager *smanager = NULL; +static MythSystemLegacyIOHandler *readThread = NULL; +static MythSystemLegacyIOHandler *writeThread = NULL; static MSList_t msList; static QMutex listLock; static FDMap_t fdMap; static QMutex fdLock; -void ShutdownMythSystem(void) +void ShutdownMythSystemLegacy(void) { run_system = false; if (manager) @@ -76,14 +76,14 @@ void ShutdownMythSystem(void) writeThread->wait(); } -MythSystemIOHandler::MythSystemIOHandler(bool read) : +MythSystemLegacyIOHandler::MythSystemLegacyIOHandler(bool read) : MThread(QString("SystemIOHandler%1").arg(read ? "R" : "W")), m_pWaitLock(), m_pWait(), m_pLock(), m_pMap(PMap_t()), m_read(read) { } -void MythSystemIOHandler::run(void) +void MythSystemLegacyIOHandler::run(void) { RunProlog(); @@ -132,7 +132,7 @@ void MythSystemIOHandler::run(void) RunEpilog(); } -bool MythSystemIOHandler::HandleRead(HANDLE h, QBuffer *buff) +bool MythSystemLegacyIOHandler::HandleRead(HANDLE h, QBuffer *buff) { DWORD lenAvail; @@ -152,20 +152,20 @@ bool MythSystemIOHandler::HandleRead(HANDLE h, QBuffer *buff) buff->buffer().append(m_readbuf, lenRead); - // Get the corresponding MythSystem instance, and the stdout/stderr + // Get the corresponding MythSystemLegacy instance, and the stdout/stderr // type fdLock.lock(); FDType_t *fdType = fdMap.value(h); fdLock.unlock(); // Emit the data ready signal (1 = stdout, 2 = stderr) - MythSystemWindows *ms = fdType->ms; + MythSystemLegacyWindows *ms = fdType->ms; emit ms->readDataReady(fdType->type); return true; } -bool MythSystemIOHandler::HandleWrite(HANDLE h, QBuffer *buff) +bool MythSystemLegacyIOHandler::HandleWrite(HANDLE h, QBuffer *buff) { if( buff->atEnd() ) { @@ -190,7 +190,7 @@ bool MythSystemIOHandler::HandleWrite(HANDLE h, QBuffer *buff) return true; } -void MythSystemIOHandler::insert(HANDLE h, QBuffer *buff) +void MythSystemLegacyIOHandler::insert(HANDLE h, QBuffer *buff) { m_pLock.lock(); m_pMap.insert(h, buff); @@ -198,7 +198,7 @@ void MythSystemIOHandler::insert(HANDLE h, QBuffer *buff) wake(); } -void MythSystemIOHandler::remove(HANDLE h) +void MythSystemLegacyIOHandler::remove(HANDLE h) { m_pLock.lock(); if (m_read) @@ -211,14 +211,14 @@ void MythSystemIOHandler::remove(HANDLE h) m_pLock.unlock(); } -void MythSystemIOHandler::wake() +void MythSystemLegacyIOHandler::wake() { QMutexLocker locker(&m_pWaitLock); m_pWait.wakeAll(); } -MythSystemManager::MythSystemManager() : +MythSystemLegacyManager::MythSystemLegacyManager() : MThread("SystemManager") { m_jumpAbort = false; @@ -226,14 +226,14 @@ MythSystemManager::MythSystemManager() : m_children = NULL; } -MythSystemManager::~MythSystemManager() +MythSystemLegacyManager::~MythSystemLegacyManager() { if (m_children) free( m_children ); wait(); } -void MythSystemManager::run(void) +void MythSystemLegacyManager::run(void) { RunProlog(); @@ -271,7 +271,7 @@ void MythSystemManager::run(void) HANDLE child = m_children[index]; // pop exited process off managed list, add to cleanup list - MythSystemWindows *ms = m_pMap.take(child); + MythSystemLegacyWindows *ms = m_pMap.take(child); ChildListRebuild(); m_mapLock.unlock(); @@ -360,7 +360,7 @@ void MythSystemManager::run(void) } // NOTE: This is only to be run while m_mapLock is locked!!! -void MythSystemManager::ChildListRebuild() +void MythSystemLegacyManager::ChildListRebuild() { int oldCount; @@ -394,7 +394,7 @@ void MythSystemManager::ChildListRebuild() } } -void MythSystemManager::append(MythSystemWindows *ms) +void MythSystemLegacyManager::append(MythSystemLegacyWindows *ms) { m_mapLock.lock(); ms->IncrRef(); @@ -428,7 +428,7 @@ void MythSystemManager::append(MythSystemWindows *ms) } } -void MythSystemManager::jumpAbort(void) +void MythSystemLegacyManager::jumpAbort(void) { m_jumpLock.lock(); m_jumpAbort = true; @@ -437,12 +437,12 @@ void MythSystemManager::jumpAbort(void) // spawn separate thread for signals to prevent manager // thread from blocking in some slot -MythSystemSignalManager::MythSystemSignalManager() : +MythSystemLegacySignalManager::MythSystemLegacySignalManager() : MThread("SystemSignalManager") { } -void MythSystemSignalManager::run(void) +void MythSystemLegacySignalManager::run(void) { RunProlog(); @@ -459,7 +459,7 @@ void MythSystemSignalManager::run(void) listLock.unlock(); break; } - MythSystemWindows *ms = msList.takeFirst(); + MythSystemLegacyWindows *ms = msList.takeFirst(); listLock.unlock(); if (!ms) @@ -501,11 +501,11 @@ void MythSystemSignalManager::run(void) } /******************************* - * MythSystem method defines + * MythSystemLegacy method defines ******************************/ -MythSystemWindows::MythSystemWindows(MythSystem *parent) : - MythSystemPrivate("MythSystemWindows") +MythSystemLegacyWindows::MythSystemLegacyWindows(MythSystemLegacy *parent) : + MythSystemLegacyPrivate("MythSystemLegacyWindows") { m_parent = parent; @@ -518,39 +518,39 @@ MythSystemWindows::MythSystemWindows(MythSystem *parent) : // Start the threads if they haven't been started yet. if (manager == NULL) { - manager = new MythSystemManager; + manager = new MythSystemLegacyManager; manager->start(); } if (smanager == NULL) { - smanager = new MythSystemSignalManager; + smanager = new MythSystemLegacySignalManager; smanager->start(); } if (readThread == NULL) { - readThread = new MythSystemIOHandler(true); + readThread = new MythSystemLegacyIOHandler(true); readThread->start(); } if (writeThread == NULL) { - writeThread = new MythSystemIOHandler(false); + writeThread = new MythSystemLegacyIOHandler(false); writeThread->start(); } } -MythSystemWindows::~MythSystemWindows(void) +MythSystemLegacyWindows::~MythSystemLegacyWindows(void) { } -bool MythSystemWindows::ParseShell(const QString&, QString &, QStringList&) +bool MythSystemLegacyWindows::ParseShell(const QString&, QString &, QStringList&) { return false; } -void MythSystemWindows::Term(bool force) +void MythSystemLegacyWindows::Term(bool force) { if( (GetStatus() != GENERIC_EXIT_RUNNING) || (!m_child) ) return; @@ -564,7 +564,7 @@ void MythSystemWindows::Term(bool force) } } -void MythSystemWindows::Signal( int sig ) +void MythSystemLegacyWindows::Signal( int sig ) { if( (GetStatus() != GENERIC_EXIT_RUNNING) || (!m_child) ) return; @@ -575,7 +575,7 @@ void MythSystemWindows::Signal( int sig ) #define MAX_BUFLEN 1024 -void MythSystemWindows::Fork(time_t timeout) +void MythSystemLegacyWindows::Fork(time_t timeout) { QString LOC_ERR = QString("myth_system('%1'): Error: ").arg(GetLogCmd()); @@ -754,21 +754,21 @@ void MythSystemWindows::Fork(time_t timeout) } } -void MythSystemWindows::Manage(void) +void MythSystemLegacyWindows::Manage(void) { if( manager == NULL ) { - manager = new MythSystemManager; + manager = new MythSystemLegacyManager; manager->start(); } manager->append(this); } -void MythSystemWindows::JumpAbort(void) +void MythSystemLegacyWindows::JumpAbort(void) { if( manager == NULL ) { - manager = new MythSystemManager; + manager = new MythSystemLegacyManager; manager->start(); } manager->jumpAbort(); diff --git a/mythtv/libs/libmythbase/mythsystemwindows.h b/mythtv/libs/libmythbase/mythsystemwindows.h index 8d75d0bc3b1..74d191dec0f 100644 --- a/mythtv/libs/libmythbase/mythsystemwindows.h +++ b/mythtv/libs/libmythbase/mythsystemwindows.h @@ -14,20 +14,20 @@ #include "mythsystemprivate.h" #include "mythbaseexp.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mthread.h" -class MythSystemWindows; +class MythSystemLegacyWindows; -typedef QMap MSMap_t; +typedef QMap MSMap_t; typedef QMap PMap_t; -typedef QList MSList_t; +typedef QList MSList_t; -class MythSystemIOHandler: public MThread +class MythSystemLegacyIOHandler: public MThread { public: - MythSystemIOHandler(bool read); - ~MythSystemIOHandler() { wait(); } + MythSystemLegacyIOHandler(bool read); + ~MythSystemLegacyIOHandler() { wait(); } void run(void); void insert(HANDLE h, QBuffer *buff); @@ -47,13 +47,13 @@ class MythSystemIOHandler: public MThread char m_readbuf[65536]; }; -class MythSystemManager : public MThread +class MythSystemLegacyManager : public MThread { public: - MythSystemManager(); - ~MythSystemManager(); + MythSystemLegacyManager(); + ~MythSystemLegacyManager(); void run(void); - void append(MythSystemWindows *); + void append(MythSystemLegacyWindows *); void jumpAbort(void); private: @@ -68,23 +68,23 @@ class MythSystemManager : public MThread QMutex m_jumpLock; }; -class MythSystemSignalManager : public MThread +class MythSystemLegacySignalManager : public MThread { public: - MythSystemSignalManager(); - ~MythSystemSignalManager() { wait(); } + MythSystemLegacySignalManager(); + ~MythSystemLegacySignalManager() { wait(); } void run(void); private: }; -class MBASE_PUBLIC MythSystemWindows : public MythSystemPrivate +class MBASE_PUBLIC MythSystemLegacyWindows : public MythSystemLegacyPrivate { Q_OBJECT public: - MythSystemWindows(MythSystem *parent); - ~MythSystemWindows(); + MythSystemLegacyWindows(MythSystemLegacy *parent); + ~MythSystemLegacyWindows(); virtual void Fork(time_t timeout) MOVERRIDE; virtual void Manage(void) MOVERRIDE; @@ -96,9 +96,9 @@ class MBASE_PUBLIC MythSystemWindows : public MythSystemPrivate virtual bool ParseShell(const QString &cmd, QString &abscmd, QStringList &args) MOVERRIDE; - friend class MythSystemManager; - friend class MythSystemSignalManager; - friend class MythSystemIOHandler; + friend class MythSystemLegacyManager; + friend class MythSystemLegacySignalManager; + friend class MythSystemLegacyIOHandler; private: HANDLE m_child; diff --git a/mythtv/libs/libmythbase/test/test_mythsystem/test_mythsystem.h b/mythtv/libs/libmythbase/test/test_mythsystem/test_mythsystem.h index 802a3928249..820687a0864 100644 --- a/mythtv/libs/libmythbase/test/test_mythsystem/test_mythsystem.h +++ b/mythtv/libs/libmythbase/test/test_mythsystem/test_mythsystem.h @@ -55,12 +55,6 @@ class TestMythSystem: public QObject QDateTime m_before; - void Go(MythSystem &s) - { - s.Run(); - (void) s.Wait(); - } - private slots: // called at the beginning of these sets of tests void initTestCase(void) @@ -77,7 +71,6 @@ class TestMythSystem: public QObject // called at the end of these sets of tests void cleanupTestCase(void) { - ShutdownMythSystem(); } // called before each test case @@ -92,25 +85,37 @@ class TestMythSystem: public QObject m_before = QDateTime(); } +#if 0 void constructed_command_is_run(void) { - MythSystem cmd(QString("echo %1").arg(__FUNCTION__), kMSStdOut); - Go(cmd); - QVERIFY(QString(cmd.ReadAll()).contains(__FUNCTION__)); + QScopedPointer cmd( + MythSystem::Create( + QString("echo %1").arg(__FUNCTION__), kMSStdOut)); + cmd->Wait(); + QVERIFY(QString(cmd->ReadAll()).contains(__FUNCTION__)); + } +#endif + + void wait_returns_true_on_exit(void) + { + QScopedPointer cmd( + MythSystem::Create("exit 200", kMSRunShell)); + QVERIFY(cmd->Wait()); } - void wait_returns_exit_code(void) + void wait_returns_false_on_timeout(void) { - MythSystem cmd("exit 200", kMSNone | kMSRunShell); - cmd.Run(); - QVERIFY(cmd.Wait() == 200); + QScopedPointer cmd( + MythSystem::Create("sleep 2", kMSRunShell)); + QVERIFY(!cmd->Wait(1)); } void getstatus_returns_exit_code(void) { - MythSystem cmd("exit 200", kMSNone | kMSRunShell); - Go(cmd); - QVERIFY(cmd.GetStatus() == 200); + QScopedPointer cmd( + MythSystem::Create("exit 200", kMSRunShell)); + cmd->Wait(); + QVERIFY(cmd->GetExitCode() == 200); } // TODO kMSDontBlockInputDevs -- avoid blocking LIRC & Joystick Menu @@ -119,14 +124,16 @@ class TestMythSystem: public QObject // tests kMSRunBackground -- run child in the background void run_in_background_works(void) { - MythSystem cmd("sleep 1", kMSRunBackground); - Go(cmd); - QVERIFY(m_before.msecsTo(QDateTime::currentDateTime()) < 500); + QScopedPointer cmd( + MythSystem::Create("sleep 0.5", kMSRunBackground)); + cmd->Wait(); + QVERIFY(m_before.msecsTo(QDateTime::currentDateTime()) < 400); } // TODO kMSProcessEvents -- process events while waiting // TODO kMSInUi -- the parent is in the UI +#if 0 // kMSStdIn -- allow access to stdin void stdin_works(void) { @@ -134,51 +141,66 @@ class TestMythSystem: public QObject QTemporaryFile tempfile; tempfile.open(); QByteArray in = QString(__FUNCTION__).toLatin1(); - MythSystem cmd(QString("cat - > %1").arg(tempfile.fileName()), - kMSStdIn); - cmd.Write(in); - Go(cmd); - QVERIFY(cmd.GetStatus() == 0); + QScopedPointer cmd( + MythSystem::Create(QString("cat - > %1").arg(tempfile.fileName()), + kMSStdIn)); + cmd->Write(in); + cmd->Wait(); + QVERIFY(cmd->GetExitCode() == 0); QByteArray out = tempfile.readAll(); QVERIFY(QString(out).contains(QString(in))); } +#endif +#if 0 // kMSStdOut -- allow access to stdout void stdout_works(void) { - MythSystem cmd(QString("echo %1").arg(__FUNCTION__), kMSStdOut); - Go(cmd); - QVERIFY(cmd.GetStatus() == 0); - QVERIFY(QString(cmd.ReadAll()).contains(__FUNCTION__)); + QScopedPointer cmd( + MythSystem::Create(QString("echo %1").arg(__FUNCTION__), + kMSStdOut)); + cmd->Wait(); + QVERIFY(cmd->GetExitCode() == 0); + QVERIFY(QString(cmd->ReadAll()).contains(__FUNCTION__)); } +#endif +#if 0 // kMSStdErr -- allow access to stderr void stderr_works(void) { - MythSystem cmd(QString("echo %1 >&2").arg(__FUNCTION__), - kMSRunShell | kMSStdErr); - Go(cmd); - QVERIFY(cmd.GetStatus() == 0); - QVERIFY(QString(cmd.ReadAllErr()).contains(__FUNCTION__)); + QScopedPointer cmd( + MythSystem::Create(QString("echo %1 >&2").arg(__FUNCTION__), + kMSRunShell | kMSStdErr)); + cmd->Wait(); + QVERIFY(cmd->GetExitCode() == 0); + QVERIFY(QString(cmd->ReadAllErr()).contains(__FUNCTION__)); } +#endif // TODO kMSBuffered -- buffer the IO channels +#if 0 // kMSRunShell -- run process through shell void shell_used_when_requested(void) { - MythSystem cmd("if [ x != y ] ; then echo X ; else echo Y ; fi", - kMSRunShell | kMSStdOut); - Go(cmd); - QVERIFY(QString(cmd.ReadAll()).contains("X")); + QScopedPointer cmd( + MythSystem::Create("if [ x != y ] ; then echo X ; else echo Y ; fi", + kMSRunShell | kMSStdOut)); + cmd->Wait(); + QVERIFY(QString(cmd->ReadAll()).contains("X")); } +#endif +#if 0 void shell_not_used_when_not_requested(void) { - MythSystem cmd("if [ x != y ] ; then echo X ; else echo Y ; fi", - kMSStdOut); - Go(cmd); - QVERIFY(!QString(cmd.ReadAll()).contains("X")); + QScopedPointer cmd( + MythSystem::Create("if [ x != y ] ; then echo X ; else echo Y ; fi", + kMSStdOut)); + cmd->Wait(); + QVERIFY(!QString(cmd->ReadAll()).contains("X")); } +#endif // no need to test kMSNoRunShell, it is a no-op // TODO delete flag @@ -189,40 +211,17 @@ class TestMythSystem: public QObject { #ifdef NEW_LOGGING console_dbg()->Clear(); - MythSystem cmd(QString("echo %1").arg(__FUNCTION__), kMSAnonLog); - Go(cmd); + QScopedPointer cmd( + MythSystem::Create(QString("echo %1").arg(__FUNCTION__), + kMSAnonLog)); + cmd->Wait(); DebugLogHandlerEntry l = console_dbg()->LastEntry(kHandleLog); QVERIFY(!l.entry().GetMessage().contains(__FUNCTION__)); - QVERIFY(!cmd.GetLogCmd().contains(__FUNCTION__)); #else - MSKIP("Log inspection not supported in old logging."); + MSKIP("Log inspection not supported in old logging."); #endif } - // kMSAbortOnJump -- abort this process on a jumppoint - void abort_on_jump_works_when_requested(void) - { - MythSystem cmd(QString("sleep 0.50"), kMSAbortOnJump); - cmd.Run(); - usleep(5000); - cmd.JumpAbort(); - int ret = cmd.Wait(); - QVERIFY(m_before.msecsTo(QDateTime::currentDateTime()) < 400); - QVERIFY(0 != ret); - } - - // ! kMSAbortOnJump -- ! abort this process on a jumppoint - void abort_on_jump_noop_works_when_not_requested(void) - { - MythSystem cmd(QString("sleep 0.50"), kMSNone); - cmd.Run(); - usleep(5000); - cmd.JumpAbort(); - int ret = cmd.Wait(); - QVERIFY(m_before.msecsTo(QDateTime::currentDateTime()) > 400); - QVERIFY(0 == ret); - } - // TODO flags to test // TODO kMSSetPGID -- set the process group id // TODO kMSAutoCleanup -- automatically delete if backgrounded @@ -231,5 +230,6 @@ class TestMythSystem: public QObject // for the duration of application. // TODO kMSPropagateLogs -- add arguments for MythTV log propagation - // TODO test current GetStatus() results. + // TODO test current GetExitCode() results. + // TODO test current GetSignal() results. }; diff --git a/mythtv/libs/libmythbase/test/test_mythsystemlegacy/.gitignore b/mythtv/libs/libmythbase/test/test_mythsystemlegacy/.gitignore new file mode 100644 index 00000000000..b7449c8d382 --- /dev/null +++ b/mythtv/libs/libmythbase/test/test_mythsystemlegacy/.gitignore @@ -0,0 +1,5 @@ +test_mythsystemlegacy +*.gcda +*.gcno +*.gcov + diff --git a/mythtv/libs/libmythbase/test/test_mythsystemlegacy/test_mythsystemlegacy.cpp b/mythtv/libs/libmythbase/test/test_mythsystemlegacy/test_mythsystemlegacy.cpp new file mode 100644 index 00000000000..77d7916af79 --- /dev/null +++ b/mythtv/libs/libmythbase/test/test_mythsystemlegacy/test_mythsystemlegacy.cpp @@ -0,0 +1,3 @@ +#include "test_mythsystemlegacy.h" + +QTEST_APPLESS_MAIN(TestMythSystemLegacy) diff --git a/mythtv/libs/libmythbase/test/test_mythsystemlegacy/test_mythsystemlegacy.h b/mythtv/libs/libmythbase/test/test_mythsystemlegacy/test_mythsystemlegacy.h new file mode 100644 index 00000000000..bb0504c8105 --- /dev/null +++ b/mythtv/libs/libmythbase/test/test_mythsystemlegacy/test_mythsystemlegacy.h @@ -0,0 +1,211 @@ +/* + * Class TestMythSystemLegacy + * + * Copyright (C) Daniel Kristjansson 2013 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include // for usleep() + +#include +#include +#include + +#include +using namespace std; + +//#define NEW_LOGGING +#ifdef NEW_LOGGING +#include "mythlogging_extra.h" +#include "debugloghandler.h" +#endif + +#include "mythcorecontext.h" +#include "mythsystemlegacy.h" + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +#define MSKIP(MSG) QSKIP(MSG, SkipSingle) +#else +#define MSKIP(MSG) QSKIP(MSG) +#endif + +#ifdef NEW_LOGGING +static DebugLogHandler *console_dbg(void) +{ + return DebugLogHandler::Get("ConsoleLogHandler"); +} +#endif + +class TestMythSystemLegacy: public QObject +{ + Q_OBJECT + + QDateTime m_before; + + void Go(MythSystemLegacy &s) + { + s.Run(); + (void) s.Wait(); + } + + private slots: + // called at the beginning of these sets of tests + void initTestCase(void) + { + gCoreContext = new MythCoreContext("bin_version", NULL); +#ifdef NEW_LOGGING + DebugLogHandler::AddReplacement("ConsoleLogHandler"); + myth_logging::initialize_logging( + VB_GENERAL, LOG_INFO, kNoFacility, /*use_threads*/false, + /*logfile*/ QString(), /*logprefix*/QString()); +#endif + } + + // called at the end of these sets of tests + void cleanupTestCase(void) + { + ShutdownMythSystemLegacy(); + } + + // called before each test case + void init(void) + { + m_before = QDateTime::currentDateTime(); + } + + // called after each test case + void cleanup(void) + { + m_before = QDateTime(); + } + + void constructed_command_is_run(void) + { + MythSystemLegacy cmd(QString("echo %1").arg(__FUNCTION__), kMSStdOut); + Go(cmd); + QVERIFY(QString(cmd.ReadAll()).contains(__FUNCTION__)); + } + + void wait_returns_exit_code(void) + { + MythSystemLegacy cmd("exit 200", kMSNone | kMSRunShell); + cmd.Run(); + QVERIFY(cmd.Wait() == 200); + } + + void getstatus_returns_exit_code(void) + { + MythSystemLegacy cmd("exit 200", kMSNone | kMSRunShell); + Go(cmd); + QVERIFY(cmd.GetStatus() == 200); + } + + // TODO kMSDontBlockInputDevs -- avoid blocking LIRC & Joystick Menu + // TODO kMSDontDisableDrawing -- avoid disabling UI drawing + + // tests kMSRunBackground -- run child in the background + void run_in_background_works(void) + { + MythSystemLegacy cmd("sleep 1", kMSRunBackground); + Go(cmd); + QVERIFY(m_before.msecsTo(QDateTime::currentDateTime()) < 500); + } + + // TODO kMSProcessEvents -- process events while waiting + // TODO kMSInUi -- the parent is in the UI + + // kMSStdIn -- allow access to stdin + void stdin_works(void) + { + MSKIP("stdin_works -- currently blocks forever"); + QTemporaryFile tempfile; + tempfile.open(); + QByteArray in = QString(__FUNCTION__).toLatin1(); + MythSystemLegacy cmd(QString("cat - > %1").arg(tempfile.fileName()), + kMSStdIn); + cmd.Write(in); + Go(cmd); + QVERIFY(cmd.GetStatus() == 0); + QByteArray out = tempfile.readAll(); + QVERIFY(QString(out).contains(QString(in))); + } + + // kMSStdOut -- allow access to stdout + void stdout_works(void) + { + MythSystemLegacy cmd(QString("echo %1").arg(__FUNCTION__), kMSStdOut); + Go(cmd); + QVERIFY(cmd.GetStatus() == 0); + QVERIFY(QString(cmd.ReadAll()).contains(__FUNCTION__)); + } + + // kMSStdErr -- allow access to stderr + void stderr_works(void) + { + MythSystemLegacy cmd(QString("echo %1 >&2").arg(__FUNCTION__), + kMSRunShell | kMSStdErr); + Go(cmd); + QVERIFY(cmd.GetStatus() == 0); + QVERIFY(QString(cmd.ReadAllErr()).contains(__FUNCTION__)); + } + // TODO kMSBuffered -- buffer the IO channels + + // kMSRunShell -- run process through shell + void shell_used_when_requested(void) + { + MythSystemLegacy cmd("if [ x != y ] ; then echo X ; else echo Y ; fi", + kMSRunShell | kMSStdOut); + Go(cmd); + QVERIFY(QString(cmd.ReadAll()).contains("X")); + } + + void shell_not_used_when_not_requested(void) + { + MythSystemLegacy cmd("if [ x != y ] ; then echo X ; else echo Y ; fi", + kMSStdOut); + Go(cmd); + QVERIFY(!QString(cmd.ReadAll()).contains("X")); + } + + // no need to test kMSNoRunShell, it is a no-op + // TODO delete flag + // kMSNoRunShell -- do NOT run process through shell + + // kMSAnonLog -- anonymize the logs + void logs_anonymized_when_requested(void) + { +#ifdef NEW_LOGGING + console_dbg()->Clear(); + MythSystemLegacy cmd(QString("echo %1").arg(__FUNCTION__), kMSAnonLog); + Go(cmd); + DebugLogHandlerEntry l = console_dbg()->LastEntry(kHandleLog); + QVERIFY(!l.entry().GetMessage().contains(__FUNCTION__)); + QVERIFY(!cmd.GetLogCmd().contains(__FUNCTION__)); +#else + MSKIP("Log inspection not supported in old logging."); +#endif + } + + // TODO flags to test + // TODO kMSSetPGID -- set the process group id + // TODO kMSAutoCleanup -- automatically delete if backgrounded + // TODO kMSLowExitVal -- allow exit values 0-127 only + // TODO kMSDisableUDPListener -- disable MythMessage UDP listener + // for the duration of application. + // TODO kMSPropagateLogs -- add arguments for MythTV log propagation + + // TODO test current GetStatus() results. +}; diff --git a/mythtv/libs/libmythbase/test/test_mythsystemlegacy/test_mythsystemlegacy.pro b/mythtv/libs/libmythbase/test/test_mythsystemlegacy/test_mythsystemlegacy.pro new file mode 100644 index 00000000000..0d8f2f13d54 --- /dev/null +++ b/mythtv/libs/libmythbase/test/test_mythsystemlegacy/test_mythsystemlegacy.pro @@ -0,0 +1,34 @@ +include ( ../../../../settings.pro ) + +QT += xml sql network + +contains(QT_VERSION, ^4\\.[0-9]\\..*) { +CONFIG += qtestlib +} +contains(QT_VERSION, ^5\\.[0-9]\\..*) { +QT += testlib +} + +TEMPLATE = app +TARGET = test_mythsystemlegacy +DEPENDPATH += . ../.. ../../logging +INCLUDEPATH += . ../.. ../../logging +LIBS += -L../.. -lmythbase-$$LIBVERSION +LIBS += -Wl,-rpath,$${PWD}/../.. + +contains(QMAKE_CXX, "g++") { + QMAKE_CXXFLAGS += -O0 -fprofile-arcs -ftest-coverage + QMAKE_LFLAGS += -fprofile-arcs +} +QMAKE_LFLAGS += -Wl,-rpath=$(PWD)/../../../../external/zeromq/src/.libs/ +QMAKE_LFLAGS += -Wl,-rpath=$(PWD)/../../../../external/nzmqt/src/ +QMAKE_LFLAGS += -Wl,-rpath=$(PWD)/../../../../external/qjson/lib/ + +# Input +HEADERS += test_mythsystemlegacy.h +SOURCES += test_mythsystemlegacy.cpp + +QMAKE_CLEAN += $(TARGET) $(TARGETA) $(TARGETD) $(TARGET0) $(TARGET1) $(TARGET2) +QMAKE_CLEAN += ; rm -f *.gcov *.gcda *.gcno + +LIBS += $$EXTRA_LIBS $$LATE_LIBS diff --git a/mythtv/libs/libmythmetadata/metadatadownload.cpp b/mythtv/libs/libmythmetadata/metadatadownload.cpp index 151f0920c81..3c78f5edd6c 100644 --- a/mythtv/libs/libmythmetadata/metadatadownload.cpp +++ b/mythtv/libs/libmythmetadata/metadatadownload.cpp @@ -8,7 +8,7 @@ #include "mythcorecontext.h" #include "mythdirs.h" #include "mythuihelper.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "storagegroup.h" #include "metadatadownload.h" #include "mythmiscutil.h" @@ -249,7 +249,7 @@ MetadataLookupList MetadataDownload::runGrabber(QString cmd, QStringList args, MetadataLookup* lookup, bool passseas) { - MythSystem grabber(cmd, args, kMSNoRunShell | kMSStdOut | kMSBuffered); + MythSystemLegacy grabber(cmd, args, kMSStdOut | kMSBuffered); MetadataLookupList list; LOG(VB_GENERAL, LOG_INFO, QString("Running Grabber: %1 %2") @@ -311,7 +311,7 @@ bool MetadataDownload::runGrabberTest(const QString &grabberpath) QStringList args; args.append("-t"); - MythSystem grabber(grabberpath, args, kMSNoRunShell | kMSStdOut | kMSBuffered); + MythSystemLegacy grabber(grabberpath, args, kMSStdOut | kMSBuffered); grabber.Run(); uint exitcode = grabber.Wait(); diff --git a/mythtv/libs/libmythmetadata/videoutils.cpp b/mythtv/libs/libmythmetadata/videoutils.cpp index 42ee280f399..9fc0b893e0d 100644 --- a/mythtv/libs/libmythmetadata/videoutils.cpp +++ b/mythtv/libs/libmythmetadata/videoutils.cpp @@ -3,7 +3,7 @@ #include "mythcontext.h" #include "mythdirs.h" #include "mythmainwindow.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythdialogbox.h" #include "mythuistatetype.h" #include "mythuiimage.h" diff --git a/mythtv/libs/libmythtv/HLS/httplivestream.cpp b/mythtv/libs/libmythtv/HLS/httplivestream.cpp index cb51fce491e..07e01115955 100644 --- a/mythtv/libs/libmythtv/HLS/httplivestream.cpp +++ b/mythtv/libs/libmythtv/HLS/httplivestream.cpp @@ -37,7 +37,7 @@ #include "mythdirs.h" #include "mythtimer.h" #include "mthreadpool.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #include "mythlogging.h" #include "storagegroup.h" diff --git a/mythtv/libs/libmythtv/datadirect.cpp b/mythtv/libs/libmythtv/datadirect.cpp index 707300844e6..fd36686be91 100644 --- a/mythtv/libs/libmythtv/datadirect.cpp +++ b/mythtv/libs/libmythtv/datadirect.cpp @@ -21,7 +21,7 @@ #include "mythversion.h" #include "mythdate.h" #include "dbutil.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #include "mythdownloadmanager.h" #include "mythtvexp.h" diff --git a/mythtv/libs/libmythtv/jobqueue.cpp b/mythtv/libs/libmythtv/jobqueue.cpp index b29aa095fb1..f426309889d 100644 --- a/mythtv/libs/libmythtv/jobqueue.cpp +++ b/mythtv/libs/libmythtv/jobqueue.cpp @@ -29,7 +29,7 @@ using namespace std; #include "mythdb.h" #include "mythdirs.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythlogging.h" #include "mythmiscutil.h" diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp index 66c8c7dc3db..703c7ed4954 100644 --- a/mythtv/libs/libmythtv/mythplayer.cpp +++ b/mythtv/libs/libmythtv/mythplayer.cpp @@ -2659,7 +2659,7 @@ void MythPlayer::JumpToProgram(void) return; } - SendMythSystemPlayEvent("PLAY_CHANGED", pginfo); + SendMythSystemLegacyPlayEvent("PLAY_CHANGED", pginfo); if (player_ctx->buffer->GetType() == ICRingBuffer::kRingBufferType) { diff --git a/mythtv/libs/libmythtv/mythsystemevent.cpp b/mythtv/libs/libmythtv/mythsystemevent.cpp index 8df3c59582e..549c7a64997 100644 --- a/mythtv/libs/libmythtv/mythsystemevent.cpp +++ b/mythtv/libs/libmythtv/mythsystemevent.cpp @@ -5,17 +5,17 @@ #include "mythcorecontext.h" #include "mthreadpool.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythsystemevent.h" #include "programinfo.h" #include "remoteutil.h" #include "exitcodes.h" #include "mythlogging.h" -#define LOC QString("MythSystemEventHandler: ") +#define LOC QString("MythSystemLegacyEventHandler: ") /** \class SystemEventThread - * \brief QRunnable class for running MythSystemEvent handler commands + * \brief QRunnable class for running MythSystemLegacyEvent handler commands * * The SystemEventThread class runs a system event handler command in * non-blocking mode. The commands are run in the MThreadPool::globalInstance, @@ -69,28 +69,28 @@ class SystemEventThread : public QRunnable }; -/** \fn MythSystemEventHandler::MythSystemEventHandler(void) +/** \fn MythSystemLegacyEventHandler::MythSystemLegacyEventHandler(void) * \brief Null Constructor * * Adds this object as a gContext event listener. */ -MythSystemEventHandler::MythSystemEventHandler(void) +MythSystemLegacyEventHandler::MythSystemLegacyEventHandler(void) { - setObjectName("MythSystemEventHandler"); + setObjectName("MythSystemLegacyEventHandler"); gCoreContext->addListener(this); } -/** \fn MythSystemEventHandler::~MythSystemEventHandler() +/** \fn MythSystemLegacyEventHandler::~MythSystemLegacyEventHandler() * \brief Destructor * * Removes this object as a gContext event listener. */ -MythSystemEventHandler::~MythSystemEventHandler() +MythSystemLegacyEventHandler::~MythSystemLegacyEventHandler() { gCoreContext->removeListener(this); } -/** \fn MythSystemEventHandler::SubstituteMatches(const QStringList &tokens, +/** \fn MythSystemLegacyEventHandler::SubstituteMatches(const QStringList &tokens, QString &command) * \brief Substitutes %MATCH% variables in given command line. * \sa ProgramInfo::SubstituteMatches(QString &str) @@ -103,7 +103,7 @@ MythSystemEventHandler::~MythSystemEventHandler() * \param tokens Const QStringList containing token list passed with event. * \param command Command line containing %MATCH% variables to be substituted. */ -void MythSystemEventHandler::SubstituteMatches(const QStringList &tokens, +void MythSystemLegacyEventHandler::SubstituteMatches(const QStringList &tokens, QString &command) { if (command.isEmpty()) @@ -212,8 +212,8 @@ void MythSystemEventHandler::SubstituteMatches(const QStringList &tokens, .arg(command)); } -/** \fn MythSystemEventHandler::EventNameToSetting(const QString &name) - * \brief Convert an MythSystemEvent name to a database setting name +/** \fn MythSystemLegacyEventHandler::EventNameToSetting(const QString &name) + * \brief Convert an MythSystemLegacyEvent name to a database setting name * * Converts an underscored, all-capital-letters system event name of the form * NET_CTRL_CONNECTED to the corresponding CamelCase database setting @@ -221,7 +221,7 @@ void MythSystemEventHandler::SubstituteMatches(const QStringList &tokens, * * \param name Const QString containing System Event name to convert */ -QString MythSystemEventHandler::EventNameToSetting(const QString &name) +QString MythSystemLegacyEventHandler::EventNameToSetting(const QString &name) { QString result("EventCmd"); QStringList parts = name.toLower().split('_', QString::SkipEmptyParts); @@ -238,11 +238,11 @@ QString MythSystemEventHandler::EventNameToSetting(const QString &name) return result; } -/** \fn MythSystemEventHandler::customEvent(QEvent *e) +/** \fn MythSystemLegacyEventHandler::customEvent(QEvent *e) * \brief Custom Event handler for receiving and processing System Events - * \sa MythSystemEventHandler::SubstituteMatches(const QStringList &tokens, + * \sa MythSystemLegacyEventHandler::SubstituteMatches(const QStringList &tokens, QString &command) - * MythSystemEventHandler::EventNameToSetting(const QString &name) + * MythSystemLegacyEventHandler::EventNameToSetting(const QString &name) * * This function listens for SYSTEM_EVENT messages and fires off any * necessary event handler commands. In addition to SYSTEM_EVENT messages, @@ -253,7 +253,7 @@ QString MythSystemEventHandler::EventNameToSetting(const QString &name) * * \param e Pointer to QEvent containing event to handle */ -void MythSystemEventHandler::customEvent(QEvent *e) +void MythSystemLegacyEventHandler::customEvent(QEvent *e) { if ((MythEvent::Type)(e->type()) == MythEvent::MythEventMessage) { @@ -313,13 +313,13 @@ void MythSystemEventHandler::customEvent(QEvent *e) /****************************************************************************/ -/** \fn SendMythSystemRecEvent(const QString msg, const RecordingInfo *pginfo) +/** \fn SendMythSystemLegacyRecEvent(const QString msg, const RecordingInfo *pginfo) * \brief Sends a System Event for an in-progress recording * \sa MythCoreContext::SendSystemEvent(const QString msg) * \param msg Const QString to send as a System Event * \param pginfo Pointer to a RecordingInfo containing info on a recording */ -void SendMythSystemRecEvent(const QString msg, const RecordingInfo *pginfo) +void SendMythSystemLegacyRecEvent(const QString msg, const RecordingInfo *pginfo) { if (pginfo) { @@ -333,17 +333,17 @@ void SendMythSystemRecEvent(const QString msg, const RecordingInfo *pginfo) else { LOG(VB_GENERAL, LOG_ERR, LOC + - "SendMythSystemRecEvent() called with empty RecordingInfo"); + "SendMythSystemLegacyRecEvent() called with empty RecordingInfo"); } } -/** \fn SendMythSystemPlayEvent(const QString msg, const ProgramInfo *pginfo) +/** \fn SendMythSystemLegacyPlayEvent(const QString msg, const ProgramInfo *pginfo) * \brief Sends a System Event for a previously recorded program * \sa MythCoreContext::SendSystemEvent(const QString msg) * \param msg Const QString to send as a System Event * \param pginfo Pointer to a RecordingInfo containing info on a recording */ -void SendMythSystemPlayEvent(const QString msg, const ProgramInfo *pginfo) +void SendMythSystemLegacyPlayEvent(const QString msg, const ProgramInfo *pginfo) { if (pginfo) gCoreContext->SendSystemEvent( @@ -352,15 +352,15 @@ void SendMythSystemPlayEvent(const QString msg, const ProgramInfo *pginfo) .arg(pginfo->GetChanID()) .arg(pginfo->GetRecordingStartTime(MythDate::ISODate))); else - LOG(VB_GENERAL, LOG_ERR, LOC + "SendMythSystemPlayEvent() called with " + LOG(VB_GENERAL, LOG_ERR, LOC + "SendMythSystemLegacyPlayEvent() called with " "empty ProgramInfo"); } /****************************************************************************/ -/** \fn MythSystemEventEditor::MythSystemEventEditor(MythScreenStack *parent, +/** \fn MythSystemLegacyEventEditor::MythSystemLegacyEventEditor(MythScreenStack *parent, const char *name) - * \brief Constructor for the MythSystemEvent settings editor + * \brief Constructor for the MythSystemLegacyEvent settings editor * * Populates the settings name list with the System Event settings names * and sets the title of the RawSettingsEditor screen to indicate that @@ -369,7 +369,7 @@ void SendMythSystemPlayEvent(const QString msg, const ProgramInfo *pginfo) * \param parent Parent screen stack for this window * \param name Name of this window */ -MythSystemEventEditor::MythSystemEventEditor(MythScreenStack *parent, +MythSystemLegacyEventEditor::MythSystemLegacyEventEditor(MythScreenStack *parent, const char *name) : RawSettingsEditor(parent, name) { diff --git a/mythtv/libs/libmythtv/mythsystemevent.h b/mythtv/libs/libmythtv/mythsystemevent.h index e54018b9303..b5e9680fa6a 100644 --- a/mythtv/libs/libmythtv/mythsystemevent.h +++ b/mythtv/libs/libmythtv/mythsystemevent.h @@ -8,29 +8,29 @@ #include "recordinginfo.h" #include "rawsettingseditor.h" -// Helper commands for formatting and sending a MythSystemEvent -MTV_PUBLIC void SendMythSystemRecEvent(const QString msg, +// Helper commands for formatting and sending a MythSystemLegacyEvent +MTV_PUBLIC void SendMythSystemLegacyRecEvent(const QString msg, const RecordingInfo *pginfo); -MTV_PUBLIC void SendMythSystemPlayEvent(const QString msg, +MTV_PUBLIC void SendMythSystemLegacyPlayEvent(const QString msg, const ProgramInfo *pginfo); -/** \class MythSystemEventHandler - * \brief Handles incoming MythSystemEvent messages +/** \class MythSystemLegacyEventHandler + * \brief Handles incoming MythSystemLegacyEvent messages * - * MythSystemEventHandler handles incoming MythSystemEvent messages and runs + * MythSystemLegacyEventHandler handles incoming MythSystemLegacyEvent messages and runs * the appropriate event handler command on the local system if one is * configured. */ -class MTV_PUBLIC MythSystemEventHandler : public QObject +class MTV_PUBLIC MythSystemLegacyEventHandler : public QObject { Q_OBJECT public: // Constructor - MythSystemEventHandler(); + MythSystemLegacyEventHandler(); // Destructor - ~MythSystemEventHandler(); + ~MythSystemLegacyEventHandler(); private: // Helpers for converting incoming events to command lines @@ -41,18 +41,18 @@ class MTV_PUBLIC MythSystemEventHandler : public QObject void customEvent(QEvent *e); }; -/** \class MythSystemEventEditor - * \brief An editor for MythSystemEvent handler commands +/** \class MythSystemLegacyEventEditor + * \brief An editor for MythSystemLegacyEvent handler commands * * This class extends RawSettingsEditor and automatically populates the - * settings list with the MythSystemEvent handler command settings names. + * settings list with the MythSystemLegacyEvent handler command settings names. */ -class MTV_PUBLIC MythSystemEventEditor : public RawSettingsEditor +class MTV_PUBLIC MythSystemLegacyEventEditor : public RawSettingsEditor { Q_OBJECT public: - MythSystemEventEditor(MythScreenStack *parent, const char *name = 0); + MythSystemLegacyEventEditor(MythScreenStack *parent, const char *name = 0); }; #endif diff --git a/mythtv/libs/libmythtv/previewgenerator.cpp b/mythtv/libs/libmythtv/previewgenerator.cpp index 67b62b8fcab..3813b683cc1 100644 --- a/mythtv/libs/libmythtv/previewgenerator.cpp +++ b/mythtv/libs/libmythtv/previewgenerator.cpp @@ -30,7 +30,7 @@ #include "playercontext.h" #include "mythdirs.h" #include "remoteutil.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #include "mythlogging.h" #include "mythmiscutil.h" @@ -245,11 +245,10 @@ bool PreviewGenerator::Run(void) cmdargs << "--outfile" << outFileName; // Timeout in 30s - MythSystem *ms = new MythSystem(command, cmdargs, + MythSystemLegacy *ms = new MythSystemLegacy(command, cmdargs, kMSDontBlockInputDevs | kMSDontDisableDrawing | kMSProcessEvents | - kMSNoRunShell | kMSAutoCleanup | kMSPropagateLogs); ms->SetNice(10); diff --git a/mythtv/libs/libmythtv/recorders/channelbase.cpp b/mythtv/libs/libmythtv/recorders/channelbase.cpp index eeaddf13213..67ba775c78a 100644 --- a/mythtv/libs/libmythtv/recorders/channelbase.cpp +++ b/mythtv/libs/libmythtv/recorders/channelbase.cpp @@ -786,7 +786,7 @@ bool ChannelBase::ChangeExternalChannel(const QString &changer, LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Running command: %1").arg(command)); - m_system = new MythSystem(command, kMSRunShell | kMSRunBackground); + m_system = new MythSystemLegacy(command, kMSRunShell | kMSRunBackground); m_system->Run(); return true; diff --git a/mythtv/libs/libmythtv/recorders/channelbase.h b/mythtv/libs/libmythtv/recorders/channelbase.h index 5d87b139b0e..4721997aee5 100644 --- a/mythtv/libs/libmythtv/recorders/channelbase.h +++ b/mythtv/libs/libmythtv/recorders/channelbase.h @@ -11,7 +11,7 @@ // MythTV headers #include "channelinfo.h" #include "inputinfo.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "tv.h" class FireWireDBOptions; @@ -163,7 +163,7 @@ class ChannelBase ChannelInfoList m_allchannels; ///< channels across all inputs QMutex m_system_lock; - MythSystem *m_system; + MythSystemLegacy *m_system; /// These get mapped from the GENERIC_EXIT_* to these values for use /// with the signalmonitor code. /// 0 == unknown, 1 == pending, 2 == failed, 3 == success diff --git a/mythtv/libs/libmythtv/sourceutil.cpp b/mythtv/libs/libmythtv/sourceutil.cpp index 0408cd0c3c9..6cab1d6bdb7 100644 --- a/mythtv/libs/libmythtv/sourceutil.cpp +++ b/mythtv/libs/libmythtv/sourceutil.cpp @@ -9,7 +9,7 @@ #include "mythdb.h" #include "mythdirs.h" #include "mythlogging.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" bool SourceUtil::HasDigitalChannel(uint sourceid) { @@ -380,7 +380,7 @@ bool SourceUtil::UpdateChannelsFromListings(uint sourceid, QString cardtype, boo args.append(cardtype); } - MythSystem getchan(cmd, args, kMSRunShell | kMSAutoCleanup ); + MythSystemLegacy getchan(cmd, args, kMSRunShell | kMSAutoCleanup ); getchan.Run(); getchan.Wait(); } diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp index 5e07537a6b0..803651d1d1d 100644 --- a/mythtv/libs/libmythtv/tv_play.cpp +++ b/mythtv/libs/libmythtv/tv_play.cpp @@ -356,7 +356,7 @@ bool TV::StartTV(ProgramInfo *tvrec, uint flags) if (curProgram) { startSysEventSent = true; - SendMythSystemPlayEvent("PLAY_STARTED", curProgram); + SendMythSystemLegacyPlayEvent("PLAY_STARTED", curProgram); } // Notify others that we are about to play @@ -375,7 +375,7 @@ bool TV::StartTV(ProgramInfo *tvrec, uint flags) else if (!startSysEventSent) { startSysEventSent = true; - SendMythSystemPlayEvent("PLAY_STARTED", curProgram); + SendMythSystemLegacyPlayEvent("PLAY_STARTED", curProgram); } LOG(VB_PLAYBACK, LOG_INFO, LOC + "tv->Playback() -- end"); @@ -429,7 +429,7 @@ bool TV::StartTV(ProgramInfo *tvrec, uint flags) curProgram = nextProgram; - SendMythSystemPlayEvent("PLAY_CHANGED", curProgram); + SendMythSystemLegacyPlayEvent("PLAY_CHANGED", curProgram); continue; } @@ -463,7 +463,7 @@ bool TV::StartTV(ProgramInfo *tvrec, uint flags) if (curProgram) { - SendMythSystemPlayEvent("PLAY_STOPPED", curProgram); + SendMythSystemLegacyPlayEvent("PLAY_STOPPED", curProgram); if (deleterecording) { @@ -6091,7 +6091,7 @@ void TV::DoPlay(PlayerContext *ctx) if (ctx->ff_rew_state) time = StopFFRew(ctx); else if (ctx->player->IsPaused()) - SendMythSystemPlayEvent("PLAY_UNPAUSED", ctx->playingInfo); + SendMythSystemLegacyPlayEvent("PLAY_UNPAUSED", ctx->playingInfo); ctx->player->Play(ctx->ts_normal, true); gCoreContext->emitTVPlaybackUnpaused(); @@ -6213,9 +6213,9 @@ void TV::DoTogglePause(PlayerContext *ctx, bool showOSD) ctx->UnlockDeletePlayer(__FILE__, __LINE__); if (paused) - SendMythSystemPlayEvent("PLAY_UNPAUSED", ctx->playingInfo); + SendMythSystemLegacyPlayEvent("PLAY_UNPAUSED", ctx->playingInfo); else - SendMythSystemPlayEvent("PLAY_PAUSED", ctx->playingInfo); + SendMythSystemLegacyPlayEvent("PLAY_PAUSED", ctx->playingInfo); if (!ignore) DoTogglePauseFinish(ctx, DoTogglePauseStart(ctx), showOSD); diff --git a/mythtv/libs/libmythtv/tv_rec.cpp b/mythtv/libs/libmythtv/tv_rec.cpp index 6eb57659f3b..ffe31cd2774 100644 --- a/mythtv/libs/libmythtv/tv_rec.cpp +++ b/mythtv/libs/libmythtv/tv_rec.cpp @@ -804,7 +804,7 @@ void TVRec::StartedRecording(RecordingInfo *curRec) kAutoRunNone : kAutoRunProfile; InitAutoRunJobs(curRec, t, NULL, __LINE__); - SendMythSystemRecEvent("REC_STARTED", curRec); + SendMythSystemLegacyRecEvent("REC_STARTED", curRec); } /** \brief If not a premature stop, adds program to history of recorded @@ -893,7 +893,7 @@ void TVRec::FinishedRecording(RecordingInfo *curRec, RecordingQuality *recq) if (HasFlags(kFlagDummyRecorderRunning)) { curRec->FinishedRecording(true); // so end time is updated - SendMythSystemRecEvent("REC_FINISHED", curRec); + SendMythSystemLegacyRecEvent("REC_FINISHED", curRec); return; } @@ -939,7 +939,7 @@ void TVRec::FinishedRecording(RecordingInfo *curRec, RecordingQuality *recq) } // send out REC_FINISHED message - SendMythSystemRecEvent("REC_FINISHED", curRec); + SendMythSystemLegacyRecEvent("REC_FINISHED", curRec); // send out DONE_RECORDING message int secsSince = curRec->GetRecordingStartTime() diff --git a/mythtv/libs/libmythtv/videosource.cpp b/mythtv/libs/libmythtv/videosource.cpp index 0fa109950fa..513c5eef16d 100644 --- a/mythtv/libs/libmythtv/videosource.cpp +++ b/mythtv/libs/libmythtv/videosource.cpp @@ -41,7 +41,7 @@ using namespace std; #include "mythdirs.h" #include "mythlogging.h" #include "libmythupnp/httprequest.h" // for TestMimeType() -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #ifdef USING_DVB @@ -567,7 +567,7 @@ void XMLTVConfig::Load(void) QStringList args; args += "baseline"; - MythSystem find_grabber_proc("tv_find_grabbers", args, + MythSystemLegacy find_grabber_proc("tv_find_grabbers", args, kMSStdOut | kMSBuffered | kMSRunShell); find_grabber_proc.Run(25); LOG(VB_GENERAL, LOG_INFO, diff --git a/mythtv/libs/libmythui/lirc.cpp b/mythtv/libs/libmythui/lirc.cpp index dc4a5f03f60..404a1717534 100644 --- a/mythtv/libs/libmythui/lirc.cpp +++ b/mythtv/libs/libmythui/lirc.cpp @@ -20,7 +20,7 @@ using namespace std; // MythTV headers #include "mythdb.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "lircevent.h" #include "lirc_client.h" diff --git a/mythtv/libs/libmythui/lirc_client.c b/mythtv/libs/libmythui/lirc_client.c index 6bcd9150b2d..68a98a01335 100644 --- a/mythtv/libs/libmythui/lirc_client.c +++ b/mythtv/libs/libmythui/lirc_client.c @@ -1,6 +1,5 @@ /* NOTE: Extracted from LIRC release 0.8.4a -- dtk */ /* Updated to LIRC release 0.8.6 */ -/* Modified to use myth_system -- Gavin Hurlbut */ /**************************************************************************** ** lirc_client.c *********************************************************** @@ -32,7 +31,6 @@ #include #include "lirc_client.h" -#include "mythsystem.h" /* internal defines */ @@ -927,7 +925,7 @@ int lirc_readconfig(const struct lirc_state *state, strcat(command, " "); strcat(command, filename); - ret = myth_system_c(command, kMSNone, 0); + ret = system(command); free(command); if(ret!=EXIT_SUCCESS) diff --git a/mythtv/libs/libmythui/myththemedmenu.cpp b/mythtv/libs/libmythui/myththemedmenu.cpp index e3fa9dec502..beded5b07b5 100644 --- a/mythtv/libs/libmythui/myththemedmenu.cpp +++ b/mythtv/libs/libmythui/myththemedmenu.cpp @@ -16,7 +16,7 @@ #include "mythuitext.h" #include "mythuistatetype.h" #include "xmlparsebase.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythuihelper.h" #include "lcddevice.h" #include "mythcorecontext.h" diff --git a/mythtv/libs/libmythui/screensaver-x11.cpp b/mythtv/libs/libmythui/screensaver-x11.cpp index ce29e2b19f5..d9aa3e8fd55 100644 --- a/mythtv/libs/libmythui/screensaver-x11.cpp +++ b/mythtv/libs/libmythui/screensaver-x11.cpp @@ -11,7 +11,7 @@ #include "mythdb.h" // Mythui headers -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythxdisplay.h" // X11 headers diff --git a/mythtv/programs/mythbackend/housekeeper.cpp b/mythtv/programs/mythbackend/housekeeper.cpp index b828fede810..324fd0de125 100644 --- a/mythtv/programs/mythbackend/housekeeper.cpp +++ b/mythtv/programs/mythbackend/housekeeper.cpp @@ -18,7 +18,7 @@ using namespace std; // MythTV headers #include "housekeeper.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "jobqueue.h" #include "mythcorecontext.h" #include "mythdb.h" @@ -52,7 +52,7 @@ HouseKeeper::HouseKeeper(bool runthread, bool master, Scheduler *lsched) : isMaster(master), sched(lsched), houseKeepingRun(runthread), houseKeepingThread(NULL), fillDBThread(NULL), fillDBStarted(false), - fillDBMythSystem(NULL) + fillDBMythSystemLegacy(NULL) { CleanupMyOldRecordings(); @@ -439,22 +439,22 @@ void HouseKeeper::RunMFD(void) { QMutexLocker locker(&fillDBLock); - fillDBMythSystem = new MythSystem(command, kMSRunShell | + fillDBMythSystemLegacy = new MythSystemLegacy(command, kMSRunShell | kMSAutoCleanup); - fillDBMythSystem->Run(0); + fillDBMythSystemLegacy->Run(0); fillDBWait.wakeAll(); } MythFillDatabaseThread::setTerminationEnabled(true); - uint result = fillDBMythSystem->Wait(0); + uint result = fillDBMythSystemLegacy->Wait(0); MythFillDatabaseThread::setTerminationEnabled(false); { QMutexLocker locker(&fillDBLock); - fillDBMythSystem->deleteLater(); - fillDBMythSystem = NULL; + fillDBMythSystemLegacy->deleteLater(); + fillDBMythSystemLegacy = NULL; fillDBWait.wakeAll(); } @@ -489,15 +489,15 @@ void HouseKeeper::KillMFD(void) return; QMutexLocker locker(&fillDBLock); - if (fillDBMythSystem && fillDBThread->isRunning()) + if (fillDBMythSystemLegacy && fillDBThread->isRunning()) { - fillDBMythSystem->Term(false); + fillDBMythSystemLegacy->Term(false); fillDBWait.wait(locker.mutex(), 50); } - if (fillDBMythSystem && fillDBThread->isRunning()) + if (fillDBMythSystemLegacy && fillDBThread->isRunning()) { - fillDBMythSystem->Term(true); + fillDBMythSystemLegacy->Term(true); fillDBWait.wait(locker.mutex(), 50); } @@ -818,7 +818,7 @@ void HouseKeeper::UpdateRecordedArtwork(void) LOG(VB_GENERAL, LOG_INFO, QString("Performing Artwork Refresh: %1 %2") .arg(command).arg(args.join(" "))); - MythSystem artupd(command, args, kMSRunShell | kMSAutoCleanup); + MythSystemLegacy artupd(command, args, kMSRunShell | kMSAutoCleanup); artupd.Run(); artupd.Wait(); diff --git a/mythtv/programs/mythbackend/housekeeper.h b/mythtv/programs/mythbackend/housekeeper.h index bbcbeaed607..6002f32a5de 100644 --- a/mythtv/programs/mythbackend/housekeeper.h +++ b/mythtv/programs/mythbackend/housekeeper.h @@ -10,7 +10,7 @@ class Scheduler; class QString; class HouseKeeper; -class MythSystem; +class MythSystemLegacy; class HouseKeepingThread : public MThread { @@ -79,7 +79,7 @@ class HouseKeeper QWaitCondition fillDBWait; // protected by fillDBLock MythFillDatabaseThread *fillDBThread; // Only mod in HouseKeepingThread bool fillDBStarted; // protected by fillDBLock - MythSystem *fillDBMythSystem; // protected by fillDBLock + MythSystemLegacy *fillDBMythSystemLegacy; // protected by fillDBLock }; #endif diff --git a/mythtv/programs/mythbackend/httpstatus.cpp b/mythtv/programs/mythbackend/httpstatus.cpp index 8571a58fcde..55380f34971 100644 --- a/mythtv/programs/mythbackend/httpstatus.cpp +++ b/mythtv/programs/mythbackend/httpstatus.cpp @@ -35,7 +35,7 @@ #include "scheduler.h" #include "mainserver.h" #include "cardutil.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #include "jobqueue.h" #include "upnp.h" @@ -573,7 +573,7 @@ void HttpStatus::FillStatusXML( QDomDocument *pDoc ) root.appendChild(misc); uint flags = kMSRunShell | kMSStdOut | kMSBuffered; - MythSystem ms(info_script, flags); + MythSystemLegacy ms(info_script, flags); ms.Run(10); if (ms.Wait() != GENERIC_EXIT_OK) { diff --git a/mythtv/programs/mythbackend/internetContent.cpp b/mythtv/programs/mythbackend/internetContent.cpp index 6ec9a0bab76..5adac667c96 100644 --- a/mythtv/programs/mythbackend/internetContent.cpp +++ b/mythtv/programs/mythbackend/internetContent.cpp @@ -19,7 +19,7 @@ #include "mythcorecontext.h" #include "mythdate.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythdirs.h" #include "rssparse.h" @@ -187,7 +187,7 @@ void InternetContent::GetInternetSources( HTTPRequest *pRequest ) i != Grabbers.end(); ++i) { QString commandline = GrabberDir + (*i); - MythSystem scriptcheck(commandline, QStringList("-v"), + MythSystemLegacy scriptcheck(commandline, QStringList("-v"), kMSRunShell | kMSStdOut | kMSBuffered); scriptcheck.Run(); scriptcheck.Wait(); diff --git a/mythtv/programs/mythbackend/main_helpers.cpp b/mythtv/programs/mythbackend/main_helpers.cpp index fd4c4dc854d..4de9a57f0e6 100644 --- a/mythtv/programs/mythbackend/main_helpers.cpp +++ b/mythtv/programs/mythbackend/main_helpers.cpp @@ -565,7 +565,7 @@ int run_backend(MythBackendCommandLineParser &cmdline) return GENERIC_EXIT_SETUP_ERROR; } - MythSystemEventHandler *sysEventHandler = new MythSystemEventHandler(); + MythSystemLegacyEventHandler *sysEventHandler = new MythSystemLegacyEventHandler(); if (ismaster) { diff --git a/mythtv/programs/mythbackend/mainserver.cpp b/mythtv/programs/mythbackend/mainserver.cpp index fea6690de4f..7f9a59939ef 100644 --- a/mythtv/programs/mythbackend/mainserver.cpp +++ b/mythtv/programs/mythbackend/mainserver.cpp @@ -40,7 +40,7 @@ using namespace std; #include "previewgeneratorqueue.h" #include "mythmiscutil.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" #include "mythcontext.h" #include "mythversion.h" @@ -1017,7 +1017,7 @@ void MainServer::customEvent(QEvent *e) if (recInfo.GetChanID()) { - SendMythSystemPlayEvent("REC_EXPIRED", &recInfo); + SendMythSystemLegacyPlayEvent("REC_EXPIRED", &recInfo); // allow re-record if auto expired but not expired live // or already "deleted" programs diff --git a/mythtv/programs/mythbackend/scheduler.cpp b/mythtv/programs/mythbackend/scheduler.cpp index eed332a7995..9111936b341 100644 --- a/mythtv/programs/mythbackend/scheduler.cpp +++ b/mythtv/programs/mythbackend/scheduler.cpp @@ -27,7 +27,7 @@ using namespace std; #include #include "mythmiscutil.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "scheduler.h" #include "encoderlink.h" #include "mainserver.h" @@ -2355,7 +2355,7 @@ void Scheduler::HandleWakeSlave(RecordingInfo &ri, int prerollseconds) { if (!pendingEventSent) { - SendMythSystemRecEvent( + SendMythSystemLegacyRecEvent( QString("REC_PENDING SECS %1").arg(secsleft), &ri); } diff --git a/mythtv/programs/mythcommflag/TemplateFinder.cpp b/mythtv/programs/mythcommflag/TemplateFinder.cpp index fa9566cc6ee..44f99101d13 100644 --- a/mythtv/programs/mythcommflag/TemplateFinder.cpp +++ b/mythtv/programs/mythcommflag/TemplateFinder.cpp @@ -15,7 +15,7 @@ #include "mythcorecontext.h" /* gContext */ #include "frame.h" /* VideoFrame */ #include "mythdate.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "exitcodes.h" // Commercial Flagging headers diff --git a/mythtv/programs/mythfilldatabase/filldata.cpp b/mythtv/programs/mythfilldatabase/filldata.cpp index bd5d495deaa..47816e23486 100644 --- a/mythtv/programs/mythfilldatabase/filldata.cpp +++ b/mythtv/programs/mythfilldatabase/filldata.cpp @@ -26,7 +26,7 @@ using namespace std; #include "mythdate.h" #include "mythdirs.h" #include "mythdb.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "videosource.h" // for is_grabber.. // filldata headers @@ -616,7 +616,7 @@ bool FillData::Run(SourceList &sourcelist) if (is_grabber_external(xmltv_grabber)) { uint flags = kMSRunShell | kMSStdOut | kMSBuffered; - MythSystem grabber_capabilities_proc(xmltv_grabber, + MythSystemLegacy grabber_capabilities_proc(xmltv_grabber, QStringList("--capabilities"), flags); grabber_capabilities_proc.Run(25); @@ -660,7 +660,7 @@ bool FillData::Run(SourceList &sourcelist) if (hasprefmethod) { uint flags = kMSRunShell | kMSStdOut | kMSBuffered; - MythSystem grabber_method_proc(xmltv_grabber, + MythSystemLegacy grabber_method_proc(xmltv_grabber, QStringList("--preferredmethod"), flags); grabber_method_proc.Run(15); diff --git a/mythtv/programs/mythfrontend/exitprompt.cpp b/mythtv/programs/mythfrontend/exitprompt.cpp index 266a8d94e2b..116bd8bbfa9 100644 --- a/mythtv/programs/mythfrontend/exitprompt.cpp +++ b/mythtv/programs/mythfrontend/exitprompt.cpp @@ -11,7 +11,7 @@ #include "mythdialogbox.h" #include "mythmainwindow.h" #include "mythscreenstack.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythlogging.h" #include "exitcodes.h" diff --git a/mythtv/programs/mythfrontend/grabbersettings.cpp b/mythtv/programs/mythfrontend/grabbersettings.cpp index 7589ce66352..44b4ed7423b 100644 --- a/mythtv/programs/mythfrontend/grabbersettings.cpp +++ b/mythtv/programs/mythfrontend/grabbersettings.cpp @@ -7,7 +7,7 @@ // myth #include "mythcorecontext.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythdbcon.h" #include "mythdirs.h" @@ -99,7 +99,7 @@ void GrabberSettings::Load(void) { QString commandline = QString("%1/%2") .arg(MovieScriptPath.path()).arg(*i); - MythSystem grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut | kMSBuffered); + MythSystemLegacy grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut | kMSBuffered); grabber.Run(); grabber.Wait(); QByteArray result = grabber.ReadAll(); @@ -126,7 +126,7 @@ void GrabberSettings::Load(void) { QString commandline = QString("%1/%2") .arg(TVScriptPath.path()).arg(*i); - MythSystem grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut | kMSBuffered); + MythSystemLegacy grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut | kMSBuffered); grabber.Run(); grabber.Wait(); QByteArray result = grabber.ReadAll(); @@ -154,7 +154,7 @@ void GrabberSettings::Load(void) { QString commandline = QString("%1/%2") .arg(GameScriptPath.path()).arg(*i); - MythSystem grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut | kMSBuffered); + MythSystemLegacy grabber(commandline, QStringList() << "-v", kMSRunShell | kMSStdOut | kMSBuffered); grabber.Run(); grabber.Wait(); QByteArray result = grabber.ReadAll(); diff --git a/mythtv/programs/mythfrontend/idlescreen.cpp b/mythtv/programs/mythfrontend/idlescreen.cpp index ec50a993197..4e01c340d00 100644 --- a/mythtv/programs/mythfrontend/idlescreen.cpp +++ b/mythtv/programs/mythfrontend/idlescreen.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include diff --git a/mythtv/programs/mythfrontend/main.cpp b/mythtv/programs/mythfrontend/main.cpp index dfd6d34558c..1e2af1750c3 100644 --- a/mythtv/programs/mythfrontend/main.cpp +++ b/mythtv/programs/mythfrontend/main.cpp @@ -21,7 +21,7 @@ using namespace std; #include "referencecounter.h" #include "mythmiscutil.h" #include "mythconfig.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "tv.h" #include "proglist.h" #include "progfind.h" @@ -296,10 +296,10 @@ static void startAppearWiz(void) int curW = gCoreContext->GetNumSetting("GuiWidth", 0); int curH = gCoreContext->GetNumSetting("GuiHeight", 0); - MythSystem *wizard = new MythSystem( - GetInstallPrefix() + "/bin/mythscreenwizard", - QStringList(), - kMSNoRunShell | kMSDisableUDPListener | kMSPropagateLogs); + MythSystemLegacy *wizard = new MythSystemLegacy( + GetInstallPrefix() + "/bin/mythscreenwizard", + QStringList(), + kMSDisableUDPListener | kMSPropagateLogs); wizard->Run(); bool reload = false; @@ -937,7 +937,7 @@ static void TVMenuCallback(void *data, QString &selection) { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); - MythSystemEventEditor *msee = new MythSystemEventEditor( + MythSystemLegacyEventEditor *msee = new MythSystemLegacyEventEditor( mainStack, "System Event Editor"); if (msee->Create()) @@ -1683,7 +1683,7 @@ int main(int argc, char **argv) if (gCoreContext->GetNumSetting("ThemeUpdateNofications", 1)) themeUpdateChecker = new ThemeUpdateChecker(); - MythSystemEventHandler *sysEventHandler = new MythSystemEventHandler(); + MythSystemLegacyEventHandler *sysEventHandler = new MythSystemLegacyEventHandler(); BackendConnectionManager bcm; diff --git a/mythtv/programs/mythfrontend/setupwizard_general.cpp b/mythtv/programs/mythfrontend/setupwizard_general.cpp index d1700a4c57a..0a7a5b7b39c 100644 --- a/mythtv/programs/mythfrontend/setupwizard_general.cpp +++ b/mythtv/programs/mythfrontend/setupwizard_general.cpp @@ -4,7 +4,7 @@ // myth #include "mythcontext.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythdbcon.h" #include "mythdirs.h" diff --git a/mythtv/programs/mythfrontend/videodlg.cpp b/mythtv/programs/mythfrontend/videodlg.cpp index 287f0f7c7aa..eff273d666e 100644 --- a/mythtv/programs/mythfrontend/videodlg.cpp +++ b/mythtv/programs/mythfrontend/videodlg.cpp @@ -24,7 +24,7 @@ #include "mythuimetadataresults.h" #include "mythdialogbox.h" #include "mythgenerictree.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "remotefile.h" #include "remoteutil.h" #include "storagegroup.h" diff --git a/mythtv/programs/mythfrontend/videoplayercommand.cpp b/mythtv/programs/mythfrontend/videoplayercommand.cpp index ad522f0e353..3404c071d6b 100644 --- a/mythtv/programs/mythfrontend/videoplayercommand.cpp +++ b/mythtv/programs/mythfrontend/videoplayercommand.cpp @@ -3,7 +3,7 @@ #include "mythcontext.h" #include "mythmainwindow.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "remoteutil.h" #include "lcddevice.h" #include "mythmiscutil.h" @@ -133,20 +133,20 @@ class VideoPlayHandleMedia : public VideoPlayProc //////////////////////////////////////////////////////////////////////// -class VideoPlayMythSystem : public VideoPlayProc +class VideoPlayMythSystemLegacy : public VideoPlayProc { private: - VideoPlayMythSystem(const QString &disp_command, + VideoPlayMythSystemLegacy(const QString &disp_command, const QString &play_command) : m_display_command(disp_command), m_play_command(play_command) { } public: - static VideoPlayMythSystem *Create(const QString &command, + static VideoPlayMythSystemLegacy *Create(const QString &command, const QString &filename) { - return new VideoPlayMythSystem(command, + return new VideoPlayMythSystemLegacy(command, ExpandPlayCommand(command, filename)); } @@ -166,9 +166,9 @@ class VideoPlayMythSystem : public VideoPlayProc return m_display_command; } - VideoPlayMythSystem *Clone() const + VideoPlayMythSystemLegacy *Clone() const { - return new VideoPlayMythSystem(*this); + return new VideoPlayMythSystemLegacy(*this); } private: @@ -351,7 +351,7 @@ class VideoPlayerCommandPrivate m_player_procs.push_back(VideoPlayHandleMedia::Create(player, filename, plot, title, subtitle, director, season, episode, inetref, length, year, id)); - m_player_procs.push_back(VideoPlayMythSystem::Create(player, filename)); + m_player_procs.push_back(VideoPlayMythSystemLegacy::Create(player, filename)); } private: diff --git a/mythtv/programs/mythjobqueue/main.cpp b/mythtv/programs/mythjobqueue/main.cpp index 486cde6002a..14fb0f98895 100644 --- a/mythtv/programs/mythjobqueue/main.cpp +++ b/mythtv/programs/mythjobqueue/main.cpp @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) jobqueue = new JobQueue(false); - MythSystemEventHandler *sysEventHandler = new MythSystemEventHandler(); + MythSystemLegacyEventHandler *sysEventHandler = new MythSystemLegacyEventHandler(); int exitCode = a.exec(); diff --git a/mythtv/programs/mythmediaserver/main.cpp b/mythtv/programs/mythmediaserver/main.cpp index 6f5a0093656..193f7884dbd 100644 --- a/mythtv/programs/mythmediaserver/main.cpp +++ b/mythtv/programs/mythmediaserver/main.cpp @@ -168,7 +168,7 @@ int main(int argc, char *argv[]) sockmanager->RegisterHandler(controlRequestHandler); controlRequestHandler->ConnectToMaster(); - MythSystemEventHandler *sysEventHandler = new MythSystemEventHandler(); + MythSystemLegacyEventHandler *sysEventHandler = new MythSystemLegacyEventHandler(); int exitCode = a.exec(); diff --git a/mythtv/programs/mythscreenwizard/main.cpp b/mythtv/programs/mythscreenwizard/main.cpp index 068a4af1028..2b1bd208b0b 100644 --- a/mythtv/programs/mythscreenwizard/main.cpp +++ b/mythtv/programs/mythscreenwizard/main.cpp @@ -242,7 +242,7 @@ int main(int argc, char **argv) return GENERIC_EXIT_CONNECT_ERROR; } - MythSystemEventHandler *sysEventHandler = new MythSystemEventHandler(); + MythSystemLegacyEventHandler *sysEventHandler = new MythSystemLegacyEventHandler(); */ startAppearWiz(GuiOffsetX, GuiOffsetY, GuiWidth, GuiHeight); diff --git a/mythtv/programs/mythshutdown/main.cpp b/mythtv/programs/mythshutdown/main.cpp index 2061a387cbc..d552fdd0eca 100644 --- a/mythtv/programs/mythshutdown/main.cpp +++ b/mythtv/programs/mythshutdown/main.cpp @@ -11,7 +11,7 @@ using namespace std; #include "exitcodes.h" #include "mythcontext.h" #include "mythdb.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "mythversion.h" #include "jobqueue.h" #include "tv.h" diff --git a/mythtv/programs/mythtv-setup/exitprompt.cpp b/mythtv/programs/mythtv-setup/exitprompt.cpp index a1ea85af23b..62c941e4143 100644 --- a/mythtv/programs/mythtv-setup/exitprompt.cpp +++ b/mythtv/programs/mythtv-setup/exitprompt.cpp @@ -7,7 +7,7 @@ #include "mythmainwindow.h" #include "mythscreenstack.h" #include "remoteutil.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "checksetup.h" #include "exitprompt.h" diff --git a/mythtv/programs/mythtv-setup/main.cpp b/mythtv/programs/mythtv-setup/main.cpp index 4208068ff76..5d253477941 100644 --- a/mythtv/programs/mythtv-setup/main.cpp +++ b/mythtv/programs/mythtv-setup/main.cpp @@ -131,7 +131,7 @@ static void SetupMenuCallback(void* data, QString& selection) { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); - MythSystemEventEditor *msee = new MythSystemEventEditor( + MythSystemLegacyEventEditor *msee = new MythSystemLegacyEventEditor( mainStack, "System Event Editor"); if (msee->Create()) diff --git a/mythtv/programs/mythtv-setup/startprompt.cpp b/mythtv/programs/mythtv-setup/startprompt.cpp index e61cf1246e0..7271cd9a75d 100644 --- a/mythtv/programs/mythtv-setup/startprompt.cpp +++ b/mythtv/programs/mythtv-setup/startprompt.cpp @@ -7,7 +7,7 @@ #include "mythdialogbox.h" #include "mythmainwindow.h" #include "mythscreenstack.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "tvremoteutil.h" #include "startprompt.h" diff --git a/mythtv/programs/mythwelcome/welcomedialog.cpp b/mythtv/programs/mythwelcome/welcomedialog.cpp index f092608c58c..e152fb7354e 100644 --- a/mythtv/programs/mythwelcome/welcomedialog.cpp +++ b/mythtv/programs/mythwelcome/welcomedialog.cpp @@ -18,7 +18,7 @@ #include "compat.h" #include "mythdirs.h" #include "remoteutil.h" -#include "mythsystem.h" +#include "mythsystemlegacy.h" #include "welcomedialog.h" #include "welcomesettings.h"