mirror of
https://gitlab.com/niansa/qcommsy.git
synced 2025-03-06 20:53:33 +01:00
Fixed one more bug
This commit is contained in:
parent
9d4da7673e
commit
1845bc9fdf
3 changed files with 23 additions and 12 deletions
|
@ -321,11 +321,12 @@ struct commsyPost {
|
|||
|
||||
|
||||
#define libCommsy_NAME "libcommsy"
|
||||
#define libCommsy_VERSION "1.0-stable"
|
||||
#define libCommsy_VERSION "1.1-stable"
|
||||
class libCommsy {
|
||||
public:
|
||||
std::vector<commsyPost> posts;
|
||||
unsigned long numposts;
|
||||
std::string lastID;
|
||||
|
||||
bool postExists(unsigned long postID) {
|
||||
return postID < numposts;
|
||||
|
@ -353,22 +354,18 @@ public:
|
|||
return &thispost->description;
|
||||
}
|
||||
|
||||
libCommsy(const std::string& _server_url, const std::string& _server_sid, const std::string& _room) {
|
||||
libCommsy(const std::string& _server_url, const std::string& _server_sid, const std::string& _room, const std::string start_id = "", const unsigned long max_posts = 0) {
|
||||
// Define required variables
|
||||
server_url = _server_url;
|
||||
server_sid = _server_sid;
|
||||
room = _room;
|
||||
std::string lastID;
|
||||
lastID = start_id;
|
||||
std::stringstream httpcontent;
|
||||
GumboOutput *document;
|
||||
long statuscode;
|
||||
numposts = 0;
|
||||
|
||||
// Make sure the server_url doesn't end with /
|
||||
if (*(server_url.end() - 1) == '/') {
|
||||
server_url.pop_back();
|
||||
}
|
||||
|
||||
// Loop until all or max_posts posts are fetched
|
||||
while (1) {
|
||||
// Check connection and download feed
|
||||
try {
|
||||
|
@ -422,6 +419,11 @@ public:
|
|||
numposts++;
|
||||
// Get lastID
|
||||
lastID = posts.back().id;
|
||||
// Check if maximum amount of posts to load was exceeded
|
||||
if (numposts == max_posts) {
|
||||
// Stop loading more posts
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <QNetworkCookie>
|
||||
|
||||
#define libCommsyAuth_NAME "libcommsyauth"
|
||||
#define libCommsyAuth_VERSION "0.1-alpha"
|
||||
#define libCommsyAuth_VERSION "0.2-alpha"
|
||||
|
||||
class authFailureError : public std::exception {};
|
||||
|
||||
|
@ -21,6 +21,7 @@ class libCommsyAuth : public QObject {
|
|||
public:
|
||||
Q_SIGNALS:
|
||||
void connectionDone(QNetworkReply *r);
|
||||
void connectionNotfound(QNetworkReply *r);
|
||||
void authDone(QNetworkReply *r);
|
||||
|
||||
public:
|
||||
|
@ -33,6 +34,7 @@ public:
|
|||
mNetManAuth = new QNetworkAccessManager(this);
|
||||
mNetReq = new QNetworkRequest();
|
||||
connect(mNetManTestconn, &QNetworkAccessManager::finished, this, &libCommsyAuth::connectionDone);
|
||||
//connect(mNetManTestconn, &QNetworkReply::HostNotFoundError, this, &libCommsyAuth::connectionNotfound);
|
||||
connect(mNetManAuth, &QNetworkAccessManager::finished, this, &libCommsyAuth::authDone);
|
||||
}
|
||||
|
||||
|
|
13
main.cpp
13
main.cpp
|
@ -21,7 +21,7 @@
|
|||
#include <QSettings>
|
||||
|
||||
#define QCommsy_NAME "QCommsy"
|
||||
#define QCommsy_VERSION "0.1-alpha"
|
||||
#define QCommsy_VERSION "0.2-alpha"
|
||||
|
||||
QSettings *settings;
|
||||
|
||||
|
@ -148,8 +148,10 @@ void _UILoader::loginWindow(QMainWindow *w, const QString& failure) {
|
|||
}
|
||||
});
|
||||
w->connect(auther, &libCommsyAuth::connectionDone, [this, thisui, w] (QNetworkReply *netReply) {
|
||||
QString authUrl = auther->getAuthUrl(netReply);
|
||||
auther->sendAuth(authUrl, thisui->usernameLine->text(), thisui->passwordLine->text());
|
||||
auther->sendAuth(auther->getAuthUrl(netReply), thisui->usernameLine->text(), thisui->passwordLine->text());
|
||||
});
|
||||
w->connect(auther, &libCommsyAuth::connectionNotfound, [this, thisui, w] (QNetworkReply *) {
|
||||
thisui->failureText->setText("Der angegebene Server existiert nicht");
|
||||
});
|
||||
|
||||
|
||||
|
@ -160,6 +162,11 @@ void _UILoader::loginWindow(QMainWindow *w, const QString& failure) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Make sure the adressLine doesn't end with /
|
||||
if (thisui->adressLine->text().endsWith("/")) {
|
||||
thisui->adressLine->backspace();
|
||||
}
|
||||
|
||||
// Save basic server credentials
|
||||
settings->setValue("server_save", thisui->saveBox->checkState() == Qt::Checked);
|
||||
settings->setValue("server_url", thisui->adressLine->text());
|
||||
|
|
Loading…
Add table
Reference in a new issue