1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 07:19:42 +01:00

Add user agent to pong request

This commit is contained in:
Dominik Schmidt 2014-12-19 14:51:14 +01:00
parent fbdb363362
commit 19d617266e
3 changed files with 33 additions and 1 deletions

View File

@ -623,6 +623,27 @@ crash()
}
const QString
operatingSystemVersionDetail()
{
#ifdef Q_OS_LINUX
return QSettings( "/etc/os-release", QSettings::IniFormat ).value( "PRETTY_NAME", "Linux" ).toString();
#else
return "Unknown";
#endif
}
const QString
userAgentString( const QString& applicationName, const QString& applicationVersion )
{
return QString( "%1/%2 (%3)" )
.arg( applicationName )
.arg( applicationVersion )
.arg( operatingSystemVersionDetail() );
}
void
installTranslator( QObject* parent )
{

View File

@ -206,6 +206,11 @@ namespace TomahawkUtils
DLLEXPORT void crash();
/**
* User-Agent header helpers
*/
DLLEXPORT const QString operatingSystemVersionDetail();
DLLEXPORT const QString userAgentString( const QString& applicationName, const QString& applicationVersion );
/**
* Qt4 / Qt5 compatibility layer

View File

@ -693,7 +693,13 @@ TomahawkApp::onInfoSystemReady()
GlobalActionManager::instance();
// check if our spotify playlist api server is up and running, and enable spotify playlist drops if so
QNetworkReply* r = Tomahawk::Utils::nam()->get( QNetworkRequest( QUrl( SPOTIFY_PLAYLIST_API_URL "/pong" ) ) );
QNetworkRequest request( QUrl( SPOTIFY_PLAYLIST_API_URL "/pong" ) );
QByteArray userAgent = TomahawkUtils::userAgentString( TOMAHAWK_APPLICATION_NAME, TOMAHAWK_VERSION ).toUtf8();
tLog() << "User-Agent: " << userAgent;
request.setRawHeader( "User-Agent", userAgent );
QNetworkReply* r = Tomahawk::Utils::nam()->get( request );
connect( r, SIGNAL( finished() ), this, SLOT( spotifyApiCheckFinished() ) );
#ifdef Q_OS_MAC