Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to go mods and primarily fix the paired state bug #58

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions dbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`
)
Expand Down Expand Up @@ -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
Expand All @@ -93,19 +93,19 @@ 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
}
// kdeconnect >= v1.2
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 {
Expand All @@ -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)
}
Expand All @@ -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:
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
}

Expand Down
22 changes: 0 additions & 22 deletions glide.lock

This file was deleted.

8 changes: 0 additions & 8 deletions glide.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down