This commit is contained in:
LubuWest 2019-06-25 20:59:10 +02:00
commit d48847d183
135 changed files with 8879 additions and 3693 deletions

View file

@ -1,5 +1,5 @@
// This file is part of Friendiqa
// https://git.friendi.ca/lubuwest/Friendiqa
// https://github.com/lubuwest/Friendiqa
// Copyright (C) 2017 Marco R. <thomasschmidt45@gmx.net>
//
// This program is free software: you can redistribute it and/or modify
@ -154,7 +154,7 @@ QString XHR::downloadtype() const
return m_downloadtype;
}
QString XHR::networktype() const
QString XHR::networktype()
{
return nc.bearerTypeFamily() + nc.bearerTypeName();
}
@ -184,7 +184,6 @@ void XHR::download()
request.setRawHeader("Authorization", headerData.toLocal8Bit());
}
request.setUrl(requrl);
//qDebug() << requrl;
reply = manager.get(request);
reply->ignoreSslErrors();
connect(reply, &QNetworkReply::readyRead,this, &XHR::onReadyRead);
@ -202,10 +201,11 @@ void XHR::get()
while(i.hasNext()) {
i.next();
query.addQueryItem(i.key(), i.value());
//qDebug()<<i.key() << " value "<< i.value();
}
QUrl requrl(m_url+m_api);
qDebug() << requrl;
//qDebug() << "API "<< requrl<<m_api;
requrl.setQuery(query);
QByteArray loginData = m_login.toLocal8Bit().toBase64();
QString headerData = "Basic " + loginData;
@ -229,19 +229,19 @@ void XHR::getlist()
else {
XHR::setUrl(m_filelist.at(dlindex));}
XHR::download();
} else {dlindex=0;}
} else {dlindex=0;m_downloadtype="";m_contactlist.clear();m_filelist.clear();}
}
void XHR::post()
{
qDebug() << "start post to " << m_url;
//qDebug() << "start post to " << m_url;
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
QHashIterator<QString, QString> iparams(params);
while(iparams.hasNext()) {
iparams.next();
qDebug() << "\t add param " << iparams.key() << " : " << iparams.value();
//qDebug() << "\t add param " << iparams.key() << " : " << iparams.value();
QHttpPart textPart;
textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"" + iparams.key() + "\""));
@ -256,7 +256,7 @@ void XHR::post()
ifiles.next();
uimg.setSource(ifiles.value());
qDebug() << "\t image: " << uimg.mimetype() << ", " << ifiles.key();
//qDebug() << "\t image: " << uimg.mimetype() << ", " << ifiles.key();
QHttpPart imagePart;
imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(uimg.mimetype()));
@ -290,14 +290,14 @@ void XHR::onReplyError(QNetworkReply::NetworkError code)
void XHR::onReplySuccess()
{
qDebug() << "!";
//emit this->success( bufferToString(), m_api);
emit this->success( buffer, m_api);
emit this->success(buffer, m_api);
buffer.clear();
// reply->deleteLater();
}
void XHR::onRequestFinished()
{
qDebug()<<"download requestFinished ";
// Save the file here
if (buffer.isNull()){qDebug() << "File empty"<<m_url; buffer.clear(); emit this->error(m_downloadtype,m_url,m_api,1);}
else if (m_downloadtype=="picturelist") {