Friendiqa v0.3
This commit is contained in:
parent
585e329bcb
commit
bda2d9f7b5
63 changed files with 2746 additions and 1357 deletions
|
@ -59,6 +59,14 @@ void XHR::setUrl(QString url)
|
|||
}
|
||||
}
|
||||
|
||||
void XHR::setApi(QString api)
|
||||
{
|
||||
if (api!=m_api) {
|
||||
m_api = api;
|
||||
emit apiChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void XHR::setLogin(QString login)
|
||||
{
|
||||
if (login!=m_login) {
|
||||
|
@ -111,6 +119,11 @@ QString XHR::url() const
|
|||
return m_url;
|
||||
}
|
||||
|
||||
QString XHR::api() const
|
||||
{
|
||||
return m_api;
|
||||
}
|
||||
|
||||
QString XHR::login() const
|
||||
{
|
||||
return m_login;
|
||||
|
@ -166,6 +179,7 @@ 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);
|
||||
|
@ -185,9 +199,9 @@ void XHR::get()
|
|||
query.addQueryItem(i.key(), i.value());
|
||||
}
|
||||
|
||||
QUrl requrl(m_url);
|
||||
QUrl requrl(m_url+m_api);
|
||||
//qDebug() << requrl;
|
||||
requrl.setQuery(query);
|
||||
|
||||
QByteArray loginData = m_login.toLocal8Bit().toBase64();
|
||||
QString headerData = "Basic " + loginData;
|
||||
request.setRawHeader("Authorization", headerData.toLocal8Bit());
|
||||
|
@ -250,7 +264,7 @@ void XHR::post()
|
|||
QString headerData = "Basic " + loginData;
|
||||
request.setRawHeader(QByteArray("Authorization"), headerData.toLocal8Bit());
|
||||
|
||||
request.setUrl(m_url);
|
||||
request.setUrl(m_url+m_api);
|
||||
reply = manager.post(request, multiPart);
|
||||
qDebug() << "\t request sent";
|
||||
connect(reply, &QNetworkReply::finished, this, &XHR::onReplySuccess);
|
||||
|
@ -263,7 +277,7 @@ void XHR::post()
|
|||
void XHR::onReplyError(QNetworkReply::NetworkError code)
|
||||
{
|
||||
qDebug() << code;
|
||||
emit this->error( bufferToString(), m_url, (int) code);
|
||||
emit this->error( bufferToString(), m_url,m_api, (int) code);
|
||||
buffer.clear();
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
@ -271,7 +285,7 @@ void XHR::onReplyError(QNetworkReply::NetworkError code)
|
|||
void XHR::onReplySuccess()
|
||||
{
|
||||
qDebug() << "!";
|
||||
emit this->success( bufferToString() );
|
||||
emit this->success( bufferToString(), m_api);
|
||||
buffer.clear();
|
||||
// reply->deleteLater();
|
||||
}
|
||||
|
@ -279,7 +293,7 @@ void XHR::onReplySuccess()
|
|||
void XHR::onRequestFinished()
|
||||
{
|
||||
// Save the file here
|
||||
if (buffer.isNull()){qDebug() << "File empty"<<m_url; buffer.clear(); emit this->error(m_downloadtype,m_url,1);}
|
||||
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") {
|
||||
QJsonDocument jsonResponse = QJsonDocument::fromJson(buffer);
|
||||
QJsonObject jsonObject = jsonResponse.object();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue