TeeJee.System

1. Overview

The TeeJee.System module provides operating-system utility namespace for BastionGuard Backup. It provides privilege checks, user identity lookup, uptime, desktop file opening, EFI detection, timers, and millisecond sleep helpers.

The implementation is written in Vala and uses GLib/GIO together with the application utility namespaces required by the file.


2. Dependencies and Integration

The module imports:

  • TeeJee.ProcessHelper
  • TeeJee.Logging
  • TeeJee.Misc
  • TeeJee.FileSystem

3. Declared Types

3.1 TeeJee.System

namespace TeeJee.System

This namespace groups stateless utility functions and shared constants.


4. State, Properties, Constants, and Signals

Internal state

  • private int euid – Runtime state used by the module.

5. Public API and Operational Methods

5.1 user_is_admin()

public bool user_is_admin()

Implements the user is admin operation for this module.

5.2 get_user_id()

public int get_user_id()

Returns or resolves user id from the current state or underlying system data.

5.3 get_user_id_effective()

public int get_user_id_effective()

Returns or resolves user id effective from the current state or underlying system data.

5.4 get_username_from_uid()

public string? get_username_from_uid(int user_id)

Returns or resolves username from uid from the current state or underlying system data.

5.5 get_system_uptime_seconds()

public double get_system_uptime_seconds()

Returns or resolves system uptime seconds from the current state or underlying system data.

  • Performs filesystem access and handles files or directories through GLib or TeeJee helpers.

5.6 xdg_open()

public static bool xdg_open (string file)

Implements the xdg open operation for this module.

  • Uses asynchronous callbacks, child watches, or worker-thread behavior.

5.7 exo_open_folder()

public bool exo_open_folder (string dir_path, bool xdg_open_try_first = true)

Implements the exo open folder operation for this module.

  • Uses asynchronous callbacks, child watches, or worker-thread behavior.

5.8 using_efi_boot()

public bool using_efi_boot()

Evaluates using efi boot and returns a Boolean capability or state result.

5.9 timer_start()

public GLib.Timer timer_start()

Implements the timer start operation for this module.

5.10 timer_elapsed()

public ulong timer_elapsed(GLib.Timer timer, bool stop = true)

Implements the timer elapsed operation for this module.

5.11 sleep()

public void sleep(int milliseconds)

Implements the sleep operation for this module.

5.12 timer_elapsed_string()

public string timer_elapsed_string(GLib.Timer timer, bool stop = true)

Implements the timer elapsed string operation for this module.

5.13 set_numeric_locale()

public void set_numeric_locale(string type)

Updates numeric locale and applies the corresponding runtime state.


6. Filesystem Paths and Resource Locations

The source references the following absolute or template paths:

/proc/uptime
/sys/firmware/efi

Some values are templates completed at runtime with application names, process IDs, device identifiers, or file names.


7. External Commands and System Interfaces

The module constructs, checks, or parses commands containing:

xdg-open
xdg-open '%s'

Execution success is determined from command exit status and, where applicable, parsed standard output or standard error.


8. Operational Flow

  1. Read or discover source data and normalize it into the module data model.

9. Error Handling and Diagnostics

  • The TeeJee logging layer records errors, debug state, generated commands, and operational messages.
  • Boolean, nullable, or empty-string return values communicate recoverable failures to callers.

10. Runtime and Security Considerations

  • Linux-specific paths: the module depends on Linux virtual filesystems or privileged system directories.
  • Concurrency: callbacks and worker state must remain synchronized with object destruction and GTK main-loop ownership.
  • Shared state: static caches and global switches are shared by all callers and are not automatically thread-isolated.

11. Licensing

The source is distributed under the GNU General Public License version 2 or any later version.

The source header identifies:

Copyright 2012-2018 Tony George <teejeetech@gmail.com>