Files
mcde/programs/dtsystemsettings/panes.c
T
lotherk 020dd9ff5d MCDE dtsystemsettings: Security, three tabs (t0157)
New programs/dtsystemsettings/security.c with the reference's three tabs:

  General     "Require password to wake this computer from sleep or screen
              saver" writes dtsession's lock time (_DtSetSmState with
              SM_STATE_LOCKTIMEOUT; the Screen Saver page reads and writes the
              same field, so the two pages show one setting).  On: the lock at
              the saver's time, or ten minutes without a saver.  "Use secure
              virtual memory" is NetBSD's vm.swap_encrypt through McdeSys
              (now and in /etc/sysctl.conf, root).  Automatic login and a
              log-out after N minutes are shown as what the desktop has:
              dtlogin always asks for a name and a password, and dtsession
              has no idle logout -- the pane says so and greys the controls.
  Encryption  the cgd(4) volumes of /etc/cgd/cgd.conf, and the sentence that
              encrypting a disk is a decision of the installation, not of a
              running system; changing a passphrase is a follow-up.
  Firewall    the npf(7) state (rc.conf npf=YES, /etc/npf.conf); the rules
              are a follow-up -- a fixed template with the shares of the
              Sharing page, never free text.

McdeSys gained the security state: mcde_sys_swap_encrypt_get/_set,
mcde_sys_cgd_volumes, mcde_sys_firewall_get.  netbsd.c implements them
(sysctl(8) vm.swap_encrypt, /etc/sysctl.conf through a KeySet() that rc.conf
now uses too, /etc/cgd/cgd.conf, rc.conf's npf), linux.c answers
MCDE_SYS_ENOTSUP with a sentence saying whose feature it is.
test_sysinfo prints all three.

The pane's icon is new: programs/icons/McdeLock.pm (a padlock, palette
colours); "security" is a real pane now, not a greyed entry.

Measured under Xvfb with xdotool (dtsession started in the session):

  - the lock checkbox: _DT_SM_STATE_INFO on dtsession's window before the
    click 0xfff, ... lockTimeout 0x0; after it 0x100 (SM_STATE_LOCKTIMEOUT),
    lockTimeout 0x258 (600 s); a second click puts it back to 0x0;
  - the three tabs and their content (docs/screenshots/leopard/
    System-Preferences-Security-mcde.png with the lock on, ...-Encryption-
    mcde.png, ...-Firewall-mcde.png);
  - test_sysinfo on this (Linux) host prints the three MCDE_SYS_ENOTSUP
    sentences -- the pane shows them instead of dead controls;
  - make check programs/dtsystemsettings: test_panes PASS; the Sound and
    Keyboard & Mouse panes still switch their tabs after the layout fix
    below;
  - make programs/dtsystemsettings, lib/McdeSys exit=0.

A Motif lesson, saved in AGENTS.md: a row column inside the pane area takes
the other orientation unless told, a child added later to a tight-packed
column goes into the next column, and a page managed for the first time after
its widgets were built keeps a height of one line.  The pane therefore builds
its page fresh inside an XmPACK_COLUMN container on a tab change; the same
XmNorientation, XmVERTICAL went into the Sound and Keyboard & Mouse page
containers.

Not measured, because this host is not NetBSD or has no root: swapping
vm.swap_encrypt, reading cgd volumes, the npf state and writing npf rules.
They are the follow-up task for the VM.
2026-11-14 12:44:32 +00:00

146 lines
5.0 KiB
C

