|
@@ -0,0 +1,73 @@
|
|
|
+#include <QGuiApplication>
|
|
|
+#include <QObject>
|
|
|
+#include <QQmlApplicationEngine>
|
|
|
+#include <csignal>
|
|
|
+#include <cstdio>
|
|
|
+#include <cstdlib>
|
|
|
+#include <cstring>
|
|
|
+#include <iostream>
|
|
|
+#include <sys/prctl.h>
|
|
|
+#include <sys/wait.h>
|
|
|
+#include <unistd.h>
|
|
|
+
|
|
|
+#include "qmlhandler.h"
|
|
|
+
|
|
|
+using namespace std;
|
|
|
+int inpipefd[2];
|
|
|
+int outpipefd[2];
|
|
|
+char buf[1024];
|
|
|
+
|
|
|
+int main(int argc, char *argv[]) {
|
|
|
+ pid_t pid = 0;
|
|
|
+ char msg[256];
|
|
|
+ int status;
|
|
|
+
|
|
|
+ pipe(inpipefd);
|
|
|
+ pipe(outpipefd);
|
|
|
+ pid = fork();
|
|
|
+ if (pid == 0) {
|
|
|
+
|
|
|
+ dup2(outpipefd[0], STDIN_FILENO);
|
|
|
+ dup2(inpipefd[1], STDOUT_FILENO);
|
|
|
+ dup2(inpipefd[1], STDERR_FILENO);
|
|
|
+
|
|
|
+
|
|
|
+ prctl(PR_SET_PDEATHSIG, SIGTERM);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ execl("../../cli/build/ccats-cli", "ccats-cli", "c", "127.0.0.1",
|
|
|
+ (char *)NULL);
|
|
|
+
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ close(outpipefd[0]);
|
|
|
+ close(inpipefd[1]);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
+
|
|
|
+ QGuiApplication app(argc, argv);
|
|
|
+
|
|
|
+ QQmlApplicationEngine engine;
|
|
|
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
|
|
+
|
|
|
+ if (engine.rootObjects().isEmpty())
|
|
|
+ return -1;
|
|
|
+
|
|
|
+ QMLHandler qmlHandler;
|
|
|
+
|
|
|
+ QObject *statusButton =
|
|
|
+ engine.rootObjects().first()->findChild<QObject *>("getstatusbutton");
|
|
|
+
|
|
|
+ QObject::connect(statusButton, SIGNAL(clicked()), &qmlHandler,
|
|
|
+ SLOT(onGetStatusClick()));
|
|
|
+
|
|
|
+ QObject::connect(&qmlHandler, SIGNAL(setStatusMessage(QVariant)),
|
|
|
+ engine.rootObjects().first(),
|
|
|
+ SLOT(setStatusMessage(QVariant)));
|
|
|
+
|
|
|
+ return app.exec();
|
|
|
+}
|