Huggle  build:^490^dce1e5c
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
webserverquery.cpp
1 //This program is free software: you can redistribute it and/or modify
2 //it under the terms of the GNU General Public License as published by
3 //the Free Software Foundation, either version 3 of the License, or
4 //(at your option) any later version.
5 
6 //This program is distributed in the hope that it will be useful,
7 //but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 //GNU General Public License for more details.
10 
11 #include "webserverquery.hpp"
12 
13 using namespace Huggle;
14 
15 WebserverQuery::WebserverQuery()
16 {
17  this->URL = "";
18  this->reply = NULL;
19  this->Parameters = "";
20  this->UsingPOST = false;
21 }
22 
24 {
25  if (this->URL == "")
26  {
27  this->Result = new QueryResult();
28  this->Result->Failed = true;
29  this->Result->ErrorMessage = "You provided invalid url";
30  this->Status = StatusInError;
31  return;
32  }
33  this->StartTime = QDateTime::currentDateTime();
34  this->Status = StatusProcessing;
35  this->Result = new QueryResult();
36 
37  QUrl url = QUrl::fromEncoded(this->URL.toUtf8());
38  QNetworkRequest request(url);
39  if (UsingPOST)
40  {
41  request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
42  }
43  if (UsingPOST)
44  {
45  //this->reply = Query::NetworkManager.post(request, url.encodedQuery());
46  this->reply = Query::NetworkManager.post(request, this->Parameters.toUtf8());
47  } else
48  {
49  this->reply = Query::NetworkManager.get(request);
50  }
51  QObject::connect(this->reply, SIGNAL(finished()), this, SLOT(Finished()));
52  QObject::connect(this->reply, SIGNAL(readyRead()), this, SLOT(ReadData()));
53  Core::DebugLog("Processing webserver request " + this->URL, 2);
54 }
55 
57 {
58 
59 }
60 
61 void WebserverQuery::ReadData()
62 {
63 
64 }
65 
66 void WebserverQuery::Finished()
67 {
68 
69 }
void Kill()
Terminate the query.
bool UsingPOST
Whether the query will submit parameters using POST data.
Result of query.
Definition: queryresult.hpp:19
static void DebugLog(QString Message, unsigned int Verbosity=1)
This log is only shown if verbosity is same or larger than requested verbosity.
Definition: core.cpp:641
QString ErrorMessage
If query is in error the reason for error is stored here.
Definition: queryresult.hpp:27
QString Parameters
Parameters for action, for example page title.
QueryResult * Result
Result of query, see documentation of QueryResult for more.
Definition: query.hpp:68