mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
use existing constants for HTTP operations
This commit is contained in:
parent
d3dd49a2e8
commit
cb165902fd
4 changed files with 7 additions and 16 deletions
|
@ -92,7 +92,7 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
|||
void DomainServer::requestUUIDFromDataServer() {
|
||||
// this slot is fired when we get a valid access token from the data-server
|
||||
// now let's ask it to set us up with a UUID
|
||||
AccountManager::getInstance().authenticatedRequest("/api/v1/domains/create", AuthenticatedRequestMethod::POST,
|
||||
AccountManager::getInstance().authenticatedRequest("/api/v1/domains/create", QNetworkAccessManager::PostOperation,
|
||||
this, SLOT(parseUUIDFromDataServer()));
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ AccountManager::AccountManager() :
|
|||
}
|
||||
}
|
||||
|
||||
void AccountManager::authenticatedRequest(const QString& path, AuthenticatedRequestMethod::Method method,
|
||||
void AccountManager::authenticatedRequest(const QString& path, QNetworkAccessManager::Operation operation,
|
||||
const QObject *successReceiver, const char *successMethod,
|
||||
const QByteArray& dataByteArray,
|
||||
const QObject* errorReceiver, const char* errorMethod) {
|
||||
|
@ -69,11 +69,11 @@ void AccountManager::authenticatedRequest(const QString& path, AuthenticatedRequ
|
|||
|
||||
QNetworkReply* networkReply = NULL;
|
||||
|
||||
switch (method) {
|
||||
case AuthenticatedRequestMethod::GET:
|
||||
switch (operation) {
|
||||
case QNetworkAccessManager::GetOperation:
|
||||
networkReply = _networkAccessManager->get(authenticatedRequest);
|
||||
break;
|
||||
case AuthenticatedRequestMethod::POST:
|
||||
case QNetworkAccessManager::PostOperation:
|
||||
authenticatedRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
networkReply = _networkAccessManager->post(authenticatedRequest, dataByteArray);
|
||||
default:
|
||||
|
|
|
@ -17,15 +17,6 @@
|
|||
|
||||
#include "OAuthAccessToken.h"
|
||||
|
||||
namespace AuthenticatedRequestMethod {
|
||||
enum Method {
|
||||
GET,
|
||||
POST,
|
||||
PUT,
|
||||
DELETE
|
||||
};
|
||||
}
|
||||
|
||||
class AccountManager : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -33,7 +24,7 @@ public:
|
|||
static AccountManager& getInstance();
|
||||
|
||||
void authenticatedRequest(const QString& path,
|
||||
AuthenticatedRequestMethod::Method method,
|
||||
QNetworkAccessManager::Operation operation,
|
||||
const QObject* successReceiver, const char* successMethod,
|
||||
const QByteArray& dataByteArray = QByteArray(),
|
||||
const QObject* errorReceiver = 0, const char* errorMethod = NULL);
|
||||
|
|
|
@ -588,7 +588,7 @@ void NodeList::domainServerAuthReply() {
|
|||
void NodeList::requestAuthForDomainServer() {
|
||||
AccountManager::getInstance().authenticatedRequest("/api/v1/domains/"
|
||||
+ uuidStringWithoutCurlyBraces(_domainInfo.getUUID()) + "/auth.json",
|
||||
AuthenticatedRequestMethod::GET,
|
||||
QNetworkAccessManager::GetOperation,
|
||||
this, SLOT(domainServerAuthReply()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue