mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Working telemetry class
This commit is contained in:
parent
8f1003f6bb
commit
7143c85201
6 changed files with 23 additions and 53 deletions
|
@ -28,6 +28,7 @@ SOURCES += \
|
||||||
src/audio/audiothread.cpp \
|
src/audio/audiothread.cpp \
|
||||||
src/splash/alert.cpp \
|
src/splash/alert.cpp \
|
||||||
src/apps/apps.cpp \
|
src/apps/apps.cpp \
|
||||||
|
src/telemetry/telemetry.cpp \
|
||||||
src/widgets/dialogs/audio/audiodialog.cpp \
|
src/widgets/dialogs/audio/audiodialog.cpp \
|
||||||
src/widgets/dialogs/audio/audiofile.cpp \
|
src/widgets/dialogs/audio/audiofile.cpp \
|
||||||
src/widgets/dialogs/audio/audiofilequeue.cpp \
|
src/widgets/dialogs/audio/audiofilequeue.cpp \
|
||||||
|
@ -77,6 +78,7 @@ HEADERS += \
|
||||||
src/apps/todo.h \
|
src/apps/todo.h \
|
||||||
src/splash/alert.h \
|
src/splash/alert.h \
|
||||||
src/apps/apps.h \
|
src/apps/apps.h \
|
||||||
|
src/telemetry/telemetry.h \
|
||||||
src/widgets/dialogs/audio/audiodialog.h \
|
src/widgets/dialogs/audio/audiodialog.h \
|
||||||
src/widgets/dialogs/audio/audiofile.h \
|
src/widgets/dialogs/audio/audiofile.h \
|
||||||
src/widgets/dialogs/audio/audiofilequeue.h \
|
src/widgets/dialogs/audio/audiofilequeue.h \
|
||||||
|
|
|
@ -233,14 +233,6 @@ namespace global {
|
||||||
namespace telemetry {
|
namespace telemetry {
|
||||||
inline bool enabled = false;
|
inline bool enabled = false;
|
||||||
inline bool telemetryDialog = false;
|
inline bool telemetryDialog = false;
|
||||||
namespace collectedData {
|
|
||||||
inline QString message;
|
|
||||||
inline QString deviceUID;
|
|
||||||
inline QString systemVersion;
|
|
||||||
inline QString device;
|
|
||||||
inline bool deviceRooted;
|
|
||||||
inline bool developerKeyInstalled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
inline QString systemInfoText;
|
inline QString systemInfoText;
|
||||||
inline bool forbidOpenSearchDialog;
|
inline bool forbidOpenSearchDialog;
|
||||||
|
@ -1179,22 +1171,27 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int testPing() {
|
int testPing(QString ipAddress = "1.1.1.1") {
|
||||||
// For some reason, implementing a non-blocking version of this functions triggers a "terminate called without an active exception" error with a platform plugin compiled with a newer GCC 11 toolchain. The problem has been solved by transplanting this function into the related area which uses it.
|
// For some reason, implementing a non-blocking version of this functions triggers a "terminate called without an active exception" error with a platform plugin compiled with a newer GCC 11 toolchain. The problem has been solved by transplanting this function into the related area which uses it.
|
||||||
|
QString function = __func__; log(function + ": pinging IP address " + ipAddress, "functions");
|
||||||
QProcess *pingProcess = new QProcess();
|
QProcess *pingProcess = new QProcess();
|
||||||
QString pingProg = "ping";
|
QString pingProg = "ping";
|
||||||
QStringList pingArgs;
|
QStringList pingArgs;
|
||||||
pingArgs << "-c" << "1" << "1.1.1.1";
|
pingArgs << "-c" << "1" << ipAddress;
|
||||||
pingProcess->start(pingProg, pingArgs);
|
pingProcess->start(pingProg, pingArgs);
|
||||||
pingProcess->waitForFinished();
|
pingProcess->waitForFinished();
|
||||||
int exitCode = pingProcess->exitCode();
|
int exitCode = pingProcess->exitCode();
|
||||||
pingProcess->deleteLater();
|
pingProcess->deleteLater();
|
||||||
if(exitCode == 0) {
|
if(exitCode == 0) {
|
||||||
|
log("Ping successful", "functions");
|
||||||
global::wifi::isConnected = true;
|
global::wifi::isConnected = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
log("Ping unsuccessful", "functions");
|
||||||
|
if(ipAddress == "1.1.1.1") {
|
||||||
global::wifi::isConnected = false;
|
global::wifi::isConnected = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
bool checkProcessName(QString name) {
|
bool checkProcessName(QString name) {
|
||||||
|
@ -1232,36 +1229,6 @@ namespace {
|
||||||
fhandler << str.toStdString();
|
fhandler << str.toStdString();
|
||||||
fhandler.close();
|
fhandler.close();
|
||||||
}
|
}
|
||||||
QJsonObject collectDeviceInformation() {
|
|
||||||
global::telemetry::collectedData::deviceUID = getUID();
|
|
||||||
global::telemetry::collectedData::systemVersion = readFile("/opt/version").trimmed();
|
|
||||||
global::telemetry::collectedData::device = global::deviceID.trimmed();
|
|
||||||
if(checkconfig("/external_root/opt/root/rooted")) {
|
|
||||||
global::telemetry::collectedData::deviceRooted = "true";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
global::telemetry::collectedData::deviceRooted = "false";
|
|
||||||
}
|
|
||||||
if(checkconfig("/external_root/opt/developer/valid-key")) {
|
|
||||||
global::telemetry::collectedData::developerKeyInstalled = "true";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
global::telemetry::collectedData::developerKeyInstalled = "false";
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonObject data;
|
|
||||||
data.insert("UID", global::telemetry::collectedData::deviceUID);
|
|
||||||
data.insert("SystemVersion", global::telemetry::collectedData::systemVersion);
|
|
||||||
data.insert("DeviceModel", global::telemetry::collectedData::device);
|
|
||||||
data.insert("DeviceRooted", global::telemetry::collectedData::deviceRooted);
|
|
||||||
data.insert("DeveloperKeyInstalled", global::telemetry::collectedData::developerKeyInstalled);
|
|
||||||
data.insert("Message", global::telemetry::collectedData::message);
|
|
||||||
|
|
||||||
return(data);
|
|
||||||
}
|
|
||||||
bool sendDeviceInformation(QJsonObject data) {
|
|
||||||
qDebug() << data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FUNCTIONS_H
|
#endif // FUNCTIONS_H
|
||||||
|
|
|
@ -436,7 +436,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
||||||
// Telemetry
|
// Telemetry
|
||||||
if(checkconfig(".config/24-telemetry/enabled") == false && checkconfig(".config/24-telemetry/asked") == false) {
|
if(checkconfig(".config/24-telemetry/enabled") == false && checkconfig(".config/24-telemetry/asked") == false) {
|
||||||
if(testPing() == 0) {
|
if(testPing("23.163.0.39") == 0) {
|
||||||
QTimer::singleShot(1000, this, SLOT(openTelemetryDialog()));
|
QTimer::singleShot(1000, this, SLOT(openTelemetryDialog()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1110,16 +1110,14 @@ void MainWindow::openTelemetryMessageDialog() {
|
||||||
global::keyboard::keyboardDialog = true;
|
global::keyboard::keyboardDialog = true;
|
||||||
global::keyboard::keyboardText = "";
|
global::keyboard::keyboardText = "";
|
||||||
generalDialogWindow = new generalDialog(this);
|
generalDialogWindow = new generalDialog(this);
|
||||||
QObject::connect(generalDialogWindow, &generalDialog::destroyed, this, &MainWindow::sendDeviceInformationSlot);
|
QObject::connect(generalDialogWindow, &generalDialog::telemetryMessage, this, &MainWindow::sendDeviceInformationSlot);
|
||||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::sendDeviceInformationSlot() {
|
void MainWindow::sendDeviceInformationSlot(QString message) {
|
||||||
QJsonObject data = collectDeviceInformation();
|
telemetryInstance = new telemetry(this);
|
||||||
qDebug() << data;
|
QObject::connect(telemetryInstance, &telemetry::showToast, this, &MainWindow::showToast);
|
||||||
sendDeviceInformation(data);
|
telemetryInstance->message = message;
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/24-telemetry/asked", "true");
|
|
||||||
writeFile("/mnt/onboard/.adds/inkbox/.config/24-telemetry/enabled", "true");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "librarywidget.h"
|
#include "librarywidget.h"
|
||||||
#include "locallibrarywidget.h"
|
#include "locallibrarywidget.h"
|
||||||
#include "homepagewidget.h"
|
#include "homepagewidget.h"
|
||||||
|
#include "telemetry.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ private slots:
|
||||||
void on_audioBtn_clicked();
|
void on_audioBtn_clicked();
|
||||||
void openTelemetryDialog();
|
void openTelemetryDialog();
|
||||||
void openTelemetryMessageDialog();
|
void openTelemetryMessageDialog();
|
||||||
void sendDeviceInformationSlot();
|
void sendDeviceInformationSlot(QString message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow * ui;
|
Ui::MainWindow * ui;
|
||||||
|
@ -126,6 +127,7 @@ private:
|
||||||
libraryWidget * libraryWidgetWindow;
|
libraryWidget * libraryWidgetWindow;
|
||||||
localLibraryWidget * localLibraryWidgetWindow;
|
localLibraryWidget * localLibraryWidgetWindow;
|
||||||
homePageWidget * homePageWidgetWindow;
|
homePageWidget * homePageWidgetWindow;
|
||||||
|
telemetry * telemetryInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -311,8 +311,8 @@ void generalDialog::on_cancelBtn_clicked()
|
||||||
}
|
}
|
||||||
else if(global::keyboard::telemetryMessageDialog == true) {
|
else if(global::keyboard::telemetryMessageDialog == true) {
|
||||||
global::keyboard::telemetryMessageDialog = false;
|
global::keyboard::telemetryMessageDialog = false;
|
||||||
|
emit telemetryMessage(global::keyboard::keyboardText);
|
||||||
global::keyboard::keyboardText = "";
|
global::keyboard::keyboardText = "";
|
||||||
global::telemetry::collectedData::message = "";
|
|
||||||
log("No message to be sent along with collected data", className);
|
log("No message to be sent along with collected data", className);
|
||||||
}
|
}
|
||||||
generalDialog::close();
|
generalDialog::close();
|
||||||
|
@ -558,11 +558,11 @@ void generalDialog::on_okBtn_clicked()
|
||||||
}
|
}
|
||||||
else if(global::keyboard::telemetryMessageDialog == true) {
|
else if(global::keyboard::telemetryMessageDialog == true) {
|
||||||
if(!global::keyboard::keyboardText.isEmpty()) {
|
if(!global::keyboard::keyboardText.isEmpty()) {
|
||||||
global::telemetry::collectedData::message = global::keyboard::keyboardText;
|
emit telemetryMessage(global::keyboard::keyboardText);
|
||||||
|
log("Message to be sent along with collected data is: " + global::keyboard::keyboardText, className);
|
||||||
global::keyboard::keyboardText = "";
|
global::keyboard::keyboardText = "";
|
||||||
global::keyboard::telemetryMessageDialog = false;
|
global::keyboard::telemetryMessageDialog = false;
|
||||||
global::keyboard::keyboardDialog = false;
|
global::keyboard::keyboardDialog = false;
|
||||||
log("Message to be sent along with collected data is: " + global::telemetry::collectedData::message, className);
|
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -94,6 +94,7 @@ signals:
|
||||||
void disableStorageEncryption();
|
void disableStorageEncryption();
|
||||||
void syncOnlineLibrary();
|
void syncOnlineLibrary();
|
||||||
void noSyncOnlineLibrary();
|
void noSyncOnlineLibrary();
|
||||||
|
void telemetryMessage(QString message);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GENERALDIALOG_H
|
#endif // GENERALDIALOG_H
|
||||||
|
|
Loading…
Reference in a new issue