Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. NetworkManager StatusChanged D-Bus signal not being received.
Qt 6.11 is out! See what's new in the release blog

NetworkManager StatusChanged D-Bus signal not being received.

Scheduled Pinned Locked Moved Solved General and Desktop
d-busnetworkmanager6.8.3
3 Posts 1 Posters 144 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vaquita Tim
    wrote last edited by
    #1

    I'm trying to put together some code to check the NetworkManager status. The final goal is to run this on an embedded system, but for testing I am running this on Ubuntu 24, where I think it should be working.

    I am trying to connect to the StateChanged D-Bus signal, with the following code :-

    const QString s_NMService( "org.freedesktop.NetworkManager" );
    const QString s_NMObjectPath( "/org/freedesktop/NetworkManager" );
    const QString s_NMInterface( "org.freedesktop.NetworkManager" );
    
    CNetworkManager::CNetworkManager(QObject *parent)
    		: QObject(parent),
    //QDBusInterface's constructor makes a non-obvious blocking call to introspect the D-Bus service
    		m_NM( s_NMService, s_NMObjectPath, s_NMInterface, QDBusConnection::systemBus() )
    {
    	const QVariant VarState( m_NM.property( "State" )  );
    	m_NMState = static_cast<ENMState>( VarState.toUInt() );
    
    	m_bWasConnected = QDBusConnection::systemBus().connect(
    						s_NMService, s_NMObjectPath, s_NMInterface,
    						"StateChanged", "(u)",
    						this, SLOT(SetNMState(uint)) );
    	m_Connect = connect( &m_NM, SIGNAL(StateChanged(uint)), this, SLOT(SetNMState(uint)) );
    
    

    However, my debugger tells me that, although the State is correctly fetched initially, the slot function is not called (it should be called twice, of course, since I tried to connect in 2 different ways).

    I have noticed this so in some sense I am in a better situation ;-)

    Clearly networkmanager is not the problem :-

    ~$ nmcli monitor 
    NetworkManager is running
    enp0s3: deactivating
    enp0s3: disconnected
    There's no primary connection
    Networkmanager is now in the 'connected (local only)' state
    Connectivity is now 'limited'
    enp0s3: using connection 'netplan-enp0s3'
    enp0s3: connecting (prepare)
    Networkmanager is now in the 'connecting' state
    enp0s3: connecting (configuring)
    enp0s3: connecting (getting IP configuration)
    'netplan-enp0s3' is now the primary connection
    enp0s3: connecting (checking IP connectivity)
    enp0s3: connecting (starting secondary connections)
    enp0s3: connected
    Networkmanager is now in the 'connected (site only)' state
    Networkmanager is now in the 'connected' state
    Connectivity is now 'full'
    

    I've checked the names and variable types using D-Feet.

    I also tried running with sudo privileges.

    Now I've run out of ideas.

    Qt v6.8.3

    If anyone with experience can spot my mistake, it would be appreciated, otherwise I will have to revert to the ugly polling option.

    TIA

    Tim

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vaquita Tim
      wrote last edited by
      #2

      I will check to see if it's due to this bug

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vaquita Tim
        wrote last edited by
        #3

        Or, more likely it was the dumb mistake of doing a quick hack for testing, which deleted my test object...

        1 Reply Last reply
        0
        • V Vaquita Tim has marked this topic as solved

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved