A new user interface for you! Read more...

File Enable_Wikipedia_over_SSL.patch of Package amarok

From: Frank Meerk├Âtter <frank@meerkoetter.org>
Date: Thu, 12 Sep 2013 19:44:03 +0000
Subject: Enable Wikipedia over SSL.
X-Git-Tag: v2.8.90
X-Git-Url: http://quickgit.kde.org/?p=amarok.git&a=commitdiff&h=284342b48dc32341c3553fd2b0ee5069d75b58f9
---
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
---


--- a/src/context/applets/wikipedia/WikipediaApplet.cpp
+++ b/src/context/applets/wikipedia/WikipediaApplet.cpp
@@ -250,11 +250,14 @@
     }
     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 @@
     // 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 @@
     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()) );

--- a/src/context/applets/wikipedia/WikipediaApplet_p.h
+++ b/src/context/applets/wikipedia/WikipediaApplet_p.h
@@ -143,6 +143,7 @@
     bool isForwardHistory;
     bool isBackwardHistory;
     bool useMobileWikipedia;
+    bool useSSL;
 };
 
 class WikipediaSearchLineEdit : public Plasma::LineEdit

--- a/src/context/applets/wikipedia/wikipediaGeneralSettings.ui
+++ b/src/context/applets/wikipedia/wikipediaGeneralSettings.ui
@@ -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>

--- a/src/context/engines/wikipedia/WikipediaEngine.cpp
+++ b/src/context/engines/wikipedia/WikipediaEngine.cpp
@@ -45,6 +45,7 @@
         : q_ptr( parent )
         , currentSelection( Artist )
         , useMobileVersion( false )
+        , useSSL( true )
         , dataContainer( 0 )
     {}
     ~WikipediaEnginePrivate() {}
@@ -88,6 +89,7 @@
         }
     } m_previousTrackMetadata;
     bool useMobileVersion;
+    bool useSSL;
 
     Plasma::DataContainer *dataContainer;
 
@@ -165,6 +167,16 @@
         {
             debug() << (mobile ? "switching to mobile wikipedia" : "switching to normal wikipedia");
             useMobileVersion = mobile;
+            updateEngine();
+        }
+    }
+
+    if( data.contains( QLatin1String("ssl") ) )
+    {
+        const bool ssl = data.value( QLatin1String("ssl") ).toBool();
+        if( ssl != useSSL )
+        {
+            useSSL = ssl;
             updateEngine();
         }
     }
@@ -532,7 +544,7 @@
     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 @@
 {
     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 @@
 {
     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") );