/*
* panes.c -- dtsystemsettings: the panes and their categories (panes.h)
*
* License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
*
* One place for the computer's settings, in four rows. A pane is drawn
* here (sound, network, Bluetooth, date and time, about) when the setting
* goes through McdeSys; the panes that are CDE's own style manager open it
* until they are drawn here too.
*/
#include <string.h>
#include "panes.h"
const char *const categoryNames[CAT_COUNT] = {
"Personal",
"Hardware",
"Internet & Network",
"System"
};
const Pane panes[] = {
{ "appearance", "Appearance", CAT_PERSONAL, "DtColor.pm", PANE_OWN,
NULL, "appearance colours colors palette theme farben fonts "
"schrift schriften smoothing antialias" },
{ "desktop", "Desktop & Screen Saver", CAT_PERSONAL, "DtBkdrp.pm",
PANE_OWN, NULL, "desktop background wallpaper hintergrund "
"screensaver screen saver bildschirmschoner" },
{ "language", "Language", CAT_PERSONAL, "DtI18N.pm", PANE_OWN,
NULL, "language sprache locale region formats datum" },
{ "dock", "Dock", CAT_PERSONAL, "DtPanel.m.pm", PANE_LATER, NULL,
"dock leiste panel front panel" },
{ "security", "Security", CAT_PERSONAL, "McdeLock.pm", PANE_OWN, NULL,
"security sicherheit firewall lock sperre password passwort "
"encryption verschluesselung cgd swap virtual memory npf" },
{ "sound", "Sound", CAT_HARDWARE, "Dtaudio.m.pm", PANE_OWN, NULL,
"sound audio lautstaerke volume ton" },
{ "displays", "Displays", CAT_HARDWARE, "DtScrn.pm", PANE_OWN,
NULL, "displays monitors resolution aufloesung bildschirm" },
{ "keyboardmouse", "Keyboard & Mouse", CAT_HARDWARE, "DtKeybd.pm",
PANE_OWN, NULL, "keyboard mouse tastatur maus wiederholung "
"repeat shortcuts keys tastenkuerzel" },
{ "printers", "Printers", CAT_HARDWARE, "Dtprint.m.pm", PANE_COMMAND,
"dtprintinfo -all", "printers drucker print cups" },
{ "bluetooth", "Bluetooth", CAT_HARDWARE, "McdeBluetooth.m.pm",
PANE_OWN, NULL, "bluetooth" },
{ "cds", "CDs & DVDs", CAT_HARDWARE, "Dtmedia.m.pm", PANE_LATER, NULL,
"cds dvds medien media einlegen" },
{ "energy", "Energy Saver", CAT_HARDWARE, "Dtbattery.m.pm", PANE_LATER,
NULL, "energy energie sleep ruhezustand strom" },
{ "network", "Network", CAT_NETWORK, "McdeWired.m.pm", PANE_OWN, NULL,
"network netzwerk lan wlan wifi ethernet dhcp ip" },
{ "sharing", "Sharing", CAT_NETWORK, "Dtlink.m.pm", PANE_OWN, NULL,
"sharing freigaben smb afp nfs ssh dateien" },
{ "datetime", "Date & Time", CAT_SYSTEM, "Dtdate.m.pm", PANE_OWN, NULL,
"date time uhr zeit timezone zeitzone ntp" },
{ "startup", "Startup", CAT_SYSTEM, "DtStart.pm", PANE_OWN, NULL,
"startup boot" },
{ "accounts", "Accounts", CAT_SYSTEM, "DtStart.pm", PANE_OWN, NULL,
"accounts benutzer users password passwort" },
{ "update", "Software Update", CAT_SYSTEM, "Dtstyle.m.pm", PANE_OWN,
NULL, "update software aktualisierung pakete packages" },
{ "backup", "Backup", CAT_SYSTEM, "DtSystem.m.pm", PANE_OWN, NULL,
"backup sicherung" },
{ "startupdisk", "Startup Disk", CAT_SYSTEM, "Dtdisk.m.pm", PANE_LATER,
NULL, "startup disk startvolume" },
{ "accessibility", "Accessibility", CAT_SYSTEM, "Dtmouse.m.pm",
PANE_LATER, NULL, "accessibility bedienungshilfen" },
{ "about", "About", CAT_SYSTEM, "MakronixDtlogo.m.pm", PANE_OWN, NULL,
"about info systembericht" },
};
const int paneCount = (int) (sizeof panes / sizeof panes[0]);
static void
Lower(const char *in, char *out, size_t len)
{
size_t i;
for (i = 0; in[i] != '\0' && i + 1 < len; i++)
out[i] = (in[i] >= 'A' && in[i] <= 'Z') ? in[i] - 'A' + 'a' :
in[i];
out[i] = '\0';
}
int
PaneMatch(const Pane *p, const char *query)
{
char q[128], hay[512];
if (p == NULL)
return 0;
if (query == NULL || query[0] == '\0')
return 1;
Lower(query, q, sizeof q);
if (q[0] == '\0')
return 1;
(void)snprintf(hay, sizeof hay, "%s %s %s", p->id, p->label,
p->keywords != NULL ? p->keywords : "");
Lower(hay, hay, sizeof hay);
return strstr(hay, q) != NULL;
}
const Pane *
PaneFind(const char *id)
{
static Pane alias;
int i;
if (id == NULL)
return NULL;
/* the fonts are part of Appearance since t0099; the old id stays */
if (strcmp(id, "fonts") == 0)
id = "appearance";
/* Desktop & Screen Saver is one pane since t0110; the old id opens the
* saver's page */
if (strcmp(id, "screensaver") == 0) {
for (i = 0; i < paneCount; i++)
if (strcmp(panes[i].id, "desktop") == 0) {
alias = panes[i];
alias.id = id;
return &alias;
}
return NULL;
}
/* Keyboard & Mouse is one pane since t0129; the old ids open its tab */
if (strcmp(id, "keyboard") == 0 || strcmp(id, "mouse") == 0 ||
strcmp(id, "shortcuts") == 0) {
for (i = 0; i < paneCount; i++)
if (strcmp(panes[i].id, "keyboardmouse") == 0) {
alias = panes[i];
alias.id = id;
return &alias;
}
return NULL;
}
for (i = 0; i < paneCount; i++)
if (strcmp(panes[i].id, id) == 0)
return &panes[i];
return NULL;
}