From 45959636ff20cb80335c0ca35352ece204bd45b8 Mon Sep 17 00:00:00 2001 From: Talut Salako Date: Wed, 30 Oct 2024 23:07:24 +0100 Subject: [PATCH 1/3] use go modules to handle dependencies --- glide.lock | 22 ---------------------- glide.yaml | 8 -------- go.mod | 15 +++++++++++++++ 3 files changed, 15 insertions(+), 30 deletions(-) delete mode 100644 glide.lock delete mode 100644 glide.yaml create mode 100644 go.mod diff --git a/glide.lock b/glide.lock deleted file mode 100644 index 68d2105..0000000 --- a/glide.lock +++ /dev/null @@ -1,22 +0,0 @@ -hash: 0c65b3581f4f0ed0f3c044adf385a0b4940c76ae4d628e797de54346e9eeb185 -updated: 2020-05-07T08:59:47.973819152+10:00 -imports: -- name: github.com/buger/goterm - version: cc3942e537b1ab00de92d348c40acbfa6565d20f -- name: github.com/godbus/dbus - version: 37bf87eef99d69c4f1d3528bd66e3a87dc201472 - subpackages: - - introspect -- name: github.com/kardianos/osext - version: c2c54e542fb797ad986b31721e1baedf214ca413 -- name: github.com/paulrademacher/climenu - version: a1afbb4e378bf580e7d6bddd826e44e8f64347a1 -- name: github.com/pkg/term - version: b1f72af2d63057363398bec5873d16a98b453312 - subpackages: - - termios -- name: golang.org/x/sys - version: d75a52659825e75fff6158388dddc6a5b04f9ba5 - subpackages: - - unix -testImports: [] diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index 00aa614..0000000 --- a/glide.yaml +++ /dev/null @@ -1,8 +0,0 @@ -package: github.com/pdf/kdeconnect-chrome-extension -import: -- package: github.com/godbus/dbus - version: ^5.0.3 - subpackages: - - introspect -- package: github.com/paulrademacher/climenu -- package: github.com/kardianos/osext diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b6327a4 --- /dev/null +++ b/go.mod @@ -0,0 +1,15 @@ +module github.com/pdf/kdeconnect-chrome-extension + +go 1.23.2 + +require ( + github.com/godbus/dbus v4.1.0+incompatible + github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 + github.com/paulrademacher/climenu v0.0.0-20151110221007-a1afbb4e378b +) + +require ( + github.com/buger/goterm v1.0.4 // indirect + github.com/pkg/term v1.1.0 // indirect + golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54 // indirect +) From 15798e17cc7b71c3234895b240bb3e3b672877bb Mon Sep 17 00:00:00 2001 From: Talut Salako Date: Wed, 30 Oct 2024 23:10:26 +0100 Subject: [PATCH 2/3] use go modules to handle dependencies --- go.sum | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 go.sum diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..4fef2d0 --- /dev/null +++ b/go.sum @@ -0,0 +1,13 @@ +github.com/buger/goterm v1.0.4 h1:Z9YvGmOih81P0FbVtEYTFF6YsSgxSUKEhf/f9bTMXbY= +github.com/buger/goterm v1.0.4/go.mod h1:HiFWV3xnkolgrBV3mY8m0X0Pumt4zg4QhbdOzQtB8tE= +github.com/godbus/dbus v4.1.0+incompatible h1:WqqLRTsQic3apZUK9qC5sGNfXthmPXzUZ7nQPrNITa4= +github.com/godbus/dbus v4.1.0+incompatible/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= +github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= +github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= +github.com/paulrademacher/climenu v0.0.0-20151110221007-a1afbb4e378b h1:k9eCPPZ1mDO+Yql8krekPptU4HeuZUN+sII+yoW9gnY= +github.com/paulrademacher/climenu v0.0.0-20151110221007-a1afbb4e378b/go.mod h1:PqhPeOOa4deGpFrOMVOJkPU4SarvApspr/o4Tp2uPic= +github.com/pkg/term v1.1.0 h1:xIAAdCMh3QIAy+5FrE8Ad8XoDhEU4ufwbaSozViP9kk= +github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw= +golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54 h1:rF3Ohx8DRyl8h2zw9qojyLHLhrJpEMgyPOImREEryf0= +golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= From fd0dad6c54123fab9d6bf1c84e9765d87e6589c3 Mon Sep 17 00:00:00 2001 From: Talut Salako Date: Wed, 30 Oct 2024 23:12:08 +0100 Subject: [PATCH 3/3] fix: use new api for various state tracking --- dbus.go | 34 +++++++++++++++++----------------- main.go | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/dbus.go b/dbus.go index 4585ffe..1aace7b 100644 --- a/dbus.go +++ b/dbus.go @@ -13,11 +13,11 @@ const ( dest = `org.kde.kdeconnect` path = `/modules/kdeconnect` - signalReachableStatusChanged = dest + `.device.reachableStatusChanged` - signalStateChanged = dest + `.device.stateChanged` - signalTrustedChanged = dest + `.device.trustedChanged` - signalNameChanged = dest + `.device.nameChanged` - signalPluginsChanged = dest + `.device.pluginsChanged` + signalReachableChanged = dest + `.device.reachableChanged` + signalStateChanged = dest + `.device.stateChanged` + signalPairStateChanged = dest + `.device.PairStateChanged` + signalNameChanged = dest + `.device.nameChanged` + signalPluginsChanged = dest + `.device.pluginsChanged` pluginShare = `kdeconnect_share` ) @@ -84,7 +84,7 @@ type Device struct { IconName string `json:"iconName"` StatusIconName string `json:"statusIconName"` IsReachable bool `json:"isReachable"` - IsTrusted bool `json:"isTrusted"` + IsPaired bool `json:"isTrusted"` SupportedPlugins map[string]struct{} `json:"supportedPlugins"` conn *dbus.Conn obj dbus.BusObject @@ -93,7 +93,7 @@ type Device struct { } func (d *Device) watch() error { - // kdeconnect < v1.2 + // kdeconnect < v1.2 :(should probably deprecate this entirely) if err := d.addMatchSignal(`reachableStatusChanged`); err != nil { return err } @@ -101,11 +101,11 @@ func (d *Device) watch() error { if err := d.addMatchSignal(`reachableChanged`); err != nil { return err } - + // still trying to find what stateChanged represented and if it the api remains if err := d.addMatchSignal(`stateChanged`); err != nil { return err } - if err := d.addMatchSignal(`trustedChanged`); err != nil { + if err := d.addMatchSignal(`pairStateChanged`); err != nil { return err } if err := d.addMatchSignal(`nameChanged`); err != nil { @@ -120,7 +120,7 @@ func (d *Device) watch() error { for s := range d.signal { var err error switch s.Name { - case signalReachableStatusChanged: + case signalReachableChanged: if err = d.getIsReachable(); err != nil { log(err) } @@ -132,8 +132,8 @@ func (d *Device) watch() error { if err = d.getName(); err != nil { log(err) } - case signalTrustedChanged: - if err = d.getIsTrusted(); err != nil { + case signalPairStateChanged: + if err = d.getIsPaired(); err != nil { log(err) } case signalStateChanged: @@ -218,12 +218,12 @@ func (d *Device) getIsReachable() error { return nil } -func (d *Device) getIsTrusted() error { - v, err := d.obj.GetProperty(dest + `.device.isTrusted`) +func (d *Device) getIsPaired() error { + v, err := d.obj.GetProperty(dest + `.device.isPaired`) if err != nil { return err } - d.IsTrusted = v.Value().(bool) + d.IsPaired = v.Value().(bool) return nil } @@ -257,7 +257,7 @@ func (d *Device) update() error { if err := d.getStatusIconName(); err != nil { logBadProp(d.ID, `statusIconName`, err) } - if err := d.getIsTrusted(); err != nil { + if err := d.getIsPaired(); err != nil { logBadProp(d.ID, `isTrusted`, err) } if err := d.getIsReachable(); err != nil { @@ -286,7 +286,7 @@ func (d *Device) supported(plugin string) error { if !d.IsReachable { return fmt.Errorf("Device is not reachable") } - if !d.IsTrusted { + if !d.IsPaired { return fmt.Errorf("Device is not trusted") } diff --git a/main.go b/main.go index 3142428..e8a1fb6 100644 --- a/main.go +++ b/main.go @@ -142,7 +142,7 @@ func main() { if devicesFlag { for _, dev := range devices.devices { - fmt.Printf("- %s: %s (paired: %v; reachable: %v)\n", dev.Name, dev.ID, dev.IsTrusted, dev.IsReachable) + fmt.Printf("- %s: %s (paired: %v; reachable: %v)\n", dev.Name, dev.ID, dev.IsPaired, dev.IsReachable) } os.Exit(0) }