diff --git a/apps.cpp b/apps.cpp
index 074f41e..a52b426 100644
--- a/apps.cpp
+++ b/apps.cpp
@@ -250,11 +250,21 @@ bool apps::parseJson() {
jsonCheckSuccess = false;
}
- if(!jsonMainObject["SupportedDevices"].isString()) {
+ if(!jsonMainObject["SupportedDevices"].isArray()) {
QString function = __func__; log(function + ": Invalid 'SupportedDevices' type inside object", className);
jsonCheckSuccess = false;
}
+ else {
+ QJsonArray jsonArray = jsonMainObject["SupportedDevices"].toArray();
+ for(QJsonValueRef refJsonObject: jsonArray) {
+ // https://doc.qt.io/qt-5/qjsonvalue.html#toInt
+ if(!refJsonObject.isString()) {
+ QString function = __func__; log(function + ": Array from 'RequiredFeatures' contains a wrong type", className);
+ jsonCheckSuccess = false;
+ }
+ }
+ }
if(!jsonMainObject["RequiredFeatures"].isArray()) {
QString function = __func__; log(function + ": Invalid 'RequiredFeatures' type inside object", className);
jsonCheckSuccess = false;
diff --git a/generaldialog.cpp b/generaldialog.cpp
index 6738a25..dc6a504 100644
--- a/generaldialog.cpp
+++ b/generaldialog.cpp
@@ -192,7 +192,7 @@ generalDialog::generalDialog(QWidget *parent) :
else if(global::userApps::appCompatibilityDialog == true) {
appCompatibilityDialog = true;
global::userApps::appCompatibilityLastContinueStatus = true;
- ui->okBtn->setText("Launch");
+ ui->okBtn->setText("Continue");
ui->cancelBtn->setText("Cancel");
ui->bodyLabel->setText(global::userApps::appCompatibilityText);
ui->headerLabel->setText("Compatibility warning");
diff --git a/main.cpp b/main.cpp
index 7802553..9402c7c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -60,6 +60,7 @@ int main(int argc, char *argv[])
while(true) {
if(QFile::exists("/tmp/gui_apps_started")) {
if(checkconfig("/tmp/gui_apps_started") == true) {
+ log("GUI apps service started successfully", "main");
QFile::remove("/tmp/gui_apps_started");
updateUserAppsMainJsonFile();
break;
diff --git a/userapps.cpp b/userapps.cpp
index db82e46..8fc2916 100644
--- a/userapps.cpp
+++ b/userapps.cpp
@@ -137,15 +137,13 @@ void userapps::updateJsonFileSlotUA(QJsonDocument jsonDocumentProvided)
void userapps::on_launchBtn_clicked()
{
// Some command to execute script or binary at "ExecPath"
- QString supportedDevices = jsonObject["SupportedDevices"].toString();
- QString message = "Supported devices for this app: ";
- message.append(supportedDevices);
- log(message, className);
+ QJsonArray supportedDevices = jsonObject["SupportedDevices"].toArray();
+ // This will work even if we are looking for 'n306' and there is a device named 'n306b' because QJsonArray::contains() works that way
if(supportedDevices.contains("all") == false and supportedDevices.contains(global::deviceID.trimmed()) == false) {
log("Warning: User app does not support this device", className);
global::userApps::appCompatibilityDialog = true;
- global::userApps::appCompatibilityText = "Your device is not compatible with this app.
Launch it anyway?";
+ global::userApps::appCompatibilityText = "Your device is not compatible with this app.
Continue anyway?";
generalDialogWindow = new generalDialog();
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
@@ -175,20 +173,30 @@ void userapps::on_launchBtn_clicked()
bool userapps::manageRequiredFeatures()
{
+ // This should be already set to 'true', but just in case
+ global::userApps::appCompatibilityLastContinueStatus = true;
QJsonArray jsonArray = jsonObject["RequiredFeatures"].toArray();
for(QJsonValueRef refJsonObject: jsonArray) {
bool launchDialog = false;
int featureId = refJsonObject.toInt();
// Wi-Fi connection required
if(featureId == 0) {
- global::userApps::appCompatibilityText = "This app needs Wi-Fi connection, launch anyway?";
- launchDialog = true;
+ // Double 'if' conditions to avoid launching unnecesery testPing() in emu
+ if(global::deviceID != "emu\n") {
+ if(testPing(true) != 0) {
+ global::userApps::appCompatibilityText = "This app needs a Wi-Fi connection, continue anyway?";
+ launchDialog = true;
+ }
+ }
}
// Rooted kernel required
if(featureId == 1) {
- global::userApps::appCompatibilityText = "This app needs a rooted kernel, launch anyway?";
- launchDialog = true;
+ if(checkconfig("/external_root/opt/root/rooted") == true) {
+ global::userApps::appCompatibilityText = "This app needs a rooted kernel, continue anyway?";
+ launchDialog = true;
+ }
}
+ // Pseudoterminal support (ID: 2) is managed by the 'gui_apps' service (https://github.com/Kobo-InkBox/rootfs/blob/master/etc/init.d/gui_apps)
if(launchDialog == true) {
global::userApps::appCompatibilityDialog = true;
@@ -224,19 +232,32 @@ QString userapps::parseJsonShow(QJsonObject json)
}
else if(value.isArray()) {
QJsonArray array = value.toArray();
- for(QJsonValueRef ref: array) {
- int id = ref.toInt();
- if(id == 0) {
- appendString.append("Wi-Fi connection");
+ if(key == "RequiredFeatures") {
+ for(QJsonValueRef ref: array) {
+ int id = ref.toInt();
+ if(id == 0) {
+ appendString.append("Wi-Fi connection");
+ }
+ else if(id == 1) {
+ appendString.append("Rooted kernel");
+ }
+ else if(id == 2) {
+ appendString.append("Pseudoterminal support");
+ }
+ appendString.append(", ");
}
- else if(id == 1) {
- appendString.append("Rooted kernel");
- }
- appendString.append(", ");
+ appendString.remove(appendString.size() - 2, 2);
+ }
+ else if(key == "SupportedDevices") {
+ for(QJsonValueRef ref: array) {
+ QString name = ref.toString();
+ appendString.append(name);
+ appendString.append(", ");
+ }
+ appendString.remove(appendString.size() - 2, 2);
}
- appendString.remove(appendString.size() - 2, 2);
- }
+ }
appendString.append("
");
mainString.append(appendString);
}