1
0

Implemented auto_usb_gadget for nickel_setting (closes #76) (#77)

This commit is contained in:
Patrick Gaskin
2020-08-09 21:26:39 -04:00
committed by GitHub
parent 65fbea2c49
commit 39b19654fc
2 changed files with 13 additions and 8 deletions

View File

@@ -62,6 +62,7 @@
# lockscreen - PowerSettings.UnlockEnabled (4.12.12111+)
# screenshots - FeatureSettings.Screenshots
# force_wifi - DeveloperSettings.ForceWifiOn (note: the setting doesn't apply until you toggle WiFi)
# auto_usb_gadget - Automatically enable USB mass storage on connection
# nickel_extras - the mimetype of the plugin, or one of:
# unblock_it
# sketch_pad

View File

@@ -278,22 +278,26 @@ NM_ACTION_(nickel_setting) {
NM_CHECK(nullptr, PowerSettings__getUnlockEnabled(settings) == !v, "failed to set setting");
vtable_ptr(settings) = vtable_target(PowerSettings_vtable);
} else if (!strcmp(arg2, "force_wifi")) {
} else if (!strcmp(arg2, "force_wifi") || !strcmp(arg2, "auto_usb_gadget")) {
//libnickel 4.6 * _ZTV11DevSettings
void *PowerSettings_vtable = dlsym(RTLD_DEFAULT, "_ZTV11DevSettings");
NM_CHECK(nullptr, PowerSettings_vtable, "could not dlsym the vtable for DevSettings");
vtable_ptr(settings) = vtable_target(PowerSettings_vtable);
const QString st = !strcmp(arg2, "force_wifi")
? QStringLiteral("ForceWifiOn")
: QStringLiteral("AutoUsbGadget");
if (mode == mode_toggle) {
QVariant v1 = Settings_getSetting(settings, QStringLiteral("ForceWifiOn"), QVariant(false));
QVariant v1 = Settings_getSetting(settings, st, QVariant(false));
vtable_ptr(settings) = vtable_target(PowerSettings_vtable);
v = v1.toBool();
}
Settings_saveSetting(settings, QStringLiteral("ForceWifiOn"), QVariant(!v), false);
Settings_saveSetting(settings, st, QVariant(!v), false);
vtable_ptr(settings) = vtable_target(PowerSettings_vtable);
QVariant v2 = Settings_getSetting(settings, QStringLiteral("ForceWifiOn"), QVariant(false));
QVariant v2 = Settings_getSetting(settings, st, QVariant(false));
vtable_ptr(settings) = vtable_target(PowerSettings_vtable);
} else {
// TODO: more settings?