summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/cable/cablerun.cpp
blob: 85660f61d7e2c677e29955b8d9bba528b62310de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <fcntl.h>
#include <unistd.h>
#include "cablerun.h"

void CableRun::detectState( NodeCollection * NC ) { 

      int fd = open( Data->Device.latin1(), O_RDWR );

      if( fd < 0 ) {
        NC->setCurrentState( Unavailable );
      }
      close( fd );
      NC->setCurrentState( Available );
}

bool CableRun::setState( NodeCollection * NC, Action_t A, bool ) { 
      if( A == Activate ) {
        detectState(NC);
        return (NC->currentState() == Available);
      }
      return 1;
}

bool CableRun::canSetState( State_t , Action_t  ) { 
      return 1;
}

QString CableRun::deviceFile( void ) {
      return Data->Device;
}