From 267f257d3aed612d3eb6dd1f4107f753f7a62aca Mon Sep 17 00:00:00 2001
From: Rex Dieter <rdieter@math.unl.edu>
Date: Wed, 1 Oct 2014 07:45:23 -0500
Subject: [PATCH 1/7] respect toplevel INCLUDE_INSTALL_DIR/LIB_INSTALL_DIR

---
 src/CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ef5d525..802125b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -83,6 +83,6 @@ target_link_libraries( ${MYGPO_QT_TARGET_NAME} ${QJSON_LIBRARIES} ${QT_QTCORE_LI
 set_target_properties( ${MYGPO_QT_TARGET_NAME} PROPERTIES VERSION ${MYGPO_QT_VERSION} SOVERSION ${MYGPO_QT_SONAME} DEFINE_SYMBOL MYGPO_MAKEDLL)
 qt5_use_modules( ${MYGPO_QT_TARGET_NAME} Core Network )
 
-install( TARGETS ${MYGPO_QT_TARGET_NAME} EXPORT ${MYGPO_QT_TARGET_NAME}Export DESTINATION lib${LIB_SUFFIX} )
+install( TARGETS ${MYGPO_QT_TARGET_NAME} EXPORT ${MYGPO_QT_TARGET_NAME}Export DESTINATION ${LIB_INSTALL_DIR} )
 
-install( FILES ${LIBMYGPO_QT_INSTALL_H} DESTINATION  include/mygpo-qt COMPONENT Devel )
+install( FILES ${LIBMYGPO_QT_INSTALL_H} DESTINATION  ${INCLUDE_INSTALL_DIR} COMPONENT Devel )

From fd4e40a2a3c69d5b4ba94e483ddcbbf3541b5767 Mon Sep 17 00:00:00 2001
From: Stefan Derkits <stefan@derkits.at>
Date: Tue, 3 Nov 2015 23:16:08 +0100
Subject: [PATCH 2/7] header install dir should be different on qt4/qt5 builds

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fca1cd8..11285f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,7 +98,7 @@ set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "A c++/qt library to access the APIs prov
 set(LIB_SUFFIX "" CACHE STRING "The directories where to install libraries to")
 set(LIB_INSTALL_DIR lib${LIB_SUFFIX} )
 set(LIB_DIR_PKGCONF "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
-set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/mygpo-qt" CACHE PATH "The directory the headers are installed in")
+set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/mygpo-qt${MYGPO_QT_VERSION_SUFFIX}" CACHE PATH "The directory the headers are installed in")
 set(CMAKECONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/mygpo-qt )
 
 if( APPLE )

From 1fd86b31cc92f2ac450b875ebd8cc2a207906944 Mon Sep 17 00:00:00 2001
From: David Sansome <me@davidsansome.com>
Date: Sat, 21 Nov 2015 10:54:40 +1100
Subject: [PATCH 3/7] Default to using HTTPS

---
 src/Config.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Config.cpp b/src/Config.cpp
index a9ab859..231f33a 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -29,7 +29,7 @@ using namespace mygpo;
 
 Config* Config::s_instance = 0;
 
-ConfigPrivate::ConfigPrivate( Config* qq ) : q( qq ), m_mygpoBaseUrl( QUrl( QLatin1String( "http://gpodder.net" ) ) ), m_userAgentPrefix( QString() )
+ConfigPrivate::ConfigPrivate( Config* qq ) : q( qq ), m_mygpoBaseUrl( QUrl( QLatin1String( "https://gpodder.net" ) ) ), m_userAgentPrefix( QString() )
 {
 
 }

From aa417f294472d31aad342e153d7d2cf4a2edd0a5 Mon Sep 17 00:00:00 2001
From: David Sansome <me@davidsansome.com>
Date: Sat, 21 Nov 2015 11:28:11 +1100
Subject: [PATCH 4/7] Support QJson 0.7 which is still used in Precise

This version lacks a QJson::Serializer::serialize(const QVariant&, bool*),
so emulate it by checking whether the returned QByteArray isNull.

http://buildbot.clementine-player.org/builders/Ubuntu%20Precise%2064-bit/builds/68/steps/compile/logs/stdio
---
 src/qjsonwrapper/Json.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/qjsonwrapper/Json.cpp b/src/qjsonwrapper/Json.cpp
index 4a8c2ac..1b4a790 100644
--- a/src/qjsonwrapper/Json.cpp
+++ b/src/qjsonwrapper/Json.cpp
@@ -116,7 +116,12 @@ toJson( const QVariant &variant, bool* ok )
     return doc.toJson( QJsonDocument::Compact );
 #else
     QJson::Serializer serializer;
-    return serializer.serialize( variant, ok );
+    QByteArray ret = serializer.serialize(variant);
+    if ( ok != NULL )
+    {
+        *ok = !ret.isNull();
+    }
+    return ret;
 #endif
 }
 

From e2889b298e4f74e7ec8f1a4df6da7e7babd9fc02 Mon Sep 17 00:00:00 2001
From: David Sansome <me@davidsansome.com>
Date: Sat, 21 Nov 2015 10:53:01 +1100
Subject: [PATCH 5/7] Make it possible to change the server URL used by
 UrlBuilder.

Currently it initializes s_server once on startup - so subsequent calls to
Config::setMygpoBaseUrl have no effect.
---
 src/UrlBuilder.cpp | 76 +++++++++++++++++++++++++++++++++++-------------------
 src/UrlBuilder.h   |  1 -
 2 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/src/UrlBuilder.cpp b/src/UrlBuilder.cpp
index eebcc30..af771db 100644
--- a/src/UrlBuilder.cpp
+++ b/src/UrlBuilder.cpp
@@ -30,7 +30,6 @@
 
 using namespace mygpo;
 
-const QString UrlBuilder::s_server = Config::instance()->mygpoBaseUrl().toString();
 const QString UrlBuilder::s_api2 = QLatin1String( "/api/2" );
 const QString UrlBuilder::s_api1 = QLatin1String( "/api/1" );
 
@@ -58,93 +57,110 @@ static QString getFormatExtension( UrlBuilder::Format f )
 QString UrlBuilder::getToplistUrl( uint i, Format f )
 {
     QString numString = QString::number(( i == 0 ) ? 1 : i );
-    return s_server % QLatin1String( "/toplist/" ) % numString % getFormatExtension( f );
+    return Config::instance()->mygpoBaseUrl().toString() %
+        QLatin1String( "/toplist/" ) % numString % getFormatExtension( f );
 }
 
 QString UrlBuilder::getSuggestionsUrl( uint i, Format f )
 {
     QString numString = QString::number(( i == 0 ) ? 1 : i );
-    return s_server % QLatin1String( "/suggestions/" ) % numString % getFormatExtension( f );
+    return Config::instance()->mygpoBaseUrl().toString() %
+        QLatin1String( "/suggestions/" ) % numString % getFormatExtension( f );
 }
 
 QString UrlBuilder::getPodcastSearchUrl( const QString& query, Format f )
 {
-    return s_server % QLatin1String( "/search" ) % getFormatExtension( f ) % QLatin1String( "?q=" ) % query;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        QLatin1String( "/search" ) % getFormatExtension( f ) % QLatin1String( "?q=" ) % query;
 }
 
 QString UrlBuilder::getSubscriptionsUrl( const QString& username, const QString& device, UrlBuilder::Format f)
 {
     QString deviceString = device.isNull() ? QString(QLatin1String("")) : (QLatin1String( "/" ) % device);
-    return s_server % QLatin1String( "/subscriptions/" ) % username % deviceString % getFormatExtension( f );
+    return Config::instance()->mygpoBaseUrl().toString() %
+        QLatin1String( "/subscriptions/" ) % username % deviceString % getFormatExtension( f );
 }
 
 QString UrlBuilder::getTopTagsUrl( uint i )
 {
     QString numString = QString::number(( i == 0 ) ? 1 : i );
-    return s_server % s_api2 % QLatin1String( "/tags/" ) % numString % QLatin1String( ".json" );
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/tags/" ) % numString % QLatin1String( ".json" );
 }
 
 QString UrlBuilder::getPodcastsOfTagUrl( const QString& tag, uint i )
 {
     QString numString = QString::number(( i == 0 ) ? 1 : i );
-    return s_server % s_api2 % QLatin1String( "/tag/" ) % tag % QLatin1String( "/" ) % numString % QLatin1String( ".json" );
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/tag/" ) % tag % QLatin1String( "/" ) % numString % QLatin1String( ".json" );
 }
 
 QString UrlBuilder::getPodcastDataUrl( const QString& url )
 {
-    return s_server % s_api2 % QLatin1String( "/data/podcast" ) % QLatin1String( ".json" ) % QLatin1String( "?url=" ) % url;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/data/podcast" ) % QLatin1String( ".json" ) % QLatin1String( "?url=" ) % url;
 }
 
 QString UrlBuilder::getEpisodeDataUrl( const QString& podcastUrl, const QString& episodeUrl )
 {
-    return s_server % s_api2 % QLatin1String( "/data/episode" ) % QLatin1String( ".json" ) % QLatin1String( "?podcast=" ) % podcastUrl % QLatin1String( "&url=" ) % episodeUrl;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/data/episode" ) % QLatin1String( ".json" ) % QLatin1String( "?podcast=" ) % podcastUrl % QLatin1String( "&url=" ) % episodeUrl;
 }
 
 QString UrlBuilder::getFavEpisodesUrl( const QString& username )
 {
-    return s_server % s_api2 % QLatin1String( "/favorites/" ) % username % QLatin1String( ".json" );
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/favorites/" ) % username % QLatin1String( ".json" );
 }
 
 
 QString UrlBuilder::getAddRemoveSubUrl( const QString& username, const QString& deviceId )
 {
-    return s_server % s_api2 % QLatin1String( "/subscriptions/" ) % username % QLatin1String( "/" ) % deviceId % QLatin1String( ".json" );
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/subscriptions/" ) % username % QLatin1String( "/" ) % deviceId % QLatin1String( ".json" );
 }
 
 QString UrlBuilder::getAccountSettingsUrl( const QString& username )
 {
-    return s_server % s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/account" ) % QLatin1String( ".json" );
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/account" ) % QLatin1String( ".json" );
 }
 
 QString UrlBuilder::getDeviceSettingsUrl( const QString& username, const QString& deviceId )
 {
-    return s_server % s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/device" ) % QLatin1String( ".json" ) % QLatin1String( "?device=" ) % deviceId;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/device" ) % QLatin1String( ".json" ) % QLatin1String( "?device=" ) % deviceId;
 }
 
 QString UrlBuilder::getPodcastSettingsUrl( const QString& username, const QString& podcastUrl )
 {
-    return s_server % s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/podcast" ) % QLatin1String( ".json" ) % QLatin1String( "?podcast=" ) % podcastUrl;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/podcast" ) % QLatin1String( ".json" ) % QLatin1String( "?podcast=" ) % podcastUrl;
 }
 
 QString UrlBuilder::getEpisodeSettingsUrl( const QString& username, const QString& podcastUrl, const QString& episodeUrl )
 {
-    return s_server % s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/episode" ) % QLatin1String( ".json" ) % QLatin1String( "?podcast=" ) % podcastUrl % QLatin1String( "&episode=" ) % episodeUrl;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/settings/" ) % username % QLatin1String( "/episode" ) % QLatin1String( ".json" ) % QLatin1String( "?podcast=" ) % podcastUrl % QLatin1String( "&episode=" ) % episodeUrl;
 }
 
 QString UrlBuilder::getDeviceListUrl( const QString& username )
 {
-    return s_server % s_api2 % QLatin1String( "/devices/" ) % username % QLatin1String( ".json" ) ;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/devices/" ) % username % QLatin1String( ".json" ) ;
 }
 
 QString UrlBuilder::getDeviceUpdatesUrl( const QString& username, const QString& deviceId, qulonglong timestamp )
 {
     QString numString = QString::number( timestamp );
-    return s_server % s_api2 % QLatin1String( "/updates/" ) % username % QLatin1String( "/" ) % deviceId % QLatin1String( ".json?since=" ) % numString;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/updates/" ) % username % QLatin1String( "/" ) % deviceId % QLatin1String( ".json?since=" ) % numString;
 }
 
 QString UrlBuilder::getRenameDeviceUrl( const QString& username, const QString& deviceId )
 {
-    return s_server % s_api2 % QLatin1String( "/devices/" ) % username % QLatin1String( "/" ) % deviceId % QLatin1String( ".json" );
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/devices/" ) % username % QLatin1String( "/" ) % deviceId % QLatin1String( ".json" );
 }
 
 QString UrlBuilder::getEpisodeActionsUrl( const QString& username, const bool aggregated )
