JFLib

ui/perm.rs#

Source: lib/ui/perm.rs

perm -- what build_rs.py builds into an app, set up before it starts, and the app's
permissions on the UI side (plat::policy, docs/PERMISSIONS.md, docs/VFS.md)

  boot(app, manifest, assets)   (main!) the app's name for its folders (plat::vfs::
                          set_app_id), its asset bundle as app:// (JFA1, apps/NAME/assets),
                          then its manifest (apps/NAME/PERMISSIONS, a BINS program's own
                          PERMISSIONS.<bin>); Err(exit code) for a bundle or manifest it
                          refuses.  Before the manifest: the user's languages and format
                          (i18n::boot: jfgui_LANG, else the system in window mode, German in
                          headless runs).  The paths on the command line come from the user:
                          with fs.user they may be read and written (folders with everything
                          below).  The steps are plat::boot's, which console programs
                          (rt::main!) run without the UI.  Script runs (--script) keep the
                          answers to permission questions in memory (jfgui_PERM_STORE or
                          `perm store` for a file).
  grant_user(path)        the same for a path of the file dialog or a drop
  trusted(f)              f on this thread without file checks: the library's own file
                          dialog lists folders, scripts read and write their files
  ask_here(on)            (runtime) the UI thread asks the questions of ask lines and agent
                          actions (window runs; scripts after `perm answer dialog`)
  answer(id, a) / set_answer(a) / set_wait(ms) / set_store(path)   (scripts: perm ...)
  Ui::perm_dialog()       (run_passes, after App::frame) the first open question as a content
                          dialog: what, the path / host / program / action, the plugin, the
                          manifest's reason (through the app's catalogue), the ask line, and
                          "Einmal erlauben" (until the program ends), "Immer erlauben"
                          (stored), "Ablehnen" (until the program ends), "Nie erlauben"
                          (stored); Esc = Ablehnen.  The two that allow take no input for
                          half a second after a question appears (window runs), so a
                          double click or a held key does not answer it unread.  The answer reaches the app as
                          UIC_PERMISSION (arg 1 allowed, 0 refused): an access the UI thread
                          made while the question was open was refused, it may try again.
  Ui::permissions_page(id) -> bool   the ready-made settings section: every ask line and
                          answered agent action with what it allows, the rule, the reason
                          and the answer; "Zurücksetzen: <rule>" revokes one (asked again
                          on the next access), "Alle zurücksetzen" all; true when an answer
                          was revoked.  Ids: the scope of `id`, then the rule ("reset").

The key of plat::policy stays here: apps cannot widen their own permissions or answer
their own questions.
  • fn boot(app: Option<&str>, manifest: Option<&str>, assets: &'static [u8]) -> Result<(), i32> (main!) set up the app: its name, its assets (app://), its permissions

impl Ui

  • fn permissions_page(&mut self, id: u32) -> bool the permissions section of a settings page: the answers to the app's permission questions, each with a reset (module header) -> an answer was revoked

Source: docs/API.md in the JFLib repository.