Commit 284342b4 authored by Frank Meerkötter's avatar Frank Meerkötter
Browse files

Enable Wikipedia over SSL.

This patch makes SSL the default. It also adds a checkbox to disable
it so if there would be a problem a fallback to HTTP is possible.

BUG: 322249
REVIEW: 112706
FIXED-IN: 2.9
parent 3eb2e8b6
......@@ -250,11 +250,14 @@ WikipediaAppletPrivate::_loadSettings()
}
langList = list;
useMobileWikipedia = (generalSettingsUi.mobileCheckBox->checkState() == Qt::Checked);
useSSL = (generalSettingsUi.sslCheckBox->checkState() == Qt::Checked);
Amarok::config("Wikipedia Applet").writeEntry( "PreferredLang", list );
Amarok::config("Wikipedia Applet").writeEntry( "UseMobile", useMobileWikipedia );
Amarok::config( "Wikipedia Applet" ).writeEntry( "UseSSL", useSSL );
_paletteChanged( App::instance()->palette() );
dataContainer->setData( "lang", langList );
dataContainer->setData( "mobile", useMobileWikipedia );
dataContainer->setData( "ssl", useSSL );
scheduleEngineUpdate();
}
......@@ -656,9 +659,11 @@ WikipediaApplet::init()
// Read config and inform the engine.
d->langList = Amarok::config("Wikipedia Applet").readEntry( "PreferredLang", QStringList() << "en" );
d->useMobileWikipedia = Amarok::config("Wikipedia Applet").readEntry( "UseMobile", false );
d->useSSL = Amarok::config( "Wikipedia Applet" ).readEntry( "UseSSL", true );
d->_paletteChanged( App::instance()->palette() );
d->dataContainer->setData( "lang", d->langList );
d->dataContainer->setData( "mobile", d->useMobileWikipedia );
d->dataContainer->setData( "ssl", d->useSSL );
d->scheduleEngineUpdate();
updateConstraints();
......@@ -787,6 +792,7 @@ WikipediaApplet::createConfigurationInterface( KConfigDialog *parent )
QWidget *genSettings = new QWidget;
d->generalSettingsUi.setupUi( genSettings );
d->generalSettingsUi.mobileCheckBox->setCheckState( d->useMobileWikipedia ? Qt::Checked : Qt::Unchecked );
d->generalSettingsUi.sslCheckBox->setCheckState( d->useSSL ? Qt::Checked : Qt::Unchecked );
connect( d->languageSettingsUi.downloadButton, SIGNAL(clicked()), this, SLOT(_getLangMap()) );
connect( parent, SIGNAL(okClicked()), this, SLOT(_loadSettings()) );
......
......@@ -143,6 +143,7 @@ public:
bool isForwardHistory;
bool isBackwardHistory;
bool useMobileWikipedia;
bool useSSL;
};
class WikipediaSearchLineEdit : public Plasma::LineEdit
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>244</width>
<height>23</height>
<width>253</width>
<height>62</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -32,6 +32,13 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="sslCheckBox">
<property name="text">
<string>Use &amp;SSL</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......
......@@ -45,6 +45,7 @@ public:
: q_ptr( parent )
, currentSelection( Artist )
, useMobileVersion( false )
, useSSL( true )
, dataContainer( 0 )
{}
~WikipediaEnginePrivate() {}
......@@ -88,6 +89,7 @@ public:
}
} m_previousTrackMetadata;
bool useMobileVersion;
bool useSSL;
Plasma::DataContainer *dataContainer;
......@@ -169,6 +171,16 @@ WikipediaEnginePrivate::_dataContainerUpdated( const QString &source, const Plas
}
}
if( data.contains( QLatin1String("ssl") ) )
{
const bool ssl = data.value( QLatin1String("ssl") ).toBool();
if( ssl != useSSL )
{
useSSL = ssl;
updateEngine();
}
}
if( data.contains( QLatin1String("lang") ) )
{
QStringList langList = data.value( QLatin1String("lang") ).toStringList();
......@@ -532,7 +544,7 @@ WikipediaEnginePrivate::fetchWikiUrl( const QString &title, const QString &urlPr
Q_Q( WikipediaEngine );
KUrl pageUrl;
QString host( ".wikipedia.org" );
pageUrl.setScheme( QLatin1String("http") );
pageUrl.setScheme( useSSL ? QLatin1String( "https" ) : QLatin1String( "http" ) );
if( useMobileVersion )
{
......@@ -570,7 +582,7 @@ WikipediaEnginePrivate::fetchLangLinks( const QString &title,
{
Q_Q( WikipediaEngine );
KUrl url;
url.setScheme( QLatin1String("http") );
url.setScheme( useSSL ? QLatin1String( "https" ) : QLatin1String( "http" ) );
url.setHost( hostLang + QLatin1String(".wikipedia.org") );
url.setPath( QLatin1String("/w/api.php") );
url.addQueryItem( QLatin1String("action"), QLatin1String("query") );
......@@ -592,7 +604,7 @@ WikipediaEnginePrivate::fetchListing( const QString &title, const QString &hostL
{
Q_Q( WikipediaEngine );
KUrl url;
url.setScheme( QLatin1String("http") );
url.setScheme( useSSL ? QLatin1String( "https" ) : QLatin1String( "http" ) );
url.setHost( hostLang + QLatin1String(".wikipedia.org") );
url.setPath( QLatin1String("/w/api.php") );
url.addQueryItem( QLatin1String("action"), QLatin1String("query") );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment