aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/app.go
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-10-20 00:07:48 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-10-20 00:22:18 +0900
commitad0034b09aaa76aca478304518c1394ba292a619 (patch)
tree07fc40ae14d9eecb368997688c0de1eb1e89cb15 /internal/app/app.go
parent1da845d78bdd6be03e771958100d388b3e6e9fcc (diff)
app: move app ID to app struct
App ID is inherent to App, and it makes no sense to generate it as part of the app sealing process. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'internal/app/app.go')
-rw-r--r--internal/app/app.go29
1 files changed, 22 insertions, 7 deletions
diff --git a/internal/app/app.go b/internal/app/app.go
index a04ae74b..4c3a60c3 100644
--- a/internal/app/app.go
+++ b/internal/app/app.go
@@ -7,26 +7,39 @@ import (
)
type App interface {
- Seal(config *Config) error
+ // ID returns a copy of App's unique ID.
+ ID() ID
+ // Start sets up the system and starts the App.
Start() error
+ // Wait waits for App's process to exit and reverts system setup.
Wait() (int, error)
+ // WaitErr returns error returned by the underlying wait syscall.
WaitErr() error
+
+ Seal(config *Config) error
String() string
}
type app struct {
+ // application unique identifier
+ id *ID
+ // underlying user switcher process
+ cmd *exec.Cmd
// child process related information
seal *appSeal
- // underlying fortified child process
- cmd *exec.Cmd
+
// wayland connection if wayland mediation is enabled
wayland *net.UnixConn
// error returned waiting for process
- wait error
+ waitErr error
lock sync.RWMutex
}
+func (a *app) ID() ID {
+ return *a.id
+}
+
func (a *app) String() string {
if a == nil {
return "(invalid fortified app)"
@@ -47,9 +60,11 @@ func (a *app) String() string {
}
func (a *app) WaitErr() error {
- return a.wait
+ return a.waitErr
}
-func New() App {
- return new(app)
+func New() (App, error) {
+ a := new(app)
+ a.id = new(ID)
+ return a, newAppID(a.id)
}