|
@@ -20,7 +20,7 @@ using namespace std;
|
|
|
|
|
|
int inpipefd[2];
|
|
|
int outpipefd[2];
|
|
|
-char buf[1024];
|
|
|
+char buf[1025];
|
|
|
QUrl sendFileUrl = QUrl("");
|
|
|
|
|
|
bool programActive = true;
|
|
@@ -53,6 +53,17 @@ void QMLHandler::handleJSON(string buffer) {
|
|
|
else if (cmd == "close") {
|
|
|
programActive = false;
|
|
|
}
|
|
|
+
|
|
|
+ else if (cmd == "list") {
|
|
|
+ emit receivingClearFileList();
|
|
|
+
|
|
|
+ // Get the array of file Names
|
|
|
+ auto fileNames = root["names"];
|
|
|
+ for (int i = 0; i < fileNames.size(); i++) {
|
|
|
+ emit receivingListFile(
|
|
|
+ QString::fromStdString(fileNames[i].asString().c_str()));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void QMLHandler::readPipeLoop() {
|
|
@@ -75,7 +86,7 @@ void QMLHandler::readPipeLoop() {
|
|
|
}
|
|
|
|
|
|
if (pollCount > 9 && buf[0]) {
|
|
|
- buf[1023] = 0;
|
|
|
+ buf[1024] = 0;
|
|
|
buf[strlen(buf)] = 0;
|
|
|
|
|
|
string cleanBuffer = buf + strcspn(buf, "\n") + 1;
|
|
@@ -115,6 +126,10 @@ void QMLHandler::onSendingClearSelectionButton() {
|
|
|
}
|
|
|
|
|
|
// Receiving
|
|
|
+void QMLHandler::onReceivingListFilesButton() {
|
|
|
+ write(outpipefd[1], "list\n", strlen("list\n"));
|
|
|
+}
|
|
|
+
|
|
|
void QMLHandler::onReceivingGetFileButton(QString fileName) {
|
|
|
QString command = "get " + fileName + "\n";
|
|
|
write(outpipefd[1], command.toUtf8().constData(),
|