mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 07:37:21 -08:00
GUI user applications: SupportedDevices
is now an array
Main credit to @Szybet for this commit.
This commit is contained in:
parent
9e5ac2102c
commit
525cfac383
4 changed files with 53 additions and 21 deletions
12
apps.cpp
12
apps.cpp
|
@ -250,11 +250,21 @@ bool apps::parseJson() {
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!jsonMainObject["SupportedDevices"].isString()) {
|
if(!jsonMainObject["SupportedDevices"].isArray()) {
|
||||||
QString function = __func__; log(function + ": Invalid 'SupportedDevices' type inside object", className);
|
QString function = __func__; log(function + ": Invalid 'SupportedDevices' type inside object", className);
|
||||||
jsonCheckSuccess = false;
|
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()) {
|
if(!jsonMainObject["RequiredFeatures"].isArray()) {
|
||||||
QString function = __func__; log(function + ": Invalid 'RequiredFeatures' type inside object", className);
|
QString function = __func__; log(function + ": Invalid 'RequiredFeatures' type inside object", className);
|
||||||
jsonCheckSuccess = false;
|
jsonCheckSuccess = false;
|
||||||
|
|
|
@ -192,7 +192,7 @@ generalDialog::generalDialog(QWidget *parent) :
|
||||||
else if(global::userApps::appCompatibilityDialog == true) {
|
else if(global::userApps::appCompatibilityDialog == true) {
|
||||||
appCompatibilityDialog = true;
|
appCompatibilityDialog = true;
|
||||||
global::userApps::appCompatibilityLastContinueStatus = true;
|
global::userApps::appCompatibilityLastContinueStatus = true;
|
||||||
ui->okBtn->setText("Launch");
|
ui->okBtn->setText("Continue");
|
||||||
ui->cancelBtn->setText("Cancel");
|
ui->cancelBtn->setText("Cancel");
|
||||||
ui->bodyLabel->setText(global::userApps::appCompatibilityText);
|
ui->bodyLabel->setText(global::userApps::appCompatibilityText);
|
||||||
ui->headerLabel->setText("Compatibility warning");
|
ui->headerLabel->setText("Compatibility warning");
|
||||||
|
|
1
main.cpp
1
main.cpp
|
@ -60,6 +60,7 @@ int main(int argc, char *argv[])
|
||||||
while(true) {
|
while(true) {
|
||||||
if(QFile::exists("/tmp/gui_apps_started")) {
|
if(QFile::exists("/tmp/gui_apps_started")) {
|
||||||
if(checkconfig("/tmp/gui_apps_started") == true) {
|
if(checkconfig("/tmp/gui_apps_started") == true) {
|
||||||
|
log("GUI apps service started successfully", "main");
|
||||||
QFile::remove("/tmp/gui_apps_started");
|
QFile::remove("/tmp/gui_apps_started");
|
||||||
updateUserAppsMainJsonFile();
|
updateUserAppsMainJsonFile();
|
||||||
break;
|
break;
|
||||||
|
|
59
userapps.cpp
59
userapps.cpp
|
@ -137,15 +137,13 @@ void userapps::updateJsonFileSlotUA(QJsonDocument jsonDocumentProvided)
|
||||||
void userapps::on_launchBtn_clicked()
|
void userapps::on_launchBtn_clicked()
|
||||||
{
|
{
|
||||||
// Some command to execute script or binary at "ExecPath"
|
// Some command to execute script or binary at "ExecPath"
|
||||||
QString supportedDevices = jsonObject["SupportedDevices"].toString();
|
QJsonArray supportedDevices = jsonObject["SupportedDevices"].toArray();
|
||||||
QString message = "Supported devices for this app: ";
|
|
||||||
message.append(supportedDevices);
|
|
||||||
log(message, className);
|
|
||||||
|
|
||||||
|
// 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) {
|
if(supportedDevices.contains("all") == false and supportedDevices.contains(global::deviceID.trimmed()) == false) {
|
||||||
log("Warning: User app does not support this device", className);
|
log("Warning: User app does not support this device", className);
|
||||||
global::userApps::appCompatibilityDialog = true;
|
global::userApps::appCompatibilityDialog = true;
|
||||||
global::userApps::appCompatibilityText = "<font face='u001'>Your device is not compatible with this app.<br>Launch it anyway</font><font face='Inter'>?</font>";
|
global::userApps::appCompatibilityText = "<font face='u001'>Your device is not compatible with this app.<br>Continue anyway</font><font face='Inter'>?</font>";
|
||||||
generalDialogWindow = new generalDialog();
|
generalDialogWindow = new generalDialog();
|
||||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
|
@ -175,20 +173,30 @@ void userapps::on_launchBtn_clicked()
|
||||||
|
|
||||||
bool userapps::manageRequiredFeatures()
|
bool userapps::manageRequiredFeatures()
|
||||||
{
|
{
|
||||||
|
// This should be already set to 'true', but just in case
|
||||||
|
global::userApps::appCompatibilityLastContinueStatus = true;
|
||||||
QJsonArray jsonArray = jsonObject["RequiredFeatures"].toArray();
|
QJsonArray jsonArray = jsonObject["RequiredFeatures"].toArray();
|
||||||
for(QJsonValueRef refJsonObject: jsonArray) {
|
for(QJsonValueRef refJsonObject: jsonArray) {
|
||||||
bool launchDialog = false;
|
bool launchDialog = false;
|
||||||
int featureId = refJsonObject.toInt();
|
int featureId = refJsonObject.toInt();
|
||||||
// Wi-Fi connection required
|
// Wi-Fi connection required
|
||||||
if(featureId == 0) {
|
if(featureId == 0) {
|
||||||
global::userApps::appCompatibilityText = "<font face='u001'>This app needs Wi-Fi connection, launch anyway</font><font face='Inter'>?</font>";
|
// Double 'if' conditions to avoid launching unnecesery testPing() in emu
|
||||||
launchDialog = true;
|
if(global::deviceID != "emu\n") {
|
||||||
|
if(testPing(true) != 0) {
|
||||||
|
global::userApps::appCompatibilityText = "<font face='u001'>This app needs a Wi-Fi connection, continue anyway</font><font face='Inter'>?</font>";
|
||||||
|
launchDialog = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Rooted kernel required
|
// Rooted kernel required
|
||||||
if(featureId == 1) {
|
if(featureId == 1) {
|
||||||
global::userApps::appCompatibilityText = "<font face='u001'>This app needs a rooted kernel, launch anyway</font><font face='Inter'>?</font>";
|
if(checkconfig("/external_root/opt/root/rooted") == true) {
|
||||||
launchDialog = true;
|
global::userApps::appCompatibilityText = "<font face='u001'>This app needs a rooted kernel, continue anyway</font><font face='Inter'>?</font>";
|
||||||
|
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) {
|
if(launchDialog == true) {
|
||||||
global::userApps::appCompatibilityDialog = true;
|
global::userApps::appCompatibilityDialog = true;
|
||||||
|
@ -224,19 +232,32 @@ QString userapps::parseJsonShow(QJsonObject json)
|
||||||
}
|
}
|
||||||
else if(value.isArray()) {
|
else if(value.isArray()) {
|
||||||
QJsonArray array = value.toArray();
|
QJsonArray array = value.toArray();
|
||||||
for(QJsonValueRef ref: array) {
|
if(key == "RequiredFeatures") {
|
||||||
int id = ref.toInt();
|
for(QJsonValueRef ref: array) {
|
||||||
if(id == 0) {
|
int id = ref.toInt();
|
||||||
appendString.append("Wi-Fi connection");
|
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.remove(appendString.size() - 2, 2);
|
||||||
appendString.append("Rooted kernel");
|
}
|
||||||
}
|
else if(key == "SupportedDevices") {
|
||||||
appendString.append(", ");
|
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("<br>");
|
appendString.append("<br>");
|
||||||
mainString.append(appendString);
|
mainString.append(appendString);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue