|
@@ -24,6 +24,7 @@ char buf[1025];
|
|
|
QUrl sendFileUrl = QUrl("");
|
|
|
QString _IP = "";
|
|
|
bool _CLI_RUNNING = false;
|
|
|
+bool _RESTART = false;
|
|
|
|
|
|
bool programActive = true;
|
|
|
|
|
@@ -197,6 +198,13 @@ void QMLHandler::handleJSON(string buffer) {
|
|
|
else if (!cmd.compare("getdata")) {
|
|
|
// TODO: Show speed and handle Error
|
|
|
}
|
|
|
+
|
|
|
+ else if (!cmd.compare("deleteme")) {
|
|
|
+ if (root["accept"] == true) {
|
|
|
+ _RESTART = true;
|
|
|
+ emit closeWindow();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// This method is a loop which runs in a seperate thread.
|
|
@@ -209,10 +217,11 @@ void QMLHandler::readPipeLoop() {
|
|
|
struct pollfd inPipeStatus;
|
|
|
inPipeStatus.fd = inpipefd[0];
|
|
|
inPipeStatus.events = POLLIN;
|
|
|
- std::vector<std::string> inputs;
|
|
|
+ vector<string> inputs;
|
|
|
+ string pipeInput;
|
|
|
|
|
|
while (programActive) {
|
|
|
- inputs = std::vector<std::string>();
|
|
|
+ inputs = vector<string>();
|
|
|
poll(&inPipeStatus, 1, 100);
|
|
|
|
|
|
if (inPipeStatus.revents & POLLIN) {
|
|
@@ -223,26 +232,23 @@ void QMLHandler::readPipeLoop() {
|
|
|
pollCount++;
|
|
|
}
|
|
|
|
|
|
- if (pollCount > 9 && buf[0]) {
|
|
|
- buf[1024] = 0;
|
|
|
- buf[strlen(buf)] = 0;
|
|
|
- inputs = tokenizeByNewlines(string(buf));
|
|
|
+ if (pollCount > 9 && (readOffset || pipeInput.size())) {
|
|
|
+ pipeInput.append(buf);
|
|
|
+ inputs = tokenizeByNewlines(pipeInput);
|
|
|
for (string s : inputs) {
|
|
|
- //~ string cleanBuffer = buf + strcspn(buf, "\n") + 1;
|
|
|
- //~ string receivedData = cleanBuffer.substr(0, cleanBuffer.size() - 1);
|
|
|
-
|
|
|
emit log(QString::fromStdString(s));
|
|
|
qInfo() << QString::fromStdString(s);
|
|
|
handleJSON(s);
|
|
|
}
|
|
|
- memset(buf, 0, 1024);
|
|
|
+ pipeInput = string();
|
|
|
+ memset(buf, 0, 1025);
|
|
|
pollCount = 0;
|
|
|
readOffset = 0;
|
|
|
}
|
|
|
|
|
|
// Fixme
|
|
|
if (readOffset >= 1024) {
|
|
|
- qInfo() << "Fixme: QMLHandler::readPipeLoop() readOffset too high!!!";
|
|
|
+ pipeInput.append(buf);
|
|
|
readOffset = 0;
|
|
|
pollCount = 0;
|
|
|
memset(buf, 0, 1025);
|
|
@@ -288,8 +294,8 @@ void QMLHandler::onReceivingGetFileButton(QString fileName) {
|
|
|
void QMLHandler::onMessagesSendButton(QString msg) { emit message(msg); }
|
|
|
|
|
|
// Settings
|
|
|
-void QMLHandler::onSettingsSwitchServerButton() {
|
|
|
- emit settingsOpenSwitchServerPopup();
|
|
|
+void QMLHandler::onSettingsDeleteMeButton() {
|
|
|
+ write(outpipefd[1], "deleteme\n", strlen("deleteme\n"));
|
|
|
}
|
|
|
|
|
|
// Ip Popup
|