void pack_restrict(int mode, bool on)
{
+ DPM::package_mode pmod;
+
+ if (mode == 0) pmod = DPM::PACKAGE_INSTALL;
+ if (mode == 1) pmod = DPM::PACKAGE_UNINSTALL;
+ if (mode == 2) pmod = DPM::PACKAGE_REINSTALL;
+ if (mode == 3) pmod = DPM::PACKAGE_MOVE;
+ if (mode == 4) pmod = DPM::PACKAGE_ALL;
+
+ dpm_error err;
+ err = dpm->set_package_restriction(pmod, on);
+
+ if (err == DPM_OK)
+ printf("%s\n", on ? "Restricted" : "Allowed");
+ else
+ printf("Error: %s\n", dpm->get_error_string(err));
+
if (mode == 4)
{
prest[0] = on;
prest[2] = on;
prest[3] = on;
- if (on)
- printf("All restricted\n");
- else
- printf("All allowed\n");
+// if (on)
+// printf("All restricted\n");
+// else
+// printf("All allowed\n");
}
else if (mode >= 0 && mode < 4)
{
prest[mode] = on;
- if (mode == 0) printf("Package install ");
- if (mode == 1) printf("Package uninstall ");
- if (mode == 2) printf("Package reinstall ");
- if (mode == 3) printf("Package move ");
- printf("%s\n", on ? "restricted" : "allowed");
+// if (mode == 0) printf("Package install ");
+// if (mode == 1) printf("Package uninstall ");
+// if (mode == 2) printf("Package reinstall ");
+// if (mode == 3) printf("Package move ");
+// printf("%s\n", on ? "restricted" : "allowed");
}
}
void priv_list(const char *name, bool add)
{
+ dpm_error err;
+
if (add)
- printf("Privelege <%s> added\n", name);
+ err = dpm->add_privilege_to_blacklist(name);
else
- printf("Privelege <%s> removed\n", name);
-}
+ err = dpm->remove_privilege_from_blacklist(name);
-//##################
+ if (err == DPM_OK)
+ {
+ if (add)
+ printf("Privilege <%s> added\n", name);
+ else
+ printf("Privilege <%s> removed\n", name);
+ }
+ else
+ printf("Error: %s\n", dpm->get_error_string(err));
+}
-void menu_package()
+void pack_state(char *st)
{
- char st[256];
-
sprintf(st, " %s: %s\n %s: %s\n %s: %s\n %s: %s\n",
"Package install", prest[0] ? "restricted" : "allowed",
"Package uninstall", prest[1] ? "restricted" : "allowed",
"Package reinstall", prest[2] ? "restricted" : "allowed",
"Package move", prest[3] ? "restricted" : "allowed"
);
+}
+
+//##################
+
+void menu_package()
+{
+ char st[256];
+
+ pack_state(st);
BEGIN(st,
" 1 - Package install restriction on\n"
else if (!strcmp(s, "8")) pack_restrict(3, false);
else if (!strcmp(s, "9")) pack_restrict(4, true);
else if (!strcmp(s, "0")) pack_restrict(4, false);
- END
+ else printf("Wrong input\n");
+ pack_state(st);
+ printf("State:\n%s\n", st);
+ }
}
void menu_app()
void uuid_bl(const char *uuid, bool add)
{
- printf("UUID %s %s\n", uuid, add ? "added" : "removed");
+ dpm_error err;
+ if (add)
+ err = dpm->bluetooth_add_uuid_to_blacklist(uuid);
+ else
+ err = dpm->bluetooth_remove_uuid_from_blacklist(uuid);
+
+ if (err == DPM_OK)
+ printf("UUID %s %s\n", uuid, add ? "added" : "removed");
+ else
+ printf("Error: %s\n", dpm->get_error_string(err));
}
bool device_restriction;
{
char st[256];
+ dpm_error err;
+ err = dpm->bluetooth_is_device_restricted(device_restriction);
+ if (err != DPM_OK)
+ printf("bluetooth_is_device_restricted() error: %s\n", dpm->get_error_string(err));
+ err = dpm->bluetooth_is_uuid_restricted(uuid_restriction);
+ if (err != DPM_OK)
+ printf("bluetooth_is_uuid_restricted() error: %s\n", dpm->get_error_string(err));
+
sprintf(st, "Bluetooth restrictions:\n %s: %s\n %s: %s\n",
"Device restriction", device_restriction ? "on" : "off",
"UUID restriction", uuid_restriction ? "on" : "off"
static char items[1024];
char *p = items;
dpm_error err = DPM_OK;
- bool allow;
get_rst_state(st);