From c3f7a7c1799801eefeb989990739a64b663d835c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 6 Jun 2014 10:59:53 +0200 Subject: [PATCH] Some fixes found during testing with remote black core (different computer) * Allow anonymous access for P2P * Fixed sound settings flags, if empty string is saved in settings * Fixed metadata registration --- src/blackcore/dbus_server.cpp | 1 + src/blackmisc/blackmisc.qrc | 1 + src/blackmisc/blackmiscfreefunctions.cpp | 1 + src/blackmisc/setaudio.cpp | 19 +++++++++++++++++-- src/blackmisc/setaudio.h | 3 ++- src/blacksound/soundgenerator.h | 13 +++++++------ 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/blackcore/dbus_server.cpp b/src/blackcore/dbus_server.cpp index 108786d93..fa8624976 100644 --- a/src/blackcore/dbus_server.cpp +++ b/src/blackcore/dbus_server.cpp @@ -26,6 +26,7 @@ namespace BlackCore parent), m_serverMode(CDBusServer::SERVERMODE_P2P) { ServerMode m = CDBusServer::addressToDBusMode(address); + m_busServer.setAnonymousAuthenticationAllowed(true); switch (m) { case SERVERMODE_SESSIONBUS: diff --git a/src/blackmisc/blackmisc.qrc b/src/blackmisc/blackmisc.qrc index f2a36716a..38aeb20b8 100644 --- a/src/blackmisc/blackmisc.qrc +++ b/src/blackmisc/blackmisc.qrc @@ -25,5 +25,6 @@ icons/aircraft_arrival.jpg icons/sky.jpg icons/tower_framed.jpg + icons/gnd_framed.jpg diff --git a/src/blackmisc/blackmiscfreefunctions.cpp b/src/blackmisc/blackmiscfreefunctions.cpp index ebe638e90..c6c620197 100644 --- a/src/blackmisc/blackmiscfreefunctions.cpp +++ b/src/blackmisc/blackmiscfreefunctions.cpp @@ -104,6 +104,7 @@ void BlackMisc::Network::registerMetadata() void BlackMisc::Settings::registerMetadata() { CSettingsNetwork::registerMetadata(); + CSettingsAudio::registerMetadata(); } /* diff --git a/src/blackmisc/setaudio.cpp b/src/blackmisc/setaudio.cpp index f8d098f9c..0fbac5316 100644 --- a/src/blackmisc/setaudio.cpp +++ b/src/blackmisc/setaudio.cpp @@ -18,7 +18,9 @@ namespace BlackMisc */ bool CSettingsAudio::getNotificationFlag(CNotificationSounds::Notification notification) const { - QChar f = m_notificationFlags.at(static_cast(notification)); + const int i = static_cast(notification); + if (i >= m_notificationFlags.length()) return true; // default + QChar f = m_notificationFlags.at(i); return '1' == f; } @@ -129,7 +131,19 @@ namespace BlackMisc */ void CSettingsAudio::initDefaultValues() { - this->m_notificationFlags = QString(1 + static_cast(CNotificationSounds::Notification::NotificationsLoadSounds), '1'); + this->initNotificationFlags(); + } + + + void CSettingsAudio::initNotificationFlags() + { + // if we add flags in the future, we automatically extend ... + static const int l = 1 + static_cast(CNotificationSounds::Notification::NotificationsLoadSounds); + if (this->m_notificationFlags.length() < l) + { + int cl = m_notificationFlags.length(); + this->m_notificationFlags.append(QString(l - cl, '1')); + } } /* @@ -155,6 +169,7 @@ namespace BlackMisc { CNotificationSounds::Notification index = static_cast(value.toInt()); char value = (command == CSettingUtilities::CmdSetTrue()) ? '1' : '0' ; + this->initNotificationFlags(); this->m_notificationFlags.replace(index, 1, value); return msgs; } diff --git a/src/blackmisc/setaudio.h b/src/blackmisc/setaudio.h index bf5b993f6..045400dea 100644 --- a/src/blackmisc/setaudio.h +++ b/src/blackmisc/setaudio.h @@ -93,7 +93,8 @@ namespace BlackMisc private: BLACK_ENABLE_TUPLE_CONVERSION(CSettingsAudio) - QString m_notificationFlags; //!< play notification for notification x, a little trick to use a string here (streamable, hashable, ..) + QString m_notificationFlags; //!< play notification for notification x, a little trick to use a string here (streamable, hashable, ..) + void initNotificationFlags(); //!< init flags }; } // namespace diff --git a/src/blacksound/soundgenerator.h b/src/blacksound/soundgenerator.h index 9860b8f58..e28e04bd9 100644 --- a/src/blacksound/soundgenerator.h +++ b/src/blacksound/soundgenerator.h @@ -168,12 +168,6 @@ namespace BlackSound */ static void playSelcal(qint32 volume, const BlackMisc::Aviation::CSelcal &selcal, const BlackMisc::Audio::CAudioDevice &audioDevice); - /*! - * \brief Play notification - * \param volume 0-100 - * \param notification - */ - static void playNotificationSound(qint32 volume, CNotificationSounds::Notification notification); //! One cycle of tones takes t milliseconds BlackMisc::PhysicalQuantities::CTime oneCycleDurationMs() const @@ -189,6 +183,13 @@ namespace BlackSound */ static void playFile(qint32 volume, const QString &file, bool removeFileAfterPlaying); + /*! + * \brief Play notification + * \param volume 0-100 + * \param notification + */ + static void playNotificationSound(qint32 volume, CNotificationSounds::Notification notification); + signals: /*! * \brief Device was closed