diff options
| -rw-r--r-- | src/plugins/General/lyrics/lyricswindow.cpp | 2 | ||||
| -rw-r--r-- | src/plugins/General/scrobbler/scrobbler.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/General/streambrowser/streamwindow.cpp | 2 | ||||
| -rw-r--r-- | src/plugins/Input/cdaudio/decoder_cdaudio.cpp | 2 | ||||
| -rw-r--r-- | src/plugins/Transports/http/httpstreamreader.cpp | 7 | ||||
| -rw-r--r-- | src/qmmp/qmmpsettings.cpp | 12 | ||||
| -rw-r--r-- | src/qmmp/qmmpsettings.h | 28 | ||||
| -rw-r--r-- | src/qmmpui/configdialog.cpp | 5 | ||||
| -rw-r--r-- | src/qmmpui/forms/configdialog.ui | 98 | ||||
| -rw-r--r-- | src/qmmpui/playlistdownloader.cpp | 2 |
10 files changed, 107 insertions, 55 deletions
diff --git a/src/plugins/General/lyrics/lyricswindow.cpp b/src/plugins/General/lyrics/lyricswindow.cpp index 17fe95109..0ef6c83d6 100644 --- a/src/plugins/General/lyrics/lyricswindow.cpp +++ b/src/plugins/General/lyrics/lyricswindow.cpp @@ -47,6 +47,8 @@ LyricsWindow::LyricsWindow(const QString &artist, const QString &title, QWidget if (gs->isProxyEnabled()) { QNetworkProxy proxy(QNetworkProxy::HttpProxy, gs->proxy().host(), gs->proxy().port()); + if(gs->proxyType() == QmmpSettings::SOCKS5_PROXY) + proxy.setType(QNetworkProxy::Socks5Proxy); if(gs->useProxyAuth()) { proxy.setUser(gs->proxy().userName()); diff --git a/src/plugins/General/scrobbler/scrobbler.cpp b/src/plugins/General/scrobbler/scrobbler.cpp index 07f33e72d..9c8a9a0ea 100644 --- a/src/plugins/General/scrobbler/scrobbler.cpp +++ b/src/plugins/General/scrobbler/scrobbler.cpp @@ -268,6 +268,8 @@ void Scrobbler::setupProxy() if (gs->isProxyEnabled()) { QNetworkProxy proxy(QNetworkProxy::HttpProxy, gs->proxy().host(), gs->proxy().port()); + if(gs->proxyType() == QmmpSettings::SOCKS5_PROXY) + proxy.setType(QNetworkProxy::Socks5Proxy); if(gs->useProxyAuth()) { proxy.setUser(gs->proxy().userName()); @@ -399,6 +401,8 @@ ScrobblerAuth::ScrobblerAuth(const QString &scrobblerUrl, const QString &authUrl if (gs->isProxyEnabled()) { QNetworkProxy proxy(QNetworkProxy::HttpProxy, gs->proxy().host(), gs->proxy().port()); + if(gs->proxyType() == QmmpSettings::SOCKS5_PROXY) + proxy.setType(QNetworkProxy::Socks5Proxy); if(gs->useProxyAuth()) { proxy.setUser(gs->proxy().userName()); diff --git a/src/plugins/General/streambrowser/streamwindow.cpp b/src/plugins/General/streambrowser/streamwindow.cpp index 504914025..dc276e872 100644 --- a/src/plugins/General/streambrowser/streamwindow.cpp +++ b/src/plugins/General/streambrowser/streamwindow.cpp @@ -96,6 +96,8 @@ StreamWindow::StreamWindow(QWidget *parent) if (gs->isProxyEnabled()) { QNetworkProxy proxy(QNetworkProxy::HttpProxy, gs->proxy().host(), gs->proxy().port()); + if(gs->proxyType() == QmmpSettings::SOCKS5_PROXY) + proxy.setType(QNetworkProxy::Socks5Proxy); if(gs->useProxyAuth()) { proxy.setUser(gs->proxy().userName()); diff --git a/src/plugins/Input/cdaudio/decoder_cdaudio.cpp b/src/plugins/Input/cdaudio/decoder_cdaudio.cpp index 11e8119ab..afc6b2995 100644 --- a/src/plugins/Input/cdaudio/decoder_cdaudio.cpp +++ b/src/plugins/Input/cdaudio/decoder_cdaudio.cpp @@ -252,7 +252,7 @@ QList<CDATrack> DecoderCDAudio::generateTrackList(const QString &device, TrackIn { cddb_http_enable (cddb_conn); cddb_set_http_path_query (cddb_conn, settings.value("cddb_path").toByteArray().constData()); - if (QmmpSettings::instance()->isProxyEnabled()) + if (QmmpSettings::instance()->isProxyEnabled() && QmmpSettings::instance()->proxyType() == QmmpSettings::HTTP_PROXY) { QUrl proxy = QmmpSettings::instance()->proxy(); cddb_http_proxy_enable (cddb_conn); diff --git a/src/plugins/Transports/http/httpstreamreader.cpp b/src/plugins/Transports/http/httpstreamreader.cpp index 5cba24d0c..0cefbe775 100644 --- a/src/plugins/Transports/http/httpstreamreader.cpp +++ b/src/plugins/Transports/http/httpstreamreader.cpp @@ -325,12 +325,19 @@ void HttpStreamReader::run() m_handle = curl_easy_init(); //proxy if (QmmpSettings::instance()->isProxyEnabled()) + { curl_easy_setopt(m_handle, CURLOPT_PROXY, strdup((QmmpSettings::instance()->proxy().host() + ":" + QString("%1").arg(QmmpSettings::instance()->proxy().port())). toLatin1 ().constData ())); + + if(QmmpSettings::instance()->proxyType() == QmmpSettings::SOCKS5_PROXY) + curl_easy_setopt(m_handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); + } else + { curl_easy_setopt(m_handle, CURLOPT_NOPROXY, "*"); + } if (QmmpSettings::instance()->useProxyAuth()) curl_easy_setopt(m_handle, CURLOPT_PROXYUSERPWD, diff --git a/src/qmmp/qmmpsettings.cpp b/src/qmmp/qmmpsettings.cpp index 158c4d9ad..a078d0613 100644 --- a/src/qmmp/qmmpsettings.cpp +++ b/src/qmmp/qmmpsettings.cpp @@ -42,7 +42,7 @@ QmmpSettings::QmmpSettings(QObject *parent) : QObject(parent) settings.endGroup(); //audio settings m_aud_software_volume = settings.value("Output/software_volume", false).toBool(); - m_aud_format = (Qmmp::AudioFormat) settings.value("Output/format", Qmmp::PCM_S16LE).toInt(); + m_aud_format = static_cast<Qmmp::AudioFormat>(settings.value("Output/format", Qmmp::PCM_S16LE).toInt()); m_aud_dithering = settings.value("Output/dithering", true).toBool(); m_volume_step = settings.value("Output/volume_step", 5).toInt(); //cover settings @@ -55,6 +55,7 @@ QmmpSettings::QmmpSettings(QObject *parent) : QObject(parent) //network settings m_proxy_enabled = settings.value("Proxy/use_proxy", false).toBool(); m_proxy_auth = settings.value("Proxy/authentication", false).toBool(); + m_proxy_type = static_cast<ProxyType>(settings.value("Proxy/proxy_type", HTTP_PROXY).toInt()); m_proxy_url = settings.value("Proxy/url").toUrl(); //buffer m_buffer_size = settings.value("Output/buffer_size", 500).toInt(); @@ -168,10 +169,16 @@ const QUrl &QmmpSettings::proxy() const return m_proxy_url; } -void QmmpSettings::setNetworkSettings(bool use_proxy, bool auth, const QUrl &proxy) +QmmpSettings::ProxyType QmmpSettings::proxyType() const +{ + return m_proxy_type; +} + +void QmmpSettings::setNetworkSettings(bool use_proxy, bool auth, ProxyType type, const QUrl &proxy) { m_proxy_enabled = use_proxy; m_proxy_auth = auth; + m_proxy_type = type; m_proxy_url = proxy; m_timer->start(); emit networkSettingsChanged(); @@ -250,6 +257,7 @@ void QmmpSettings::sync() settings.setValue("Proxy/use_proxy", m_proxy_enabled); settings.setValue("Proxy/authentication", m_proxy_auth); settings.setValue("Proxy/url", m_proxy_url); + settings.setValue("Proxy/proxy_type", m_proxy_type); //equalizer settings settings.beginGroup(QString("Equalizer_%1").arg(m_eq_settings.bands())); for (int i = 0; i < m_eq_settings.bands(); ++i) diff --git a/src/qmmp/qmmpsettings.h b/src/qmmp/qmmpsettings.h index 1588c382c..97e33f282 100644 --- a/src/qmmp/qmmpsettings.h +++ b/src/qmmp/qmmpsettings.h @@ -37,6 +37,21 @@ class QMMP_EXPORT QmmpSettings : public QObject Q_OBJECT public: /*! + * This enum describes possible replaygain modes. + */ + enum ReplayGainMode + { + REPLAYGAIN_TRACK = 0, /*!< Use track gain/peak */ + REPLAYGAIN_ALBUM, /*!< Use album gain/peak */ + REPLAYGAIN_DISABLED /*!< Disable ReplayGain */ + }; + + enum ProxyType + { + HTTP_PROXY = 0, + SOCKS5_PROXY + }; + /*! * Constructor. * @param parent Parent object. * This functions is for internal usage only, use QmmpSettings::instance() instead. @@ -47,15 +62,6 @@ public: */ virtual ~QmmpSettings(); /*! - * This enum describes possible replaygain modes. - */ - enum ReplayGainMode - { - REPLAYGAIN_TRACK = 0, /*!< Use track gain/peak */ - REPLAYGAIN_ALBUM, /*!< Use album gain/peak */ - REPLAYGAIN_DISABLED /*!< Disable ReplayGain */ - }; - /*! * Returns current ReplayGain mode. */ QmmpSettings::ReplayGainMode replayGainMode() const; @@ -133,13 +139,14 @@ public: * Returns global proxy url. */ const QUrl &proxy() const; + ProxyType proxyType() const; /*! * Sets network settings. * @param use_proxy Enables or disables global proxy. * @param auth Enables or disables proxy authentication. * @param proxy Proxy url. */ - void setNetworkSettings(bool use_proxy, bool auth, const QUrl &proxy); + void setNetworkSettings(bool use_proxy, bool auth, ProxyType type, const QUrl &proxy); /*! * Returns equalizer settings. */ @@ -234,6 +241,7 @@ private: bool m_proxy_enabled; bool m_proxy_auth; QUrl m_proxy_url; + ProxyType m_proxy_type; //equalizer settings EqSettings m_eq_settings; //buffer size diff --git a/src/qmmpui/configdialog.cpp b/src/qmmpui/configdialog.cpp index 599026f1b..47764e2dd 100644 --- a/src/qmmpui/configdialog.cpp +++ b/src/qmmpui/configdialog.cpp @@ -69,6 +69,8 @@ ConfigDialog::ConfigDialog (QWidget *parent) : QDialog (parent) #ifndef Q_OS_WIN m_ui->bitDepthComboBox->addItem("32 (float)", Qmmp::PCM_FLOAT); #endif + m_ui->proxyTypeComboBox->addItem(tr("HTTP"), QmmpSettings::HTTP_PROXY); + m_ui->proxyTypeComboBox->addItem(tr("SOCKS5"), QmmpSettings::SOCKS5_PROXY); readSettings(); loadPluginsInfo(); loadLanguages(); @@ -131,6 +133,7 @@ void ConfigDialog::readSettings() m_ui->enableProxyCheckBox->setChecked(gs->isProxyEnabled()); m_ui->authProxyCheckBox->setChecked(gs->useProxyAuth()); m_ui->hostLineEdit->setText(gs->proxy().host()); + m_ui->proxyTypeComboBox->setCurrentIndex(m_ui->proxyTypeComboBox->findData(gs->proxyType())); if (gs->proxy().port(0)) m_ui->portLineEdit->setText(QString::number(gs->proxy().port(0))); m_ui->proxyUserLineEdit->setText(gs->proxy().userName()); @@ -138,6 +141,7 @@ void ConfigDialog::readSettings() m_ui->hostLineEdit->setEnabled(m_ui->enableProxyCheckBox->isChecked()); m_ui->portLineEdit->setEnabled(m_ui->enableProxyCheckBox->isChecked()); + m_ui->proxyTypeComboBox->setEnabled(m_ui->enableProxyCheckBox->isChecked()); m_ui->proxyUserLineEdit->setEnabled(m_ui->authProxyCheckBox->isChecked()); m_ui->proxyPasswLineEdit->setEnabled(m_ui->authProxyCheckBox->isChecked()); //file type determination @@ -404,6 +408,7 @@ void ConfigDialog::saveSettings() proxyUrl.setPassword(m_ui->proxyPasswLineEdit->text()); gs->setNetworkSettings(m_ui->enableProxyCheckBox->isChecked(), m_ui->authProxyCheckBox->isChecked(), + static_cast<QmmpSettings::ProxyType>(m_ui->proxyTypeComboBox->currentData().toInt()), proxyUrl); gs->setCoverSettings(m_ui->coverIncludeLineEdit->text().split(","), diff --git a/src/qmmpui/forms/configdialog.ui b/src/qmmpui/forms/configdialog.ui index 93ed345dc..0960b807a 100644 --- a/src/qmmpui/forms/configdialog.ui +++ b/src/qmmpui/forms/configdialog.ui @@ -517,19 +517,7 @@ </layout> </widget> <widget class="QWidget" name="network"> - <layout class="QVBoxLayout"> - <property name="leftMargin"> - <number>9</number> - </property> - <property name="topMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> + <layout class="QVBoxLayout" name="verticalLayout_6"> <item> <widget class="QGroupBox" name="groupBox_5"> <property name="title"> @@ -541,7 +529,7 @@ <property name="checkable"> <bool>false</bool> </property> - <layout class="QGridLayout"> + <layout class="QFormLayout" name="formLayout"> <item row="0" column="0" colspan="2"> <widget class="QCheckBox" name="enableProxyCheckBox"> <property name="text"> @@ -550,6 +538,16 @@ </widget> </item> <item row="1" column="0"> + <widget class="QLabel" name="label_19"> + <property name="text"> + <string>Proxy type:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="proxyTypeComboBox"/> + </item> + <item row="2" column="0"> <widget class="QLabel" name="label_5"> <property name="text"> <string>Proxy host name:</string> @@ -559,10 +557,10 @@ </property> </widget> </item> - <item row="1" column="1"> + <item row="2" column="1"> <widget class="QLineEdit" name="hostLineEdit"/> </item> - <item row="2" column="0"> + <item row="3" column="0"> <widget class="QLabel" name="label_6"> <property name="text"> <string>Proxy port:</string> @@ -572,17 +570,17 @@ </property> </widget> </item> - <item row="2" column="1"> + <item row="3" column="1"> <widget class="QLineEdit" name="portLineEdit"/> </item> - <item row="3" column="0" colspan="2"> + <item row="4" column="0" colspan="2"> <widget class="QCheckBox" name="authProxyCheckBox"> <property name="text"> <string>Use authentication with proxy</string> </property> </widget> </item> - <item row="4" column="0"> + <item row="5" column="0"> <widget class="QLabel" name="label_7"> <property name="text"> <string>Proxy user name:</string> @@ -592,10 +590,10 @@ </property> </widget> </item> - <item row="4" column="1"> + <item row="5" column="1"> <widget class="QLineEdit" name="proxyUserLineEdit"/> </item> - <item row="5" column="0"> + <item row="6" column="0"> <widget class="QLabel" name="label_8"> <property name="text"> <string>Proxy password:</string> @@ -605,7 +603,7 @@ </property> </widget> </item> - <item row="5" column="1"> + <item row="6" column="1"> <widget class="QLineEdit" name="proxyPasswLineEdit"> <property name="echoMode"> <enum>QLineEdit::Password</enum> @@ -915,12 +913,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>275</x> - <y>37</y> + <x>480</x> + <y>63</y> </hint> <hint type="destinationlabel"> - <x>275</x> - <y>37</y> + <x>617</x> + <y>131</y> </hint> </hints> </connection> @@ -931,12 +929,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>275</x> - <y>37</y> + <x>480</x> + <y>63</y> </hint> <hint type="destinationlabel"> - <x>275</x> - <y>37</y> + <x>617</x> + <y>163</y> </hint> </hints> </connection> @@ -947,12 +945,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>275</x> - <y>37</y> + <x>617</x> + <y>192</y> </hint> <hint type="destinationlabel"> - <x>275</x> - <y>37</y> + <x>617</x> + <y>224</y> </hint> </hints> </connection> @@ -963,12 +961,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>275</x> - <y>37</y> + <x>617</x> + <y>192</y> </hint> <hint type="destinationlabel"> - <x>272</x> - <y>37</y> + <x>617</x> + <y>256</y> </hint> </hints> </connection> @@ -1011,12 +1009,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>275</x> - <y>37</y> + <x>480</x> + <y>192</y> </hint> <hint type="destinationlabel"> - <x>275</x> - <y>37</y> + <x>617</x> + <y>194</y> </hint> </hints> </connection> @@ -1036,5 +1034,21 @@ </hint> </hints> </connection> + <connection> + <sender>enableProxyCheckBox</sender> + <signal>toggled(bool)</signal> + <receiver>proxyTypeComboBox</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>342</x> + <y>55</y> + </hint> + <hint type="destinationlabel"> + <x>356</x> + <y>88</y> + </hint> + </hints> + </connection> </connections> </ui> diff --git a/src/qmmpui/playlistdownloader.cpp b/src/qmmpui/playlistdownloader.cpp index 6ea9785ef..122b8ba97 100644 --- a/src/qmmpui/playlistdownloader.cpp +++ b/src/qmmpui/playlistdownloader.cpp @@ -37,6 +37,8 @@ PlayListDownloader::PlayListDownloader(QObject *parent) : QObject(parent) if (gs->isProxyEnabled()) { QNetworkProxy proxy(QNetworkProxy::HttpProxy, gs->proxy().host(), gs->proxy().port()); + if(gs->proxyType() == QmmpSettings::SOCKS5_PROXY) + proxy.setType(QNetworkProxy::Socks5Proxy); if(gs->useProxyAuth()) { proxy.setUser(gs->proxy().userName()); |
