|
@@ -22,6 +22,8 @@ int inpipefd[2];
|
|
int outpipefd[2];
|
|
int outpipefd[2];
|
|
char buf[1025];
|
|
char buf[1025];
|
|
QUrl sendFileUrl = QUrl("");
|
|
QUrl sendFileUrl = QUrl("");
|
|
|
|
+QString _USERNAME;
|
|
|
|
+QString _PASSWORD;
|
|
|
|
|
|
bool programActive = true;
|
|
bool programActive = true;
|
|
|
|
|
|
@@ -64,6 +66,40 @@ void QMLHandler::handleJSON(string buffer) {
|
|
QString::fromStdString(fileNames[i].asString().c_str()));
|
|
QString::fromStdString(fileNames[i].asString().c_str()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ else if (cmd == "connect") {
|
|
|
|
+ if (root["accept"] == false) {
|
|
|
|
+ emit ipPopupSetStatus(root["error"].asString().c_str());
|
|
|
|
+ close(outpipefd[1]);
|
|
|
|
+ close(inpipefd[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ else if (cmd == "version") {
|
|
|
|
+ if (root["accept"] == true) {
|
|
|
|
+ write(outpipefd[1], _USERNAME.toUtf8().constData(),
|
|
|
|
+ strlen(_USERNAME.toUtf8().constData()));
|
|
|
|
+ write(outpipefd[1], _PASSWORD.toUtf8().constData(),
|
|
|
|
+ strlen(_PASSWORD.toUtf8().constData()));
|
|
|
|
+ } else {
|
|
|
|
+ QString errorMessage = QString::fromStdString(string(
|
|
|
|
+ "Version mismatch: \nClient: " + root["clientversion"].asString() +
|
|
|
|
+ "\nServer: " + root["serverversion"].asString()));
|
|
|
|
+ emit ipPopupSetStatus(errorMessage);
|
|
|
|
+ close(outpipefd[1]);
|
|
|
|
+ close(inpipefd[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ else if (cmd == "login") {
|
|
|
|
+ if (root["accept"] == true) {
|
|
|
|
+ emit ipPopupClose();
|
|
|
|
+ } else {
|
|
|
|
+ emit ipPopupSetStatus(root["error"].asString().c_str());
|
|
|
|
+ close(outpipefd[1]);
|
|
|
|
+ close(inpipefd[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void QMLHandler::readPipeLoop() {
|
|
void QMLHandler::readPipeLoop() {
|
|
@@ -145,7 +181,8 @@ void QMLHandler::onSettingsSwitchServerButton() {
|
|
}
|
|
}
|
|
|
|
|
|
// Ip Popup
|
|
// Ip Popup
|
|
-void QMLHandler::onIpPopupConnectButton(QString ip, QString username, QString password) {
|
|
|
|
|
|
+void QMLHandler::onIpPopupConnectButton(QString ip, QString username,
|
|
|
|
+ QString password) {
|
|
pid_t pid = 0;
|
|
pid_t pid = 0;
|
|
|
|
|
|
pipe(inpipefd);
|
|
pipe(inpipefd);
|
|
@@ -171,6 +208,9 @@ void QMLHandler::onIpPopupConnectButton(QString ip, QString username, QString pa
|
|
// TODO: Not hardcoded
|
|
// TODO: Not hardcoded
|
|
emit footerSetStatus("Connected to " + ip);
|
|
emit footerSetStatus("Connected to " + ip);
|
|
|
|
|
|
|
|
+ _USERNAME = username;
|
|
|
|
+ _PASSWORD = password;
|
|
|
|
+
|
|
close(outpipefd[0]);
|
|
close(outpipefd[0]);
|
|
close(inpipefd[1]);
|
|
close(inpipefd[1]);
|
|
|
|
|