Permalink
Browse files

Add graphic user configuration for AirPlay.

Aim to simplify AirPlay and AirTunes configuration. The AirPlay settings page will also show the status for the RSA key and indicate any potential errors.
Drop conditional compilation of AirPlay (video only) without AirTunes (RAOP).
Services can now be started using proper settings and doesn't require the use of environment variables.
  • Loading branch information...
1 parent 1316335 commit 11ea7ef9c653e8e88d0c2cb032a25da639c91c2a @jyavenard jyavenard committed Jul 17, 2012
@@ -18,6 +18,7 @@
#define MAX_PACKET_SIZE 2048
RSA *MythRAOPConnection::g_rsa = NULL;
+QString MythRAOPConnection::g_rsaLastError;
// RAOP RTP packet type
#define TIMING_REQUEST 0x52
@@ -78,7 +79,8 @@ MythRAOPConnection::MythRAOPConnection(QObject *parent, QTcpSocket *socket,
m_masterTimeStamp(0), m_deviceTimeStamp(0), m_networkLatency(0),
m_clockSkew(0),
m_audioTimer(NULL),
- m_progressStart(0), m_progressCurrent(0), m_progressEnd(0)
+ m_progressStart(0), m_progressCurrent(0), m_progressEnd(0),
+ m_authenticated(false)
{
}
@@ -1354,9 +1356,9 @@ RSA *MythRAOPConnection::LoadKey(void)
if ( !file )
{
- LOG(VB_GENERAL, LOG_ERR, LOC + QString("Failed to read key from: %1")
- .arg(GetConfDir() + sName));
+ g_rsaLastError = QObject::tr("Failed to read key from: %1").arg(GetConfDir() + sName);
g_rsa = NULL;
+ LOG(VB_GENERAL, LOG_ERR, LOC + g_rsaLastError);
return NULL;
}
@@ -1365,13 +1367,15 @@ RSA *MythRAOPConnection::LoadKey(void)
if (g_rsa)
{
+ g_rsaLastError = "";
LOG(VB_GENERAL, LOG_DEBUG, LOC +
QString("Loaded RSA private key (%1)").arg(RSA_check_key(g_rsa)));
return g_rsa;
}
+ g_rsaLastError = QObject::tr("Failed to load RSA private key.");
g_rsa = NULL;
- LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to load RSA private key.");
+ LOG(VB_GENERAL, LOG_ERR, LOC + g_rsaLastError);
return NULL;
}
@@ -53,9 +53,8 @@ class MythRAOPConnection : public QObject
int GetDataPort() { return m_dataPort; }
bool HasAudio() { return m_audio; }
static QMap<QString,QString> decodeDMAP(const QByteArray &dmap);
-
- protected:
static RSA *LoadKey(void);
+ static QString RSALastError(void) { return g_rsaLastError; }
private slots:
void readClient(void);
@@ -128,6 +127,7 @@ class MythRAOPConnection : public QObject
QByteArray m_AESIV;
AES_KEY m_aesKey;
static RSA *g_rsa;
+ static QString g_rsaLastError;
// audio out
AudioOutput *m_audio;
AVCodec *m_codec;
@@ -403,11 +403,13 @@ using_frontend {
using_libdns_sd {
!macx: LIBS += -ldns_sd
- HEADERS += AirPlay/mythairplayserver.h
- SOURCES += AirPlay/mythairplayserver.cpp
- using_libcrypto: HEADERS += AirPlay/mythraopdevice.h AirPlay/mythraopconnection.h
- using_libcrypto: SOURCES += AirPlay/mythraopdevice.cpp AirPlay/mythraopconnection.cpp
- using_libcrypto: DEFINES += USING_MYTHRAOP
+ using_libcrypto {
+ HEADERS += AirPlay/mythairplayserver.h
+ SOURCES += AirPlay/mythairplayserver.cpp
+ HEADERS += AirPlay/mythraopdevice.h AirPlay/mythraopconnection.h
+ SOURCES += AirPlay/mythraopdevice.cpp AirPlay/mythraopconnection.cpp
+ DEFINES += USING_AIRPLAY
+ }
}
using_mheg {
@@ -38,7 +38,9 @@
#include "mythconfig.h"
#include "mythdirs.h"
#include "mythuihelper.h"
-
+#ifdef USING_AIRPLAY
+#include "AirPlay/mythraopconnection.h"
+#endif
#if defined(Q_OS_MACX)
#include "privatedecoder_vda.h"
#endif
@@ -2599,6 +2601,85 @@ static HostLineEdit *UDPNotifyPort()
return ge;
}
+#ifdef USING_AIRPLAY
+// AirPlay Settings
+static HostCheckBox *AirPlayEnabled()
+{
+ HostCheckBox *gc = new HostCheckBox("AirPlayEnabled");
+ gc->setLabel(QObject::tr("Enable AirPlay"));
+ gc->setHelpText(QObject::tr("AirPlay lets you wirelessly view content on "
+ "your TV from your iPhone, iPad, iPod Touch, or "
+ "iTunes on your computer."));
+ gc->setValue(true);
+ return gc;
+}
+
+static HostCheckBox *AirPlayAudioOnly()
+{
+ HostCheckBox *gc = new HostCheckBox("AirPlayAudioOnly");
+ gc->setLabel(QObject::tr("Only support AirTunes (no video)"));
+ gc->setHelpText(QObject::tr("Only stream audio from your iPhone, iPad, "
+ "iPod Touch, or iTunes on your computer"));
+ gc->setValue(false);
+ return gc;
+}
+
+static HostCheckBox *AirPlayPasswordEnabled()
+{
+ HostCheckBox *gc = new HostCheckBox("AirPlayPasswordEnabled");
+ gc->setLabel(QObject::tr("Require password"));
+ gc->setValue(false);
+ gc->setHelpText(QObject::tr("Require a password to use AirPlay. Your iPhone, "
+ "iPad, iPod Touch, or iTunes on your computer "
+ "will prompt you when required"));
+ return gc;
+}
+
+static HostLineEdit *AirPlayPassword()
+{
+ HostLineEdit *ge = new HostLineEdit("AirPlayPassword");
+ ge->setValue("0000");
+ ge->setHelpText(QObject::tr("Your iPhone, iPad, iPod Touch, or iTunes on "
+ "your computer will prompt you for this password "
+ "when required"));
+ return ge;
+}
+
+static HorizontalConfigurationGroup *AirPlayPasswordSettings()
+{
+ HorizontalConfigurationGroup *hc =
+ new HorizontalConfigurationGroup(false, false, false, false);
+ hc->addChild(AirPlayPasswordEnabled());
+ hc->addChild(AirPlayPassword());
+ return hc;
+}
+
+static TransLabelSetting *AirPlayInfo()
+{
+ TransLabelSetting *ts = new TransLabelSetting();
+ ts->setValue(QObject::tr("All AirPlay settings take effect when "
+ "you restart MythFrontend."));
+ return ts;
+}
+
+static TransLabelSetting *AirPlayRSAInfo()
+{
+ TransLabelSetting *ts = new TransLabelSetting();
+ if (MythRAOPConnection::LoadKey() == NULL)
+ {
+ ts->setValue(QObject::tr("AirTunes RSA key couldn't be loaded. "
+ "Check http://www.mythtv.org/wiki/AirTunes/AirPlay. "
+ "Last Error: %1")
+ .arg(MythRAOPConnection::RSALastError()));
+ }
+ else
+ {
+ ts->setValue(QObject::tr("AirTunes RSA key successfully loaded."));
+ }
+ return ts;
+}
+#endif
+
static HostCheckBox *RealtimePriority()
{
HostCheckBox *gc = new HostCheckBox("RealtimePriority");
@@ -3200,6 +3281,27 @@ MainGeneralSettings::MainGeneralSettings()
media->addChild(mediaMon);
addChild(media);
+ VerticalConfigurationGroup *remotecontrol =
+ new VerticalConfigurationGroup(false, true, false, false);
+ remotecontrol->setLabel(QObject::tr("Remote Control"));
+ remotecontrol->addChild(LircDaemonDevice());
+ remotecontrol->addChild(NetworkControlEnabled());
+ remotecontrol->addChild(NetworkControlPort());
+ remotecontrol->addChild(UDPNotifyPort());
+ addChild(remotecontrol);
+
+#ifdef USING_AIRPLAY
+ VerticalConfigurationGroup *airplay =
+ new VerticalConfigurationGroup(false, true, false, false);
+ airplay->setLabel(QObject::tr("AirPlay Settings"));
+ airplay->addChild(AirPlayEnabled());
+ airplay->addChild(AirPlayAudioOnly());
+ airplay->addChild(AirPlayPasswordSettings());
+ airplay->addChild(AirPlayInfo());
+ airplay->addChild(AirPlayRSAInfo());
+ addChild(airplay);
+#endif
+
VerticalConfigurationGroup *shutdownSettings =
new VerticalConfigurationGroup(true, true, false, false);
shutdownSettings->setLabel(QObject::tr("Shutdown/Reboot Settings"));
@@ -3208,15 +3310,6 @@ MainGeneralSettings::MainGeneralSettings()
shutdownSettings->addChild(HaltCommand());
shutdownSettings->addChild(RebootCommand());
addChild(shutdownSettings);
-
- VerticalConfigurationGroup *remotecontrol =
- new VerticalConfigurationGroup(false, true, false, false);
- remotecontrol->setLabel(QObject::tr("Remote Control"));
- remotecontrol->addChild(LircDaemonDevice());
- remotecontrol->addChild(NetworkControlEnabled());
- remotecontrol->addChild(NetworkControlPort());
- remotecontrol->addChild(UDPNotifyPort());
- addChild(remotecontrol);
}
PlaybackSettings::PlaybackSettings()
@@ -92,14 +92,14 @@ using namespace std;
#include "DVD/dvdringbuffer.h"
// AirPlay
-#ifdef USING_RAOP
+#ifdef USING_AIRPLAY
#include "AirPlay/mythraopdevice.h"
+#include "AirPlay/mythairplayserver.h"
#endif
#ifdef USING_LIBDNS_SD
#include <QScopedPointer>
#include "bonjourregister.h"
-#include "AirPlay/mythairplayserver.h"
#endif
static ExitPrompter *exitPopup = NULL;
@@ -235,11 +235,8 @@ namespace
void cleanup()
{
-#ifdef USING_RAOP
+#ifdef USING_AIRPLAY
MythRAOPDevice::Cleanup();
-#endif
-
-#ifdef USING_LIBDNS_SD
MythAirplayServer::Cleanup();
#endif
@@ -1564,13 +1561,17 @@ int main(int argc, char **argv)
bonjour->Register(port, "_mythfrontend._tcp",
name, dummy);
}
-
- if (getenv("MYTHTV_AIRPLAY"))
- MythAirplayServer::Create();
#endif
-#ifdef USING_RAOP
- MythRAOPDevice::Create();
+#ifdef USING_AIRPLAY
+ if (gCoreContext->GetNumSetting("AirPlayEnabled", true))
+ {
+ MythRAOPDevice::Create();
+ if (!gCoreContext->GetNumSetting("AirPlayAudioOnly", false))
+ {
+ MythAirplayServer::Create();
+ }
+ }
#endif
LCD::SetupLCD();
@@ -106,5 +106,5 @@ using_oss: DEFINES += USING_OSS
macx: DEFINES += USING_COREAUDIO
using_libdns_sd {
DEFINES += USING_LIBDNS_SD
- using_libcrypto: DEFINES += USING_RAOP
+ using_libcrypto: DEFINES += USING_AIRPLAY
}

0 comments on commit 11ea7ef

Please sign in to comment.