# HG changeset patch
# User Chris Cannam
# Date 1386861642 0
# Node ID 7f7fba33b7de2890ca96dbd15969219bb9fe04b9
# Parent  e84a1c6fb35a9f1cf1f755d5e8faf09bea6450cf
Add network permission to prefs; make OSC support one of the things that depends on it
diff -r e84a1c6fb35a -r 7f7fba33b7de .hgsubstate
--- a/.hgsubstate	Wed Dec 11 22:00:09 2013 +0000
+++ b/.hgsubstate	Thu Dec 12 15:20:42 2013 +0000
@@ -1,5 +1,5 @@
 236814e07bd07473958c1ff89103124536a0c3c8 dataquay
 3c5adc4a864fa75e5b1e67c260b77541aaa4f1f6 sv-dependency-builds
-47964f188bd9cb2a75ad5c3783a86db76950a392 svapp
+c837368b1faf2cd3727242099eefec0a18deb91f svapp
 786ee8d1f30e4920f361419a75eafa079ec0160d svcore
 b81f21f2c4c3d1cb115e278a098ac4869fb7377f svgui
diff -r e84a1c6fb35a -r 7f7fba33b7de main/MainWindow.cpp
--- a/main/MainWindow.cpp	Wed Dec 11 22:00:09 2013 +0000
+++ b/main/MainWindow.cpp	Thu Dec 12 15:20:42 2013 +0000
@@ -128,7 +128,7 @@
 
 
 MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) :
-    MainWindowBase(withAudioOutput, withOSCSupport, true),
+    MainWindowBase(withAudioOutput, true),
     m_overview(0),
     m_mainMenusCreated(false),
     m_paneMenu(0),
@@ -302,6 +302,9 @@
     NetworkPermissionTester tester;
     bool networkPermission = tester.havePermission();
     if (networkPermission) {
+        if (withOSCSupport) {
+            startOSCQueue();
+        }
         TransformFactory::getInstance()->startPopulationThread();
         m_surveyer = new Surveyer
             ("sonicvisualiser.org", "survey23-present.txt", "survey23.php");
diff -r e84a1c6fb35a -r 7f7fba33b7de main/NetworkPermissionTester.cpp
--- a/main/NetworkPermissionTester.cpp	Wed Dec 11 22:00:09 2013 +0000
+++ b/main/NetworkPermissionTester.cpp	Thu Dec 12 15:20:42 2013 +0000
@@ -56,10 +56,12 @@
 	      "
Developed in the Centre for Digital Music at Queen Mary, University of London, Sonic Visualiser is provided free as open source software under the GNU General Public License.
"
               "
"
 	      "Before we go on...
"
-	      "Sonic Visualiser needs to make occasional network requests to our servers.
"
+	      "Sonic Visualiser would like to make networking connections and open a network port.
"
 	      "This is to:
"
-	      "-  look up information about available and installed plugins; and"
-	      "
-  tell you when updates are available.
"
+	      "-  Find information about available and installed plugins;"
+	      "
-  Support the use of Open Sound Control, where configured; and"
+	      "
-  Tell you when updates are available."
+              "
"
 	      "No personal information will be sent, no tracking is carried out, and all requests happen in the background without interrupting your work.
"
 	      "We recommend that you allow this, because it makes Sonic Visualiser more useful. But if you do not wish to do so, please un-check the box below.
"));
 	layout->addWidget(label, 0, 0);
diff -r e84a1c6fb35a -r 7f7fba33b7de main/PreferencesDialog.cpp
--- a/main/PreferencesDialog.cpp	Wed Dec 11 22:00:09 2013 +0000
+++ b/main/PreferencesDialog.cpp	Thu Dec 12 15:20:42 2013 +0000
@@ -42,6 +42,8 @@
 #include "audioio/AudioTargetFactory.h"
 #include "base/ResourceFinder.h"
 
+#include "version.h"
+
 PreferencesDialog::PreferencesDialog(QWidget *parent) :
     QDialog(parent),
     m_audioDevice(0),
@@ -206,8 +208,13 @@
 #endif
 
     settings.beginGroup("Preferences");
+
     QString userLocale = settings.value("locale", "").toString();
     m_currentLocale = userLocale;
+    
+    QString permishTag = QString("network-permission-%1").arg(SV_VERSION);
+    m_networkPermission = settings.value(permishTag, false).toBool();
+
     settings.endGroup();
 
     QComboBox *locale = new QComboBox;
@@ -240,6 +247,11 @@
     connect(locale, SIGNAL(currentIndexChanged(int)),
             this, SLOT(localeChanged(int)));
 
+    QCheckBox *networkPermish = new QCheckBox;
+    networkPermish->setCheckState(m_networkPermission ? Qt::Checked : Qt::Unchecked);
+    connect(networkPermish, SIGNAL(stateChanged(int)),
+            this, SLOT(networkPermissionChanged(int)));
+
     QSpinBox *fontSize = new QSpinBox;
     int fs = prefs->getPropertyRangeAndValue("View Font Size", &min, &max,
                                              &deflt);
@@ -278,6 +290,10 @@
                        row, 0);
     subgrid->addWidget(locale, row++, 1, 1, 1);
 
+    subgrid->addWidget(new QLabel(tr("%1:").arg(tr("Allow network usage"))),
+                       row, 0);
+    subgrid->addWidget(networkPermish, row++, 1, 1, 1);
+
     subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
                                                 ("Temporary Directory Root"))),
                        row, 0);
@@ -508,6 +524,14 @@
 }
 
 void
+PreferencesDialog::networkPermissionChanged(int state)
+{
+    m_networkPermission = (state == Qt::Checked);
+    m_applyButton->setEnabled(true);
+    m_changesOnRestart = true;
+}
+
+void
 PreferencesDialog::showSplashChanged(int state)
 {
     m_showSplash = (state == Qt::Checked);
@@ -602,19 +626,17 @@
         AudioTargetFactory::getInstance()->getCallbackTargetNames();
 
     QSettings settings;
-
     settings.beginGroup("Preferences");
+    QString permishTag = QString("network-permission-%1").arg(SV_VERSION);
+    settings.setValue(permishTag, m_networkPermission);
     settings.setValue("audio-target", devices[m_audioDevice]);
+    settings.setValue("locale", m_currentLocale);
     settings.endGroup();
 
     settings.beginGroup("MainWindow");
     settings.setValue("sessiontemplate", m_currentTemplate);
     settings.endGroup();
 
-    settings.beginGroup("Preferences");
-    settings.setValue("locale", m_currentLocale);
-    settings.endGroup();
-
     m_applyButton->setEnabled(false);
 
     if (m_changesOnRestart) {
diff -r e84a1c6fb35a -r 7f7fba33b7de main/PreferencesDialog.h
--- a/main/PreferencesDialog.h	Wed Dec 11 22:00:09 2013 +0000
+++ b/main/PreferencesDialog.h	Thu Dec 12 15:20:42 2013 +0000
@@ -61,6 +61,7 @@
     void showSplashChanged(int state);
     void defaultTemplateChanged(int);
     void localeChanged(int);
+    void networkPermissionChanged(int state);
 
     void tempDirButtonClicked();
 
@@ -91,6 +92,7 @@
     int m_audioDevice;
     int m_resampleQuality;
     bool m_resampleOnLoad;
+    bool m_networkPermission;
     QString m_tempDirRoot;
     int m_backgroundMode;
     int m_timeToTextMode;