aboutsummaryrefslogtreecommitdiffhomepage
path: root/system/dbus/proxy.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-13 01:15:19 +0900
committerOphestra <cat@gensokyo.uk>2025-11-13 01:17:47 +0900
commit4e7aab07d5b175345fdf3ea08868dab1e6d90126 (patch)
treea625cca0e8cdf576313fe2d9ab07a22d1839ee7c /system/dbus/proxy.go
parent15a66a2b314e7a674c9445e25ffb2451ec73b55e (diff)
internal/system: relocate from system
These packages are highly specific to hakurei and are difficult to use safely from other pieces of code. Their exported symbols are made available until v0.4.0 where they will be removed for #24. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'system/dbus/proxy.go')
-rw-r--r--system/dbus/proxy.go105
1 files changed, 0 insertions, 105 deletions
diff --git a/system/dbus/proxy.go b/system/dbus/proxy.go
deleted file mode 100644
index 9de49c41..00000000
--- a/system/dbus/proxy.go
+++ /dev/null
@@ -1,105 +0,0 @@
-package dbus
-
-import (
- "context"
- "io"
- "sync"
- "syscall"
-
- "hakurei.app/hst"
- "hakurei.app/internal/helper"
- "hakurei.app/message"
-)
-
-// ProxyName is the file name or path to the proxy program.
-// Overriding ProxyName will only affect Proxy instance created after the change.
-var ProxyName = "xdg-dbus-proxy"
-
-// Proxy holds the state of a xdg-dbus-proxy process, and should never be copied.
-type Proxy struct {
- helper helper.Helper
- ctx context.Context
- msg message.Msg
-
- cancel context.CancelCauseFunc
- cause func() error
-
- final *Final
- output io.Writer
- useSandbox bool
-
- name string
-
- mu, pmu sync.RWMutex
-}
-
-func (p *Proxy) String() string {
- if p == nil {
- return "(invalid dbus proxy)"
- }
-
- p.mu.RLock()
- defer p.mu.RUnlock()
-
- if p.helper != nil {
- return p.helper.String()
- }
-
- return "(unused dbus proxy)"
-}
-
-// Final describes the outcome of a proxy configuration.
-type Final struct {
- Session, System ProxyPair
- // parsed upstream address
- SessionUpstream, SystemUpstream []AddrEntry
- io.WriterTo
-}
-
-// Finalise creates a checked argument writer for [Proxy].
-func Finalise(sessionBus, systemBus ProxyPair, session, system *hst.BusConfig) (final *Final, err error) {
- if session == nil && system == nil {
- return nil, syscall.EBADE
- }
-
- var args []string
- if session != nil {
- if err = session.CheckInterfaces("session"); err != nil {
- return
- }
- args = append(args, Args(session, sessionBus)...)
- }
- if system != nil {
- if err = system.CheckInterfaces("system"); err != nil {
- return
- }
- args = append(args, Args(system, systemBus)...)
- }
-
- final = &Final{Session: sessionBus, System: systemBus}
-
- final.WriterTo, err = helper.NewCheckedArgs(args...)
- if err != nil {
- return
- }
-
- if session != nil {
- final.SessionUpstream, err = Parse([]byte(final.Session[0]))
- if err != nil {
- return
- }
- }
- if system != nil {
- final.SystemUpstream, err = Parse([]byte(final.System[0]))
- if err != nil {
- return
- }
- }
-
- return
-}
-
-// New returns a new instance of [Proxy].
-func New(ctx context.Context, msg message.Msg, final *Final, output io.Writer) *Proxy {
- return &Proxy{name: ProxyName, ctx: ctx, msg: msg, final: final, output: output, useSandbox: true}
-}