1
0

Implemented nickel_setting:force_wifi action

As per @NiLuJe's request: https://github.com/geek1011/kobo-plugin-experiments/issues/3#issuecomment-622109660
This commit is contained in:
Patrick Gaskin
2020-05-01 03:59:19 -04:00
parent 748338bbdb
commit 155bee4c9c
2 changed files with 18 additions and 0 deletions

View File

@@ -39,6 +39,7 @@
# invert - toggles FeatureSettings.InvertScreen (all versions)
# lockscreen - toggles PowerSettings.UnlockEnabled (4.12.12111+)
# screenshots - toggles FeatureSettings.Screenshots (all versions)
# force_wifi - toggles DeveloperSettings.ForceWifiOn (note: the setting doesn't apply until you toggle WiFi) (all versions)
# nickel_extras - the mimetype of the plugin, or one of:
# web_browser
# unblock_it

View File

@@ -144,6 +144,23 @@ NM_ACTION_(nickel_setting) {
NM_ASSERT(PowerSettings__getUnlockEnabled(settings) == !v, "failed to set setting");
vtable_ptr(settings) = vtable_target(PowerSettings_vtable);
}
} else if (!strcmp(arg, "force_wifi")) {
void *PowerSettings_vtable = dlsym(RTLD_DEFAULT, "_ZTV11DevSettings");
NM_ASSERT(PowerSettings_vtable, "could not dlsym the vtable for DevSettings");
vtable_ptr(settings) = vtable_target(PowerSettings_vtable);
if (!strcmp(arg, "force_wifi")) {
QVariant v1 = Settings_getSetting(settings, QStringLiteral("ForceWifiOn"), QVariant(false));
vtable_ptr(settings) = vtable_target(PowerSettings_vtable);
v = v1.toBool();
Settings_saveSetting(settings, QStringLiteral("ForceWifiOn"), QVariant(!v), false);
vtable_ptr(settings) = vtable_target(PowerSettings_vtable);
QVariant v2 = Settings_getSetting(settings, QStringLiteral("ForceWifiOn"), QVariant(false));
vtable_ptr(settings) = vtable_target(PowerSettings_vtable);
}
} else {
// TODO: more settings
Settings_SettingsD(settings);