From 4ea29b1cf1c8a583126a71b0db2a60a2efb75897 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 9 May 2019 10:40:51 -0400 Subject: [PATCH] [libcalamares] Implement "raw" handling --- src/libcalamares/geoip/Handler.cpp | 33 ++++++++++++++++++++++++++++++ src/libcalamares/geoip/Handler.h | 2 -- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/libcalamares/geoip/Handler.cpp b/src/libcalamares/geoip/Handler.cpp index f98ac897d..7aa8ee701 100644 --- a/src/libcalamares/geoip/Handler.cpp +++ b/src/libcalamares/geoip/Handler.cpp @@ -124,6 +124,16 @@ do_query( Handler::Type type, const QString& url, const QString& selector ) return interface->processReply( synchronous_get( url ) ); } +static QString +do_raw_query( Handler::Type type, const QString& url, const QString& selector ) +{ + const auto interface = create_interface( type, selector ); + if ( !interface ) + return QString(); + + return interface->rawReply( synchronous_get( url ) ); +} + RegionZonePair Handler::get() const { @@ -146,4 +156,27 @@ Handler::query() const } ); } +QString +Handler::getRaw() const +{ + if ( !isValid() ) + return QString(); + return do_raw_query( m_type, m_url, m_selector ); +} + + +QFuture< QString > +Handler::queryRaw() const +{ + Handler::Type type = m_type; + QString url = m_url; + QString selector = m_selector; + + return QtConcurrent::run( [=] + { + return do_raw_query( type, url, selector ); + } ); +} + + } // namespace diff --git a/src/libcalamares/geoip/Handler.h b/src/libcalamares/geoip/Handler.h index b095c59ac..92e5f326e 100644 --- a/src/libcalamares/geoip/Handler.h +++ b/src/libcalamares/geoip/Handler.h @@ -77,8 +77,6 @@ public: /// @brief Like query, but don't interpret the contents QFuture< QString > queryRaw() const; - - bool isValid() const { return m_type != Type::None; } Type type() const { return m_type; }