11 #include <QNetworkAccessManager>
12 #include <QNetworkCookie>
18 #include <QStringMatcher>
65 : m_theclass(theclass)
66 , m_fileInfoUrl(fileInfoUrl)
68 , m_updateInterval(updateInterval)
73 , m_urlLastMod(
"UNKNOWN")
74 , m_expectedMD5Sum(
"")
82 QString infofilebasename = QFileInfo(
path).fileName();
83 if (!infofilebasename.isEmpty()&&
path.endsWith(infofilebasename)) {
110 connect(m_netreply, SIGNAL(
error(QNetworkReply::NetworkError)),
111 m_theclass, SLOT(
error(QNetworkReply::NetworkError)));
114 m_theclass, SLOT(
sslErrors(
const QList<QSslError>&)));
116 connect(m_netreply, SIGNAL(downloadProgress(qint64,qint64)),
128 ,
m_d(
new Imp(this,fileinfoUrl,updateInterval))
156 QNetworkRequest netrequest(fileInfoUrl);
174 QString
target = activeRetrievalDir +
"downloadedfileinfo.txt";
177 if (!newEvtsOnServerInfo.
isValid()) {
203 QList<VP1EventFile> freshLocalEvents =
freshEvents();
206 if (
evt < evtToGet) {
221 QNetworkRequest netrequestEvt(
url);
237 QVariant
val =
m_d->
m_netreply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
238 if(
val.type()==QVariant::Int)
239 sc =
val.value<
int>();
240 else if(
val.type()==QVariant::Invalid)
242 else if(!
val.canConvert<
int>())
243 message(
"Cannot convert status code to int while processing " +
m_d->
m_netreply->url().toString());
245 sc =
val.value<
int>();
249 QString lastModified;
250 QVariant lastModHeader =
m_d->
m_netreply->header(QNetworkRequest::LastModifiedHeader);
251 if(lastModHeader.type()!=QVariant::Invalid &&
252 lastModHeader.canConvert<QDateTime>()) {
253 QDateTime lastModTime = lastModHeader.value<QDateTime>();
254 lastModified = lastModTime.toString();
277 QString
target = activeRetrievalDir +
"downloadedfileinfo.txt";
285 message(
"ERROR: Could not remove the old fileinfo " +
target);
292 QFile localfileinfo(
target);
293 if(!localfileinfo.open(QIODevice::WriteOnly)) {
302 localfileinfo.write(ba);
303 localfileinfo.close();
309 if(!targetFile.open(QIODevice::WriteOnly)) {
318 targetFile.write(ba);
327 message(
"Checksum did not match");
335 if(!QFile::rename(
target,finalTarget)) {
336 message(
"ERROR: Could not move " +
target +
" to " + finalTarget);
361 +
"\n Error decoding here: http://doc.trolltech.com/4.4/qnetworkreply.html#NetworkError-enum");
391 unsigned currentTime = QDateTime::currentDateTime().toTime_t();