fix(SubscribeState): add the path to the recieved chan type
also remove the check for the signal to be the current path since this will block us from receiving updates to the actual object before it only signaled on when we deactivated, since the activation happens on another device.
This commit is contained in:
parent
3ba9bbd706
commit
ba0310894b
1 changed files with 4 additions and 2 deletions
|
@ -2,6 +2,7 @@ package gonetworkmanager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/godbus/dbus/v5"
|
"github.com/godbus/dbus/v5"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -220,6 +221,7 @@ func (a *activeConnection) GetPropertyMaster() (Device, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type StateChange struct {
|
type StateChange struct {
|
||||||
|
Path dbus.ObjectPath
|
||||||
State NmActiveConnectionState
|
State NmActiveConnectionState
|
||||||
Reason NmActiveConnectionStateReason
|
Reason NmActiveConnectionStateReason
|
||||||
}
|
}
|
||||||
|
@ -243,17 +245,17 @@ func (a *activeConnection) SubscribeState(receiver chan StateChange, exit chan s
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case signal, ok := <-channel:
|
case signal, ok := <-channel:
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
err = fmt.Errorf("connection closed for %s", ActiveConnectionSignalStateChanged)
|
err = fmt.Errorf("connection closed for %s", ActiveConnectionSignalStateChanged)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if signal.Path != a.GetPath() || signal.Name != ActiveConnectionInterface+"."+ActiveConnectionSignalStateChanged {
|
if signal.Name != ActiveConnectionInterface+"."+ActiveConnectionSignalStateChanged {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
stateChange := StateChange{
|
stateChange := StateChange{
|
||||||
|
Path: signal.Path,
|
||||||
State: NmActiveConnectionState(signal.Body[0].(uint32)),
|
State: NmActiveConnectionState(signal.Body[0].(uint32)),
|
||||||
Reason: NmActiveConnectionStateReason(signal.Body[1].(uint32)),
|
Reason: NmActiveConnectionStateReason(signal.Body[1].(uint32)),
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue