mirror of
https://gitlab.com/niansa/qcommsy.git
synced 2025-03-06 20:53:33 +01:00
Fixed all current bugs (I suppose)
This commit is contained in:
parent
79af814a2b
commit
aadc303cea
3 changed files with 17 additions and 8 deletions
|
@ -67,6 +67,10 @@ std::vector<std::string> merge_strvects(std::vector<std::string> base, const std
|
||||||
}
|
}
|
||||||
|
|
||||||
static long curlreq(std::stringstream &responsebuffer, std::string SID, std::string URL) {
|
static long curlreq(std::stringstream &responsebuffer, std::string SID, std::string URL) {
|
||||||
|
std::cout << "Connection details begin" << std::endl;
|
||||||
|
std::cout << "URL: " << URL << std::endl;
|
||||||
|
std::cout << "SID: " << SID << std::endl;
|
||||||
|
std::cout << "Connection details end" << std::endl;
|
||||||
// Initialise variables
|
// Initialise variables
|
||||||
curlpp::Cleanup cleaner;
|
curlpp::Cleanup cleaner;
|
||||||
curlpp::Easy request;
|
curlpp::Easy request;
|
||||||
|
@ -349,7 +353,7 @@ public:
|
||||||
return &thispost->description;
|
return &thispost->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
libCommsy(std::string _server_url, std::string _server_sid, std::string _room) {
|
libCommsy(const std::string& _server_url, const std::string& _server_sid, const std::string& _room) {
|
||||||
// Define required variables
|
// Define required variables
|
||||||
server_url = _server_url;
|
server_url = _server_url;
|
||||||
server_sid = _server_sid;
|
server_sid = _server_sid;
|
||||||
|
@ -360,6 +364,11 @@ public:
|
||||||
long statuscode;
|
long statuscode;
|
||||||
numposts = 0;
|
numposts = 0;
|
||||||
|
|
||||||
|
// Make sure the server_url doesn't end with /
|
||||||
|
if (*(server_url.end() - 1) == '/') {
|
||||||
|
server_url.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
// Check connection and download feed
|
// Check connection and download feed
|
||||||
try {
|
try {
|
||||||
|
@ -372,6 +381,7 @@ public:
|
||||||
} else if (statuscode == 500) {
|
} else if (statuscode == 500) {
|
||||||
throw invalidRoomError();
|
throw invalidRoomError();
|
||||||
} else if (statuscode != 200) {
|
} else if (statuscode != 200) {
|
||||||
|
std::cout << "Unhandled status code " << statuscode << std::endl;
|
||||||
throw connectionFailError();
|
throw connectionFailError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ public:
|
||||||
// Create request
|
// Create request
|
||||||
mNetReq->setUrl(authUrl + "&mod=context&fct=login");
|
mNetReq->setUrl(authUrl + "&mod=context&fct=login");
|
||||||
mNetReq->setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
mNetReq->setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
|
mNetReq->setAttribute(QNetworkRequest::FollowRedirectsAttribute, false);
|
||||||
|
|
||||||
// Perform the request
|
// Perform the request
|
||||||
std::cout << mNetReq->url().toString().toStdString() << std::endl;
|
std::cout << mNetReq->url().toString().toStdString() << std::endl;
|
||||||
|
|
12
main.cpp
12
main.cpp
|
@ -28,14 +28,10 @@ QSettings *settings;
|
||||||
|
|
||||||
class _UILoader {
|
class _UILoader {
|
||||||
libCommsy *connector = nullptr;
|
libCommsy *connector = nullptr;
|
||||||
libCommsyAuth *auther;
|
libCommsyAuth *auther = nullptr;
|
||||||
bool cacheInvalidate = true;
|
bool cacheInvalidate = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_UILoader() {
|
|
||||||
auther = new libCommsyAuth();
|
|
||||||
}
|
|
||||||
|
|
||||||
void reconnect() {
|
void reconnect() {
|
||||||
// Destroy old connector
|
// Destroy old connector
|
||||||
if (connector != nullptr) {
|
if (connector != nullptr) {
|
||||||
|
@ -47,7 +43,6 @@ public:
|
||||||
}
|
}
|
||||||
cacheInvalidate = false;
|
cacheInvalidate = false;
|
||||||
// Connect to commsy
|
// Connect to commsy
|
||||||
std::cout << "Connecting using: " << settings->value("server_url").toString().toStdString() << "..." << std::endl;
|
|
||||||
connector = new libCommsy(settings->value("server_url").toString().toStdString(), settings->value("server_sid").toString().toStdString(), settings->value("server_room").toString().toStdString());
|
connector = new libCommsy(settings->value("server_url").toString().toStdString(), settings->value("server_sid").toString().toStdString(), settings->value("server_room").toString().toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +111,9 @@ void _UILoader::offlineWindow(QMainWindow *w) {
|
||||||
void _UILoader::loginWindow(QMainWindow *w, const QString& failure) {
|
void _UILoader::loginWindow(QMainWindow *w, const QString& failure) {
|
||||||
Ui::loginWindow *thisui = new Ui::loginWindow;
|
Ui::loginWindow *thisui = new Ui::loginWindow;
|
||||||
|
|
||||||
|
// Create new auther
|
||||||
|
auther = new libCommsyAuth();
|
||||||
|
|
||||||
// Check if logged in already
|
// Check if logged in already
|
||||||
if (settings->contains("server_sid")) {
|
if (settings->contains("server_sid")) {
|
||||||
return overviewWindow(w);
|
return overviewWindow(w);
|
||||||
|
@ -140,6 +138,7 @@ void _UILoader::loginWindow(QMainWindow *w, const QString& failure) {
|
||||||
// Login
|
// Login
|
||||||
try {
|
try {
|
||||||
settings->setValue("server_sid", auther->getSID(netReply));
|
settings->setValue("server_sid", auther->getSID(netReply));
|
||||||
|
auther->deleteLater();
|
||||||
cacheInvalidate = true;
|
cacheInvalidate = true;
|
||||||
overviewWindow(w, false);
|
overviewWindow(w, false);
|
||||||
} catch (authFailureError&) {
|
} catch (authFailureError&) {
|
||||||
|
@ -231,7 +230,6 @@ int main(int argc, char *argv[]) {
|
||||||
_UILoader UILoader;
|
_UILoader UILoader;
|
||||||
|
|
||||||
// Set theme
|
// Set theme
|
||||||
settings->clear();
|
|
||||||
a.setStyle(QStyleFactory::create("windows"));
|
a.setStyle(QStyleFactory::create("windows"));
|
||||||
|
|
||||||
// Load initial window
|
// Load initial window
|
||||||
|
|
Loading…
Add table
Reference in a new issue