@@ -155,7 +171,8 @@ QString UrlBuilder::getEpisodeActionsUrl( const QString& username, const bool ag
     else
         agg = QLatin1String( "" );
 
-    return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json" ) % agg;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json" ) % agg;
 }
 
 QString UrlBuilder::getEpisodeActionsUrlByPodcast( const QString& username, const QString& podcastUrl, const bool aggregated )
@@ -166,7 +183,8 @@ QString UrlBuilder::getEpisodeActionsUrlByPodcast( const QString& username, cons
     else
         agg = QLatin1String( "" );
 
-    return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?podcast=" ) % podcastUrl % agg;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?podcast=" ) % podcastUrl % agg;
 }
 
 QString UrlBuilder::getEpisodeActionsUrlByDevice( const QString& username, const QString& deviceId, bool aggregated )
@@ -177,33 +195,39 @@ QString UrlBuilder::getEpisodeActionsUrlByDevice( const QString& username, const
     else
         agg = QLatin1String( "" );
 
-    return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?device=" ) % deviceId % agg;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?device=" ) % deviceId % agg;
 }
 
 QString UrlBuilder::getEpisodeActionsUrlByTimestamp( const QString& username, qulonglong since )
 {
     QString numString = QString::number( since );
-    return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?since=" ) % numString;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?since=" ) % numString;
 }
 
 QString UrlBuilder::getEpisodeActionsUrlByPodcastAndTimestamp( const QString& username, const QString& podcastUrl, qulonglong since )
 {
     QString numString = QString::number( since );
-    return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?podcast=" ) % podcastUrl % QLatin1String( "&since=" ) % numString;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?podcast=" ) % podcastUrl % QLatin1String( "&since=" ) % numString;
 }
 
 QString UrlBuilder::getEpisodeActionsUrlByDeviceAndTimestamp( const QString& username, const QString& deviceId, qulonglong since )
 {
     QString numString = QString::number( since );
-    return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?device=" ) % deviceId % QLatin1String( "&since=" ) % numString;
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json?device=" ) % deviceId % QLatin1String( "&since=" ) % numString;
 }
 
 QString UrlBuilder::getUploadEpisodeActionsUrl( const QString& username )
 {
-    return s_server % s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json" );
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/episodes/" ) % username % QLatin1String( ".json" );
 }
 
 QString UrlBuilder::getDeviceSynchronizationStatusUrl ( const QString& username )
 {
-    return s_server % s_api2 % QLatin1String( "/sync-devices/" ) % username % QLatin1String( ".json" );
+    return Config::instance()->mygpoBaseUrl().toString() %
+        s_api2 % QLatin1String( "/sync-devices/" ) % username % QLatin1String( ".json" );
 }
diff --git a/src/UrlBuilder.h b/src/UrlBuilder.h
index 6f2c2c5..625cef1 100644
--- a/src/UrlBuilder.h
+++ b/src/UrlBuilder.h
@@ -137,7 +137,6 @@ class UrlBuilder
 private:
     UrlBuilder() {};
     UrlBuilder( const UrlBuilder& ) {};
-    static const QString s_server;
     static const QString s_api2;
     static const QString s_api1;
 };

From 5e633a2880d196ab3e10f1c3815834e1e2b5a75c Mon Sep 17 00:00:00 2001
From: Stefan Derkits <stefan@derkits.at>
Date: Sun, 22 Nov 2015 16:24:51 +0100
Subject: [PATCH 6/7] small style fix in Json.cpp

---
 src/qjsonwrapper/Json.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qjsonwrapper/Json.cpp b/src/qjsonwrapper/Json.cpp
index 1b4a790..d87c2b3 100644
--- a/src/qjsonwrapper/Json.cpp
+++ b/src/qjsonwrapper/Json.cpp
@@ -116,7 +116,7 @@ toJson( const QVariant &variant, bool* ok )
     return doc.toJson( QJsonDocument::Compact );
 #else
     QJson::Serializer serializer;
-    QByteArray ret = serializer.serialize(variant);
+    QByteArray ret = serializer.serialize( variant );
     if ( ok != NULL )
     {
         *ok = !ret.isNull();

From 0f67e97087654055e665095bdb4bc1775787a46d Mon Sep 17 00:00:00 2001
From: Stefan Derkits <stefan@derkits.at>
Date: Wed, 30 Mar 2016 17:54:01 +0200
Subject: [PATCH 7/7] adapt UrlBuilderTest to https urls

---
 tests/UrlBuilderTest.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/UrlBuilderTest.cpp b/tests/UrlBuilderTest.cpp
index 1aae701..d963225 100644
--- a/tests/UrlBuilderTest.cpp
+++ b/tests/UrlBuilderTest.cpp
@@ -24,7 +24,7 @@
 
 using namespace mygpo;
 
-UrlBuilderTest::UrlBuilderTest() :m_server(QLatin1String("http://gpodder.net")),
+UrlBuilderTest::UrlBuilderTest() :m_server(QLatin1String("https://gpodder.net")),
         m_api2(QLatin1String( "/api/2" )) {
 
 }
