summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/gprs/GPRSrun.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/gprs/GPRSrun.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/gprs/GPRSrun.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/settings/networksettings2/gprs/GPRSrun.cpp b/noncore/settings/networksettings2/gprs/GPRSrun.cpp
index e842b99..cccc71a 100644
--- a/noncore/settings/networksettings2/gprs/GPRSrun.cpp
+++ b/noncore/settings/networksettings2/gprs/GPRSrun.cpp
@@ -2,104 +2,104 @@
2#include <signal.h> 2#include <signal.h>
3#include <errno.h> 3#include <errno.h>
4#include <qdir.h> 4#include <qdir.h>
5#include <system.h> 5#include <system.h>
6#include <resources.h> 6#include <resources.h>
7#include <netnode.h> 7#include <netnode.h>
8#include "GPRSrun.h" 8#include "GPRSrun.h"
9 9
10State_t GPRSRun::detectState( void ) { 10State_t GPRSRun::detectState( void ) {
11 11
12 // is pppd still running ? 12 // is pppd still running ?
13 // is rfcomm still active 13 // is rfcomm still active
14 NodeCollection * NC = nodeCollection(); 14 NodeCollection * NC = nodeCollection();
15 InterfaceInfo * I = NC->assignedInterface(); 15 InterfaceInfo * I = NC->assignedInterface();
16 16
17 QDir D("/var/run"); 17 QDir D("/var/run");
18 18
19 if( I ) { 19 if( I ) {
20 // has some pppx attached 20 // has some pppx attached
21 return ( I->IsUp ) ? IsUp : Available; 21 return ( I->IsUp ) ? IsUp : Available;
22 } 22 }
23 23
24 // check ppp itself and figure out interface 24 // check ppp itself and figure out interface
25 25
26 owarn << "Check for ppp " << NC->name() << oendl; 26 odebug << "Check for ppp " << NC->name() << oendl;
27 if( D.exists( QString("ppp-")+removeSpaces(NC->name())+".pid") ) { 27 if( D.exists( QString("ppp-")+removeSpaces(NC->name())+".pid") ) {
28 // get pid and check if pppd is still running 28 // get pid and check if pppd is still running
29 QFile F( D.path()+"/ppp-"+removeSpaces(NC->name())+".pid"); 29 QFile F( D.path()+"/ppp-"+removeSpaces(NC->name())+".pid");
30 30
31 owarn << "PPP PID " << F.name() << oendl; 31 odebug << "PPP PID " << F.name() << oendl;
32 if( F.open( IO_ReadOnly ) ) { 32 if( F.open( IO_ReadOnly ) ) {
33 QTextStream TS(&F); 33 QTextStream TS(&F);
34 QString X = TS.readLine(); 34 QString X = TS.readLine();
35 PPPPid = X.toULong(); 35 PPPPid = X.toULong();
36 int rv; 36 int rv;
37 37
38 rv = ::kill( PPPPid, 0 ); 38 rv = ::kill( PPPPid, 0 );
39 if( rv == 0 || 39 if( rv == 0 ||
40 ( rv < 0 && errno == EPERM ) 40 ( rv < 0 && errno == EPERM )
41 ) { 41 ) {
42 // pppd is still up 42 // pppd is still up
43 X = TS.readLine(); 43 X = TS.readLine();
44 I = NSResources->system().findInterface(X); 44 I = NSResources->system().findInterface(X);
45 45
46 owarn << "ppp running : IFace " << X << " = " << (long)I << oendl; 46 odebug << "ppp running : IFace " << X << " = " << (long)I << oendl;
47 47
48 if( I ) { 48 if( I ) {
49 NC->assignInterface( I ); 49 NC->assignInterface( I );
50 return (I->IsUp) ? IsUp : Available; 50 return (I->IsUp) ? IsUp : Available;
51 } 51 }
52 52
53 return Available; 53 return Available;
54 54
55 } else { 55 } else {
56 // pppd is down 56 // pppd is down
57 PPPPid = 0; 57 PPPPid = 0;
58 } 58 }
59 } // else pppd is down 59 } // else pppd is down
60 } 60 }
61 NC->assignInterface( 0 ); 61 NC->assignInterface( 0 );
62 return Unknown; 62 return Unknown;
63} 63}
64 64
65QString GPRSRun::setMyState( NodeCollection * NC, Action_t A , bool ) { 65QString GPRSRun::setMyState( NodeCollection * NC, Action_t A , bool ) {
66 66
67 if( A == Up ) { 67 if( A == Up ) {
68 // start ppp on deviceFile 68 // start ppp on deviceFile
69 QStringList SL; 69 QStringList SL;
70 SL << "pon" 70 SL << "pon"
71 << removeSpaces( NC->name() ) 71 << removeSpaces( NC->name() )
72 << NC->device()->deviceFile(); 72 << NC->device()->deviceFile();
73 73
74 if( ! NSResources->system().execAsUser( SL ) ) { 74 if( ! NSResources->system().execAsUser( SL ) ) {
75 return QString("Cannot start pppd for %1").arg(NC->name()); 75 return QString("Cannot start pppd for %1").arg(NC->name());
76 } 76 }
77 } else if ( A == Down ) { 77 } else if ( A == Down ) {
78 if( PPPPid == 0 ) { 78 if( PPPPid == 0 ) {
79 detectState(); 79 detectState();
80 } 80 }
81 if( PPPPid ) { 81 if( PPPPid ) {
82 QStringList SL; 82 QStringList SL;
83 83
84 SL << "poff" 84 SL << "poff"
85 << removeSpaces( NC->name() ); 85 << removeSpaces( NC->name() );
86 86
87 if( ! NSResources->system().execAsUser( SL ) ) { 87 if( ! NSResources->system().execAsUser( SL ) ) {
88 return QString("Cannot terminate pppd for %1").arg(NC->name()); 88 return QString("Cannot terminate pppd for %1").arg(NC->name());
89 } 89 }
90 NC->assignInterface( 0 ); 90 NC->assignInterface( 0 );
91 owarn << "ppp stopped " << oendl; 91 odebug << "ppp stopped " << oendl;
92 PPPPid = 0; 92 PPPPid = 0;
93 } 93 }
94 } 94 }
95 95
96 return QString(); 96 return QString();
97} 97}
98 98
99bool GPRSRun::handlesInterface( const QString & S ) { 99bool GPRSRun::handlesInterface( const QString & S ) {
100 return Pat.match( S ) >= 0; 100 return Pat.match( S ) >= 0;
101} 101}
102 102
103bool GPRSRun::handlesInterface( InterfaceInfo * I ) { 103bool GPRSRun::handlesInterface( InterfaceInfo * I ) {
104 return handlesInterface( I->Name ); 104 return handlesInterface( I->Name );
105} 105}