Permalink
Browse files

Fix UI message interface availability when using MythWelcome.

This adds a mechanism to disable the UI message interface when running
MythFrontend, freeing up the necessary ports to allow the frontend to
listen on them and receive events while MythWelcome idles in the
background. The interface is brought back up on MythWelcome when the
frontend terminates.

This commit contains an ABI bump for two new events and a MythSystem
constant.

Fixes #10815
  • Loading branch information...
wagnerrp committed Aug 22, 2012
1 parent 2ba42aa commit 8532584f4c3d0f7d14b88eed6c492073fbed8f86
@@ -24,5 +24,9 @@ QEvent::Type MythEvent::kUnlockInputDevicesEventType =
(QEvent::Type) QEvent::registerEventType();
QEvent::Type MythEvent::kUpdateBrowseInfoEventType =
(QEvent::Type) QEvent::registerEventType();
+QEvent::Type MythEvent::kDisableUDPListenerEventType =
+ (QEvent::Type) QEvent::registerEventType();
+QEvent::Type MythEvent::kEnableUDPListenerEventType =
+ (QEvent::Type) QEvent::registerEventType();
QEvent::Type ExternalKeycodeEvent::kEventType =
(QEvent::Type) QEvent::registerEventType();
@@ -80,6 +80,8 @@ class MBASE_PUBLIC MythEvent : public QEvent
static Type kLockInputDevicesEventType;
static Type kUnlockInputDevicesEventType;
static Type kUpdateBrowseInfoEventType;
+ static Type kDisableUDPListenerEventType;
+ static Type kEnableUDPListenerEventType;
private:
QString message;
@@ -297,6 +297,7 @@ void MythSystem::ProcessFlags(uint flags)
m_settings["BlockInputDevs"] = !(flags & kMSDontBlockInputDevs);
m_settings["DisableDrawing"] = !(flags & kMSDontDisableDrawing);
m_settings["ProcessEvents"] = flags & kMSProcessEvents;
+ m_settings["DisableUDP"] = flags & kMSDisableUDPListener;
}
if( flags & kMSStdIn )
@@ -361,6 +362,16 @@ void MythSystem::HandlePreRun()
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.
@@ -381,6 +392,14 @@ void MythSystem::HandlePostRun()
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") )
@@ -24,6 +24,8 @@ typedef enum MythSystemMask {
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.
} MythSystemFlag;
#ifdef __cplusplus
@@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
-#define MYTH_BINARY_VERSION "0.26.20120807-1"
+#define MYTH_BINARY_VERSION "0.26.20120822-1"
/** \brief Increment this whenever the MythTV network protocol changes.
*
@@ -2325,6 +2325,14 @@ void MythMainWindow::customEvent(QEvent *ce)
{
LockInputDevices(false);
}
+ else if (ce->type() == MythEvent::kDisableUDPListenerEventType)
+ {
+ d->m_udpListener->Disable();
+ }
+ else if (ce->type() == MythEvent::kEnableUDPListenerEventType)
+ {
+ d->m_udpListener->Enable();
+ }
else if ((MythEvent::Type)(ce->type()) == MythEvent::MythEventMessage)
{
MythEvent *me = (MythEvent *)ce;
@@ -13,6 +13,23 @@
MythUDPListener::MythUDPListener()
{
+ Enable();
+}
+
+void MythUDPListener::deleteLater(void)
+{
+ Disable();
+ disconnect();
+ QObject::deleteLater();
+}
+
+void MythUDPListener::Enable(void)
+{
+ if (m_socketPool)
+ return;
+
+ LOG(VB_GENERAL, LOG_INFO, LOC + "Enabling");
+
m_socketPool = new ServerPool(this);
connect(m_socketPool, SIGNAL(newDatagram(QByteArray, QHostAddress,
quint16)),
@@ -30,19 +47,12 @@ MythUDPListener::MythUDPListener()
}
}
-void MythUDPListener::deleteLater(void)
-{
- TeardownAll();
- disconnect();
- QObject::deleteLater();
-}
-
-void MythUDPListener::TeardownAll(void)
+void MythUDPListener::Disable(void)
{
if (!m_socketPool)
return;
- LOG(VB_GENERAL, LOG_INFO, LOC + "Disconnecting");
+ LOG(VB_GENERAL, LOG_INFO, LOC + "Disabling");
m_socketPool->close();
delete m_socketPool;
@@ -16,6 +16,9 @@ class MythUDPListener : public QObject
public:
MythUDPListener();
+ void Enable(void);
+ void Disable(void);
+
public slots:
virtual void deleteLater(void);
@@ -24,9 +27,9 @@ class MythUDPListener : public QObject
quint16 senderPort);
private:
- ~MythUDPListener(void) { TeardownAll(); }
+ ~MythUDPListener(void) { Disable(); }
- void TeardownAll(void);
+ void TeardownAll(void) { Disable(); }
private:
ServerPool *m_socketPool;
@@ -107,7 +107,7 @@ void WelcomeDialog::startFrontend(void)
QString startFECmd = gCoreContext->GetSetting("MythWelcomeStartFECmd",
m_installDir + "/bin/mythfrontend");
- myth_system(startFECmd);
+ myth_system(startFECmd, kMSDisableUDPListener);
updateAll();
m_frontendIsRunning = false;
}

0 comments on commit 8532584

Please sign in to comment.