tray

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package tray implements the basic functionality of the system tray application

Exported function(s): OnReady, OnQuit, ChangeScanInterval, ScanNow, ChangeLanguage, RefreshMenu

Index

Constants

This section is empty.

Variables

View Source
var Language = 1

Language is used to represent the index of the currently selected language. The language indices are as follows:

0: German

1: British English

2: American English

3: Spanish

4: French

5: Dutch

6: Portuguese

Default language is British English

View Source
var MenuItems []MenuItem
View Source
var ReportingPageOpen = false
View Source
var ScanCounter int
View Source
var ScanTicker *time.Ticker

Functions

func BuildReportingPage

func BuildReportingPage() error

BuildReportingPage builds the reporting page executable using a Wails application

Parameters: _

Returns: _

func ChangeLanguage

func ChangeLanguage(testInput ...string)

ChangeLanguage allows the user to select a new language for the application via a dialog window.

This function presents a dialog window with a list of available languages. The user can select a language from this list, and the application's language setting is updated accordingly. The function maps each language to an index, which is used internally for localization. If the function is called with a test input, it uses the test input instead of displaying the dialog window.

The language indices are as follows: 0: German 1: British English 2: American English 3: Spanish 4: French 5: Dutch 6: Portuguese

Parameters:

  • testInput ...string: Optional parameter used for testing. If provided, the function uses this as the user's language selection instead of displaying the dialog window.

Returns: None. The function updates the 'language' variable in-place.

func ChangeScanInterval

func ChangeScanInterval(testInput ...string)

ChangeScanInterval prompts the user to set a new scan interval through a dialog window.

This function displays a dialog window asking the user to input the desired scan interval in hours. If the user input is valid, the function updates the scan interval accordingly. If the input is invalid or less than or equal to zero, the function defaults to a 24-hour interval.

For testing purposes, an optional string parameter 'testInput' can be provided. If 'testInput' is provided, the function uses this as the user's input instead of displaying the dialog window.

Parameters:

  • testInput ...string: Optional parameter used for testing. If provided, the function uses this as the user's input instead of displaying the dialog window.

Returns: None. The function updates the 'ScanTicker' variable in-place.

func OnQuit

func OnQuit()

OnQuit manages the cleanup operations that need to be performed when the application is about to terminate.

This function is called when the application is exiting. It is responsible for performing any necessary cleanup operations such as closing open files, terminating active connections, or releasing resources. The specific cleanup operations depend on the resources and services used by the application.

Parameters: None.

Returns: None. The function performs cleanup operations in-place.

func OnReady

func OnReady()

OnReady orchestrates the runtime behavior of the system tray application.

This function sets up the system tray with various menu items such as 'Reporting Page', 'Change Scan Interval', 'Scan Now', 'Change Language', and 'Quit'. It also initializes a ticker for scheduled security scans and a signal listener for system termination signals. It then enters a loop where it listens for various events such as clicks on the menu items, system termination signals, and the elapse of the scan interval. Depending on the event, it performs actions such as opening the reporting page, changing the scan interval, initiating an immediate scan, changing the application language, refreshing the menu, or quitting the application.

Parameters: None.

Returns: None. The function runs indefinitely, orchestrating the behavior of the system tray application.

func OpenReportingPage

func OpenReportingPage(path string) error

OpenReportingPage launches the reporting page of the application using a Wails application.

This function checks if a reporting page is already open. If it is, it returns an error. If not, it changes the current working directory to the reporting page directory and builds the reporting-page executable using the Wails framework. It then runs the executable, opening the reporting page. If the 'Quit' option is selected from the system tray while the reporting page is open, the function kills the reporting-page process and sets the ReportingPageOpen flag to false.

Parameters:

  • path string: The relative path to the reporting-page directory. This is used to change the current working directory to the reporting-page directory.

Returns:

  • error: An error object if an error occurred during the process, otherwise nil.

func RefreshMenu

func RefreshMenu()

RefreshMenu updates the system tray menu items to reflect the current language setting.

This function iterates over each menu item in the system tray and updates its title and tooltip text to match the current language setting. The language setting is determined by the 'language' variable, which stores the index of the currently active language. The function uses the 'Localize' function from the 'localization' package to translate the title and tooltip text of each menu item.

Parameters: None.

Returns: None. The function updates the system tray menu items in-place.

func ScanNow

func ScanNow() ([]checks.Check, error)

ScanNow initiates an immediate security scan, bypassing the scheduled intervals.

This function triggers a security scan regardless of the scheduled intervals. It is useful for situations where an immediate scan is required, such as after a significant system change or when manually requested by the user. During the scan, a progress dialog is displayed to keep the user informed about the scan progress. Once the scan is complete, the dialog is closed and the results of the scan are returned.

Parameters: None.

Returns:

  • []checks.Check: A list of checks performed during the scan.
  • error: An error object if an error occurred during the scan, otherwise nil.

Types

type MenuItem struct {
	MenuTitle string
	// contains filtered or unexported fields
}

MenuItem represents a single item in the system tray menu.

This struct encapsulates the title, tooltip text, and the actual system tray menu item object for a single menu item. The 'MenuTitle' field is a string that represents the title of the menu item. This is the text that is displayed in the system tray menu. The 'menuTooltip' field is a string that represents the tooltip text for the menu item. This is the text that is displayed when the user hovers over the menu item in the system tray menu. The 'sysMenuItem' field is a pointer to a systray.MenuItem object. This is the actual menu item object that is added to the system tray menu.

Fields:

  • MenuTitle string: The title of the menu item. This is the text that is displayed in the system tray menu.
  • menuTooltip string: The tooltip text for the menu item. This is the text that is displayed when the user hovers over the menu item in the system tray menu.
  • sysMenuItem *systray.MenuItem: The actual menu item object that is added to the system tray menu.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL