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:
1
res/doc
1
res/doc
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user