1
0
Fork 0
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:
niansa 2020-08-16 14:54:54 +02:00
parent 79af814a2b
commit aadc303cea
3 changed files with 17 additions and 8 deletions

View file

@ -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) {
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
curlpp::Cleanup cleaner;
curlpp::Easy request;
@ -349,7 +353,7 @@ public:
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
server_url = _server_url;
server_sid = _server_sid;
@ -360,6 +364,11 @@ public:
long statuscode;
numposts = 0;
// Make sure the server_url doesn't end with /
if (*(server_url.end() - 1) == '/') {
server_url.pop_back();
}
while (1) {
// Check connection and download feed
try {
@ -372,6 +381,7 @@ public:
} else if (statuscode == 500) {
throw invalidRoomError();
} else if (statuscode != 200) {
std::cout << "Unhandled status code " << statuscode << std::endl;
throw connectionFailError();
}

View file

@ -65,6 +65,7 @@ public:
// Create request
mNetReq->setUrl(authUrl + "&mod=context&fct=login");
mNetReq->setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
mNetReq->setAttribute(QNetworkRequest::FollowRedirectsAttribute, false);
// Perform the request
std::cout << mNetReq->url().toString().toStdString() << std::endl;

View file

@ -28,14 +28,10 @@ QSettings *settings;
class _UILoader {
libCommsy *connector = nullptr;
libCommsyAuth *auther;
libCommsyAuth *auther = nullptr;
bool cacheInvalidate = true;
public:
_UILoader() {
auther = new libCommsyAuth();
}
void reconnect() {
// Destroy old connector
if (connector != nullptr) {
@ -47,7 +43,6 @@ public:
}
cacheInvalidate = false;
// 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());
}
@ -116,6 +111,9 @@ void _UILoader::offlineWindow(QMainWindow *w) {
void _UILoader::loginWindow(QMainWindow *w, const QString& failure) {
Ui::loginWindow *thisui = new Ui::loginWindow;
// Create new auther
auther = new libCommsyAuth();
// Check if logged in already
if (settings->contains("server_sid")) {
return overviewWindow(w);
@ -140,6 +138,7 @@ void _UILoader::loginWindow(QMainWindow *w, const QString& failure) {
// Login
try {
settings->setValue("server_sid", auther->getSID(netReply));
auther->deleteLater();
cacheInvalidate = true;
overviewWindow(w, false);
} catch (authFailureError&) {
@ -231,7 +230,6 @@ int main(int argc, char *argv[]) {
_UILoader UILoader;
// Set theme
settings->clear();
a.setStyle(QStyleFactory::create("windows"));
// Load initial window