mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:30:05 +00:00 
			
		
		
		
	Don't use a hard-coded user-agent for placefiles, add DPI parameter
This commit is contained in:
		
							parent
							
								
									751cafbfe7
								
							
						
					
					
						commit
						e3449e382d
					
				
					 5 changed files with 58 additions and 6 deletions
				
			
		|  | @ -1,8 +1,10 @@ | |||
| #include <scwx/qt/config/radar_site.hpp> | ||||
| #include <scwx/qt/main/main_window.hpp> | ||||
| #include <scwx/qt/main/versions.hpp> | ||||
| #include <scwx/qt/manager/radar_product_manager.hpp> | ||||
| #include <scwx/qt/manager/resource_manager.hpp> | ||||
| #include <scwx/qt/manager/settings_manager.hpp> | ||||
| #include <scwx/network/cpr.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
| #include <scwx/util/threads.hpp> | ||||
| 
 | ||||
|  | @ -26,6 +28,8 @@ int main(int argc, char* argv[]) | |||
|    QApplication a(argc, argv); | ||||
| 
 | ||||
|    QCoreApplication::setApplicationName("Supercell Wx"); | ||||
|    scwx::network::cpr::SetUserAgent( | ||||
|       fmt::format("SupercellWx/{}", scwx::qt::main::kVersionString_)); | ||||
| 
 | ||||
|    // Enable internationalization support
 | ||||
|    QTranslator translator; | ||||
|  |  | |||
|  | @ -1,11 +1,14 @@ | |||
| #include <scwx/qt/manager/placefile_manager.hpp> | ||||
| #include <scwx/gr/placefile.hpp> | ||||
| #include <scwx/network/cpr.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
| 
 | ||||
| #include <shared_mutex> | ||||
| #include <vector> | ||||
| 
 | ||||
| #include <QDir> | ||||
| #include <QGuiApplication> | ||||
| #include <QScreen> | ||||
| #include <QUrl> | ||||
| #include <boost/algorithm/string.hpp> | ||||
| #include <boost/asio/post.hpp> | ||||
|  | @ -340,9 +343,12 @@ void PlacefileManager::Impl::PlacefileRecord::Update() | |||
|          return; | ||||
|       } | ||||
| 
 | ||||
|       auto dpi = QGuiApplication::primaryScreen()->logicalDotsPerInch(); | ||||
| 
 | ||||
|       // Specify parameters
 | ||||
|       auto parameters = cpr::Parameters { | ||||
|          {"version", "1.2"}, // Placefile Version Supported
 | ||||
|          {"dpi", fmt::format("{:0.0f}", dpi)}, | ||||
|          {"lat", fmt::format("{:0.3f}", p->radarSite_->latitude())}, | ||||
|          {"lon", fmt::format("{:0.3f}", p->radarSite_->longitude())}}; | ||||
| 
 | ||||
|  | @ -373,11 +379,8 @@ void PlacefileManager::Impl::PlacefileRecord::Update() | |||
|       } | ||||
| 
 | ||||
|       // Send HTTP GET request
 | ||||
|       // TODO: Update hard coded User-Agent
 | ||||
|       auto response = | ||||
|          cpr::Get(cpr::Url {decodedUrl}, | ||||
|                   cpr::Header {{"User-Agent", "SupercellWx/0.2.2"}}, | ||||
|                   parameters); | ||||
|          cpr::Get(cpr::Url {decodedUrl}, network::cpr::GetHeader(), parameters); | ||||
| 
 | ||||
|       if (cpr::status::is_success(response.status_code)) | ||||
|       { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat