Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // =============================================================================
- // DownloadSparkData()
- // =============================================================================
- //
- void Vasama::DownloadSparkData()
- {
- SetStatusText( "Initialize download...");
- iDlManager = new QNetworkAccessManager( this );
- connect( iDlManager,
- SIGNAL( finished( QNetworkReply* )),
- this,
- SLOT( DataDownloadFinished( QNetworkReply* )));
- iDlManager->get( QNetworkRequest( QUrl( iBaseUrl + KSparkTxd )));
- }
- // =============================================================================
- // DataDownloadFinished()
- // =============================================================================
- //
- void Vasama::DataDownloadFinished( QNetworkReply* reply )
- {
- SetStatusText( "Download finished...");
- QVariant statusCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute );
- qDebug() << "Vasama::DataDownloadFinished() status: " << statusCode;
- if (reply->error() == QNetworkReply::NoError && statusCode.toInt() == 200 )
- {
- // Read bytesfrom the reply
- QByteArray bytes = reply->readAll(); // bytes
- QString string( bytes ); // string
- string.remove( QChar('\r')); // strip MS-DOS carriage returns
- ParseData( string );
- }
- else
- {
- if ( !statusCode.toInt() ) statusCode.setValue( -1 );
- SetStatusText( "Download failed! (Response code: " + statusCode.toString() + ")");
- }
- reply->deleteLater();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement