summaryrefslogtreecommitdiff
path: root/noncore/settings
authorwimpie <wimpie>2004-08-12 12:46:55 (UTC)
committer wimpie <wimpie>2004-08-12 12:46:55 (UTC)
commit8f215ba9ceb395f262517855a99d7d2d303ca760 (patch) (unidiff)
treeaa5f9b14c249217b4d3fc30f4771bdaf1c3545d3 /noncore/settings
parentef64880308b5035cc8ca2e4e79325db613af525b (diff)
downloadopie-8f215ba9ceb395f262517855a99d7d2d303ca760.zip
opie-8f215ba9ceb395f262517855a99d7d2d303ca760.tar.gz
opie-8f215ba9ceb395f262517855a99d7d2d303ca760.tar.bz2
MANY changes
- now generates peers/pap-chap secrets files (no chatscript yet) (not all usefull ppp options included yet) - still not ready for prime time yet
Diffstat (limited to 'noncore/settings') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp8
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h14
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp8
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h14
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h3
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp38
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetooth_NN.h57
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.cpp11
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.h26
-rw-r--r--noncore/settings/networksettings2/cable/cable_NNI.cpp30
-rw-r--r--noncore/settings/networksettings2/cable/cable_NNI.h20
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.cpp6
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.h8
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.cpp11
-rw-r--r--noncore/settings/networksettings2/irda/irda_NN.h26
-rw-r--r--noncore/settings/networksettings2/irda/irda_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/irda/irda_NNI.h16
-rw-r--r--noncore/settings/networksettings2/irda/irdarun.h3
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.cpp23
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NN.h17
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/lancard/lancard_NNI.h15
-rw-r--r--noncore/settings/networksettings2/main.cpp16
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.cpp11
-rw-r--r--noncore/settings/networksettings2/modem/modem_NN.h8
-rw-r--r--noncore/settings/networksettings2/modem/modem_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/modem/modem_NNI.h16
-rw-r--r--noncore/settings/networksettings2/modem/modemrun.h3
-rw-r--r--noncore/settings/networksettings2/network/network_NN.cpp42
-rw-r--r--noncore/settings/networksettings2/network/network_NN.h31
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.cpp122
-rw-r--r--noncore/settings/networksettings2/network/network_NNI.h19
-rw-r--r--noncore/settings/networksettings2/networksettings.cpp52
-rw-r--r--noncore/settings/networksettings2/networksettings.h3
-rw-r--r--noncore/settings/networksettings2/networksettings.pro3
-rw-r--r--noncore/settings/networksettings2/networksettings2/Utils.h1
-rw-r--r--noncore/settings/networksettings2/networksettings2/asline.h2
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.cpp23
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h460
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp13
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h5
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp18
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.cpp30
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.h11
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp476
-rw-r--r--noncore/settings/networksettings2/nsdata.h11
-rw-r--r--noncore/settings/networksettings2/ppp/PPPAuthGUI.ui158
-rw-r--r--noncore/settings/networksettings2/ppp/PPPAuthedit.cpp42
-rw-r--r--noncore/settings/networksettings2/ppp/PPPAuthedit.h2
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.cpp31
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NN.h31
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.cpp108
-rw-r--r--noncore/settings/networksettings2/ppp/ppp_NNI.h21
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.cpp13
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.h8
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.cpp27
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.h23
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.cpp23
-rw-r--r--noncore/settings/networksettings2/usb/usb_NN.h7
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.cpp35
-rw-r--r--noncore/settings/networksettings2/usb/usb_NNI.h18
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.cpp14
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NN.h8
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NNI.cpp6
-rw-r--r--noncore/settings/networksettings2/vpn/vpn_NNI.h16
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.cpp23
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NN.h9
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.cpp107
-rw-r--r--noncore/settings/networksettings2/wlan/wlan_NNI.h20
69 files changed, 1308 insertions, 1190 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp
index d8420b9..398dcdc 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.cpp
@@ -31,20 +31,12 @@ QWidget * ABluetoothBNEP::edit( QWidget * parent ) {
31 GUI->showData( Data ); 31 GUI->showData( Data );
32 return GUI; 32 return GUI;
33} 33}
34 34
35QString ABluetoothBNEP::acceptable( void ) { 35QString ABluetoothBNEP::acceptable( void ) {
36 return ( GUI ) ? GUI->acceptable( ) : QString(); 36 return ( GUI ) ? GUI->acceptable( ) : QString();
37} 37}
38 38
39void ABluetoothBNEP::commit( void ) { 39void ABluetoothBNEP::commit( void ) {
40 if( GUI && GUI->commit( Data ) ) 40 if( GUI && GUI->commit( Data ) )
41 setModified( 1 ); 41 setModified( 1 );
42} 42}
43
44bool ABluetoothBNEP::hasDataFor( const QString & ) {
45 return 0;
46}
47
48bool ABluetoothBNEP::generateDataForCommonFile( SystemFile & , long ){
49 return 0;
50}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h
index bb3e7e7..1bf0f48 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NNI.h
@@ -5,40 +5,36 @@
5#include "bluetoothBNEPdata.h" 5#include "bluetoothBNEPdata.h"
6#include "bluetoothBNEPrun.h" 6#include "bluetoothBNEPrun.h"
7 7
8class BluetoothBNEPNetNode; 8class BluetoothBNEPNetNode;
9class BluetoothBNEPEdit; 9class BluetoothBNEPEdit;
10 10
11class ABluetoothBNEP : public ANetNodeInstance { 11class ABluetoothBNEP : public ANetNodeInstance {
12 12
13public : 13public :
14 14
15 ABluetoothBNEP( BluetoothBNEPNetNode * PNN ); 15 ABluetoothBNEP( BluetoothBNEPNetNode * PNN );
16 16
17 RuntimeInfo * runtime( void )
18 { return
19 ( RT ) ? RT : ( RT = new BluetoothBNEPRun( this, Data ) );
20 }
21
17 QWidget * edit( QWidget * parent ); 22 QWidget * edit( QWidget * parent );
18 QString acceptable( void ); 23 QString acceptable( void );
19 void commit( void ); 24 void commit( void );
20 25
21 RuntimeInfo * runtime( void )
22 { if( RT == 0 )
23 RT = new BluetoothBNEPRun( this, Data );
24 return RT;
25 }
26
27 virtual void * data( void ) 26 virtual void * data( void )
28 { return (void *)&Data; } 27 { return (void *)&Data; }
29 28
30 virtual bool hasDataFor( const QString & S );
31 virtual bool generateDataForCommonFile( SystemFile & SF, long );
32
33protected : 29protected :
34 30
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 31 virtual void setSpecificAttribute( QString & Attr, QString & Value );
36 virtual void saveSpecificAttribute( QTextStream & TS ); 32 virtual void saveSpecificAttribute( QTextStream & TS );
37 33
38private : 34private :
39 35
40 BluetoothBNEPEdit * GUI; 36 BluetoothBNEPEdit * GUI;
41 BluetoothBNEPData Data; 37 BluetoothBNEPData Data;
42 BluetoothBNEPRun * RT; 38 BluetoothBNEPRun * RT;
43 39
44}; 40};
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp
index cff2639..7ec8288 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.cpp
@@ -19,20 +19,12 @@ QWidget * ABluetoothRFCOMM::edit( QWidget * parent ) {
19 GUI->showData( Data ); 19 GUI->showData( Data );
20 return GUI; 20 return GUI;
21} 21}
22 22
23QString ABluetoothRFCOMM::acceptable( void ) { 23QString ABluetoothRFCOMM::acceptable( void ) {
24 return ( GUI ) ? GUI->acceptable( ) : QString(); 24 return ( GUI ) ? GUI->acceptable( ) : QString();
25} 25}
26 26
27void ABluetoothRFCOMM::commit( void ) { 27void ABluetoothRFCOMM::commit( void ) {
28 if( GUI->commit( Data ) ) 28 if( GUI->commit( Data ) )
29 setModified( 1 ); 29 setModified( 1 );
30} 30}
31
32bool ABluetoothRFCOMM::hasDataFor( const QString & ) {
33 return 0;
34}
35
36bool ABluetoothRFCOMM::generateDataForCommonFile( SystemFile & , long ){
37 return 0;
38}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h
index 97bd29c..820fc17 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMM_NNI.h
@@ -5,40 +5,36 @@
5#include "bluetoothRFCOMMdata.h" 5#include "bluetoothRFCOMMdata.h"
6#include "bluetoothRFCOMMrun.h" 6#include "bluetoothRFCOMMrun.h"
7 7
8class BluetoothRFCOMMNetNode; 8class BluetoothRFCOMMNetNode;
9class BluetoothRFCOMMEdit; 9class BluetoothRFCOMMEdit;
10 10
11class ABluetoothRFCOMM : public ANetNodeInstance { 11class ABluetoothRFCOMM : public ANetNodeInstance {
12 12
13public : 13public :
14 14
15 ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN ); 15 ABluetoothRFCOMM( BluetoothRFCOMMNetNode * PNN );
16 16
17 RuntimeInfo * runtime( void )
18 { return
19 ( RT ) ? RT : ( RT = new BluetoothRFCOMMRun( this, Data ) );
20 }
21
17 QWidget * edit( QWidget * parent ); 22 QWidget * edit( QWidget * parent );
18 QString acceptable( void ); 23 QString acceptable( void );
19 void commit( void ); 24 void commit( void );
20 25
21 RuntimeInfo * runtime( void )
22 { if( RT == 0 )
23 RT = new BluetoothRFCOMMRun( this, Data );
24 return RT;
25 }
26
27 virtual void * data( void ) 26 virtual void * data( void )
28 { return (void *)&Data; } 27 { return (void *)&Data; }
29 28
30 virtual bool hasDataFor( const QString & S );
31 virtual bool generateDataForCommonFile( SystemFile & SF, long );
32
33protected : 29protected :
34 30
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 31 virtual void setSpecificAttribute( QString & Attr, QString & Value );
36 virtual void saveSpecificAttribute( QTextStream & TS ); 32 virtual void saveSpecificAttribute( QTextStream & TS );
37 33
38private : 34private :
39 35
40 BluetoothRFCOMMEdit * GUI; 36 BluetoothRFCOMMEdit * GUI;
41 BluetoothRFCOMMData Data; 37 BluetoothRFCOMMData Data;
42 BluetoothRFCOMMRun * RT; 38 BluetoothRFCOMMRun * RT;
43}; 39};
44 40
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
index aff1f59..65fd686 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.h
@@ -3,23 +3,26 @@
3 3
4class BluetoothRFCOMMRun : public AsLine { 4class BluetoothRFCOMMRun : public AsLine {
5 5
6public : 6public :
7 7
8 BluetoothRFCOMMRun( ANetNodeInstance * NNI, 8 BluetoothRFCOMMRun( ANetNodeInstance * NNI,
9 BluetoothRFCOMMData & Data ) : AsLine( NNI ) 9 BluetoothRFCOMMData & Data ) : AsLine( NNI )
10 { } 10 { }
11 11
12 virtual AsLine * asLine( void ) 12 virtual AsLine * asLine( void )
13 { return (AsLine *)this; } 13 { return (AsLine *)this; }
14 14
15 virtual QString deviceFile( void )
16 { return QString( "/dev/rfcomm..." ); }
17
15protected : 18protected :
16 19
17 void detectState( NodeCollection * ) 20 void detectState( NodeCollection * )
18 { } 21 { }
19 22
20 bool setState( NodeCollection * , Action_t, bool ) 23 bool setState( NodeCollection * , Action_t, bool )
21 { return 0; } 24 { return 0; }
22 25
23 bool canSetState( State_t , Action_t ) 26 bool canSetState( State_t , Action_t )
24 { return 0; } 27 { return 0; }
25}; 28};
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
index b59b4f0..443a627 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.cpp
@@ -37,47 +37,24 @@ const QString BluetoothBNEPNetNode::nodeDescription(){
37ANetNodeInstance * BluetoothBNEPNetNode::createInstance( void ) { 37ANetNodeInstance * BluetoothBNEPNetNode::createInstance( void ) {
38 return new ABluetoothBNEP( this ); 38 return new ABluetoothBNEP( this );
39} 39}
40 40
41const char ** BluetoothBNEPNetNode::needs( void ) { 41const char ** BluetoothBNEPNetNode::needs( void ) {
42 return BluetoothBNEPNeeds; 42 return BluetoothBNEPNeeds;
43} 43}
44 44
45const char * BluetoothBNEPNetNode::provides( void ) { 45const char * BluetoothBNEPNetNode::provides( void ) {
46 return "device"; 46 return "device";
47} 47}
48 48
49bool BluetoothBNEPNetNode::generateProperFilesFor(
50 ANetNodeInstance * ) {
51 return 0;
52}
53
54bool BluetoothBNEPNetNode::hasDataFor( const QString & S ) {
55 return S == "interfaces";
56}
57
58bool BluetoothBNEPNetNode::generateDeviceDataForCommonFile(
59 SystemFile & S ,
60 long DevNr) {
61 QString NIC = genNic( DevNr );
62
63 if( S.name() == "interfaces" ) {
64 // generate mapping stanza for this interface
65 S << "# check if " << NIC << " can be brought UP" << endl;
66 S << "mapping " << NIC << endl;
67 S << " script networksettings2-request" << endl << endl;
68 }
69 return 0;
70}
71
72QString BluetoothBNEPNetNode::genNic( long nr ) { 49QString BluetoothBNEPNetNode::genNic( long nr ) {
73 QString S; 50 QString S;
74 return S.sprintf( "bnep%ld", nr ); 51 return S.sprintf( "bnep%ld", nr );
75} 52}
76 53
77 54
78void BluetoothBNEPNetNode::setSpecificAttribute( QString & A, QString & V ) { 55void BluetoothBNEPNetNode::setSpecificAttribute( QString & A, QString & V ) {
79 if( A == "interfacecount" ) { 56 if( A == "interfacecount" ) {
80 InstanceCount = V.toLong(); 57 InstanceCount = V.toLong();
81 } 58 }
82} 59}
83 60
@@ -115,39 +92,24 @@ const QString BluetoothRFCOMMNetNode::nodeDescription(){
115ANetNodeInstance * BluetoothRFCOMMNetNode::createInstance( void ) { 92ANetNodeInstance * BluetoothRFCOMMNetNode::createInstance( void ) {
116 return new ABluetoothRFCOMM( this ); 93 return new ABluetoothRFCOMM( this );
117} 94}
118 95
119const char ** BluetoothRFCOMMNetNode::needs( void ) { 96const char ** BluetoothRFCOMMNetNode::needs( void ) {
120 return BluetoothRFCOMMNeeds; 97 return BluetoothRFCOMMNeeds;
121} 98}
122 99
123const char * BluetoothRFCOMMNetNode::provides( void ) { 100const char * BluetoothRFCOMMNetNode::provides( void ) {
124 return "line"; 101 return "line";
125} 102}
126 103
127bool BluetoothRFCOMMNetNode::generateProperFilesFor(
128 ANetNodeInstance * ) {
129 return 0;
130}
131
132bool BluetoothRFCOMMNetNode::hasDataFor( const QString & ) {
133 return 0;
134}
135
136bool BluetoothRFCOMMNetNode::generateDeviceDataForCommonFile(
137 SystemFile & ,
138 long ) {
139 return 0;
140}
141
142void BluetoothRFCOMMNetNode::setSpecificAttribute( QString &, QString & ) { 104void BluetoothRFCOMMNetNode::setSpecificAttribute( QString &, QString & ) {
143} 105}
144 106
145void BluetoothRFCOMMNetNode::saveSpecificAttribute( QTextStream & ) { 107void BluetoothRFCOMMNetNode::saveSpecificAttribute( QTextStream & ) {
146} 108}
147 109
148extern "C" { 110extern "C" {
149void create_plugin( QList<ANetNode> & PNN ) { 111void create_plugin( QList<ANetNode> & PNN ) {
150 PNN.append( new BluetoothBNEPNetNode() ); 112 PNN.append( new BluetoothBNEPNetNode() );
151 PNN.append( new BluetoothRFCOMMNetNode() ); 113 PNN.append( new BluetoothRFCOMMNetNode() );
152} 114}
153} 115}
diff --git a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
index 2e5e1d2..4d6a3c1 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
+++ b/noncore/settings/networksettings2/bluetooth/bluetooth_NN.h
@@ -1,80 +1,65 @@
1#ifndef BLUETOOTH_NETNODE_H 1#ifndef BLUETOOTH_NETNODE_H
2#define BLUETOOTH_NETNODE_H 2#define BLUETOOTH_NETNODE_H
3 3
4#include "netnode.h" 4#include "netnode.h"
5 5
6class ABluetoothBNEP; 6class ABluetoothBNEP;
7 7
8class BluetoothBNEPNetNode : public ANetNode { 8class BluetoothBNEPNetNode : public ANetNode {
9 9
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 13
14 BluetoothBNEPNetNode(); 14 BluetoothBNEPNetNode();
15 virtual ~BluetoothBNEPNetNode(); 15 virtual ~BluetoothBNEPNetNode();
16 16
17 virtual const QString pixmapName() 17 virtual QString genNic( long );
18 { return "Devices/bluetooth"; } 18 virtual long instanceCount( void )
19 { return InstanceCount; }
20 virtual const QString pixmapName()
21 { return "Devices/bluetooth"; }
19 22
20 virtual const QString nodeDescription() ; 23 virtual const QString nodeDescription() ;
21 24 virtual ANetNodeInstance * createInstance( void );
22 virtual ANetNodeInstance * createInstance( void ); 25 virtual const char * provides( void );
23 26 virtual const char ** needs( void );
24 virtual const char ** needs( void );
25 virtual const char * provides( void );
26
27 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
28 virtual bool hasDataFor( const QString & S );
29 virtual bool generateDeviceDataForCommonFile(
30 SystemFile & , long DevNr );
31
32 virtual long instanceCount( void )
33 { return InstanceCount; }
34 virtual QString genNic( long );
35 27
36private: 28private:
37 29
38 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 30 virtual void setSpecificAttribute( QString & Attr, QString & Value );
39 virtual void saveSpecificAttribute( QTextStream & TS ); 31 virtual void saveSpecificAttribute( QTextStream & TS );
40 32
41 // number of interfaces for this device 33 // number of interfaces for this device
42 long InstanceCount; 34 long InstanceCount;
43 35
44}; 36};
45 37
46class BluetoothRFCOMMNetNode : public ANetNode { 38class BluetoothRFCOMMNetNode : public ANetNode {
47 39
48 Q_OBJECT 40 Q_OBJECT
49 41
50public: 42public:
51 43
52 BluetoothRFCOMMNetNode(); 44 BluetoothRFCOMMNetNode();
53 virtual ~BluetoothRFCOMMNetNode(); 45 virtual ~BluetoothRFCOMMNetNode();
54
55 virtual const QString pixmapName()
56 { return "Devices/bluetooth"; }
57
58 virtual const QString nodeDescription() ;
59
60 virtual ANetNodeInstance * createInstance( void );
61 46
62 virtual const char ** needs( void ); 47 virtual const QString pixmapName()
63 virtual const char * provides( void ); 48 { return "Devices/bluetooth"; }
64 49
65 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 50 virtual const QString nodeDescription() ;
66 virtual bool hasDataFor( const QString & S ); 51 virtual ANetNodeInstance * createInstance( void );
67 virtual bool generateDeviceDataForCommonFile( 52 virtual const char ** needs( void );
68 SystemFile & , long ); 53 virtual const char * provides( void );
69 54
70private: 55private:
71 56
72 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 57 virtual void setSpecificAttribute( QString & Attr, QString & Value );
73 virtual void saveSpecificAttribute( QTextStream & TS ); 58 virtual void saveSpecificAttribute( QTextStream & TS );
74}; 59};
75 60
76extern "C" 61extern "C"
77{ 62{
78 void create_plugin( QList<ANetNode> & PNN ); 63 void create_plugin( QList<ANetNode> & PNN );
79}; 64};
80 65
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp
index b8c690b..38568df 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NN.cpp
@@ -27,34 +27,23 @@ const QString CableNetNode::nodeDescription(){
27ANetNodeInstance * CableNetNode::createInstance( void ) { 27ANetNodeInstance * CableNetNode::createInstance( void ) {
28 return new ACable( this ); 28 return new ACable( this );
29} 29}
30 30
31const char ** CableNetNode::needs( void ) { 31const char ** CableNetNode::needs( void ) {
32 return CableNeeds; 32 return CableNeeds;
33} 33}
34 34
35const char * CableNetNode::provides( void ) { 35const char * CableNetNode::provides( void ) {
36 return "line"; 36 return "line";
37} 37}
38 38
39bool CableNetNode::generateProperFilesFor(
40 ANetNodeInstance * ) {
41 return 0;
42}
43
44bool CableNetNode::generateDeviceDataForCommonFile(
45 SystemFile & ,
46 long ) {
47 return 0;
48}
49
50void CableNetNode::setSpecificAttribute( QString & , QString & ) { 39void CableNetNode::setSpecificAttribute( QString & , QString & ) {
51} 40}
52 41
53void CableNetNode::saveSpecificAttribute( QTextStream & ) { 42void CableNetNode::saveSpecificAttribute( QTextStream & ) {
54} 43}
55 44
56extern "C" { 45extern "C" {
57void create_plugin( QList<ANetNode> & PNN ) { 46void create_plugin( QList<ANetNode> & PNN ) {
58 PNN.append( new CableNetNode() ); 47 PNN.append( new CableNetNode() );
59} 48}
60} 49}
diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h
index c48037a..5cc2b2d 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.h
+++ b/noncore/settings/networksettings2/cable/cable_NN.h
@@ -1,43 +1,35 @@
1#ifndef CABLE_NETNODE_H 1#ifndef CABLE_NETNODE_H
2#define CABLE_NETNODE_H 2#define CABLE_NETNODE_H
3 3
4#include "netnode.h" 4#include "netnode.h"
5 5
6class ACable; 6class ACable;
7 7
8class CableNetNode : public ANetNode { 8class CableNetNode : public ANetNode {
9 9
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 13
14 CableNetNode(); 14 CableNetNode();
15 virtual ~CableNetNode(); 15 virtual ~CableNetNode();
16 16
17 virtual const QString pixmapName() 17 virtual const QString pixmapName()
18 { return "Devices/cable"; } 18 { return "Devices/cable"; }
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 21 virtual ANetNodeInstance * createInstance( void );
22 virtual ANetNodeInstance * createInstance( void ); 22 virtual const char ** needs( void );
23 23 virtual const char * provides( void );
24 virtual const char ** needs( void );
25 virtual const char * provides( void );
26
27 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
28 virtual bool hasDataFor( const QString & )
29 { return 0; }
30 virtual bool generateDeviceDataForCommonFile(
31 SystemFile & SF, long DevNr);
32 24
33private: 25private:
34 26
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
36 virtual void saveSpecificAttribute( QTextStream & TS ); 28 virtual void saveSpecificAttribute( QTextStream & TS );
37}; 29};
38 30
39extern "C" 31extern "C"
40{ 32{
41 void create_plugin( QList<ANetNode> & PNN ); 33 void create_plugin( QList<ANetNode> & PNN );
42}; 34};
43 35
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.cpp b/noncore/settings/networksettings2/cable/cable_NNI.cpp
index ca21135..4bd9421 100644
--- a/noncore/settings/networksettings2/cable/cable_NNI.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NNI.cpp
@@ -40,34 +40,50 @@ void ACable::saveSpecificAttribute( QTextStream & TS ) {
40 TS << "device=" << quote( Data.Device ) << endl; 40 TS << "device=" << quote( Data.Device ) << endl;
41 TS << "lockfile=" << quote( Data.LockFile ) << endl; 41 TS << "lockfile=" << quote( Data.LockFile ) << endl;
42 TS << "speed=" << Data.Speed << endl; 42 TS << "speed=" << Data.Speed << endl;
43 TS << "parity=" << Data.Parity << endl; 43 TS << "parity=" << Data.Parity << endl;
44 TS << "databits=" << Data.DataBits << endl; 44 TS << "databits=" << Data.DataBits << endl;
45 TS << "stopbits=" << Data.StopBits << endl; 45 TS << "stopbits=" << Data.StopBits << endl;
46 TS << "hardwarecontrol=" << 46 TS << "hardwarecontrol=" <<
47 ((Data.HardwareControl) ? "yes" : "no") << endl; 47 ((Data.HardwareControl) ? "yes" : "no") << endl;
48 TS << "softwarecontrol=" << 48 TS << "softwarecontrol=" <<
49 ((Data.SoftwareControl) ? "yes" : "no") << endl; 49 ((Data.SoftwareControl) ? "yes" : "no") << endl;
50} 50}
51 51
52short ACable::generateFileEmbedded( const QString & ID,
53 const QString & Path,
54 QTextStream & TS,
55 long DevNr ) {
56 short rvl, rvd;
57
58 rvl = 1;
59 if( ID == "peers" ) {
60 TS << Data.Device
61 << endl;
62 TS << Data.Speed
63 << endl;
64 TS << "lock "
65 << Data.LockFile
66 << endl;
67 rvl = 0;
68 }
69
70 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr );
71 return (rvd == 2 || rvl == 2 ) ? 2 :
72 (rvd == 0 || rvl == 0 ) ? 0 : 1;
73}
74
52QWidget * ACable::edit( QWidget * parent ) { 75QWidget * ACable::edit( QWidget * parent ) {
53 GUI = new CableEdit( parent ); 76 GUI = new CableEdit( parent );
54 GUI->showData( Data ); 77 GUI->showData( Data );
55 return GUI; 78 return GUI;
56} 79}
57 80
58QString ACable::acceptable( void ) { 81QString ACable::acceptable( void ) {
59 return ( GUI ) ? GUI->acceptable( ) : QString(); 82 return ( GUI ) ? GUI->acceptable( ) : QString();
60} 83}
61 84
62void ACable::commit( void ) { 85void ACable::commit( void ) {
63 if( GUI && GUI->commit( Data ) ) { 86 if( GUI && GUI->commit( Data ) ) {
64 setModified( 1 ); 87 setModified( 1 );
65 } 88 }
66} 89}
67
68bool ACable::generateDataForCommonFile(
69 SystemFile & ,
70 long ) {
71 return 1;
72}
73
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.h b/noncore/settings/networksettings2/cable/cable_NNI.h
index bf3e292..d06cbbe 100644
--- a/noncore/settings/networksettings2/cable/cable_NNI.h
+++ b/noncore/settings/networksettings2/cable/cable_NNI.h
@@ -5,42 +5,40 @@
5#include "cabledata.h" 5#include "cabledata.h"
6#include "cablerun.h" 6#include "cablerun.h"
7 7
8class CableNetNode; 8class CableNetNode;
9class CableEdit; 9class CableEdit;
10 10
11class ACable : public ANetNodeInstance { 11class ACable : public ANetNodeInstance {
12 12
13public : 13public :
14 14
15 ACable( CableNetNode * PNN ); 15 ACable( CableNetNode * PNN );
16 16
17 RuntimeInfo * runtime( void )
18 { return
19 ( RT ) ? RT : ( RT = new CableRun( this, Data ) );
20 }
21
17 QWidget * edit( QWidget * parent ); 22 QWidget * edit( QWidget * parent );
18 QString acceptable( void ); 23 QString acceptable( void );
19 void commit( void ); 24 void commit( void );
20 25
21 RuntimeInfo * runtime( void )
22 { if( RT == 0 )
23 RT = new CableRun( this, Data );
24 return RT;
25 }
26
27 virtual void * data( void ) 26 virtual void * data( void )
28 { return (void *)&Data; } 27 { return (void *)&Data; }
29 28
30 virtual bool hasDataFor( const QString & ) 29 short generateFileEmbedded( const QString & ID,
31 { return 0; } 30 const QString & Path,
32 virtual bool generateDataForCommonFile( 31 QTextStream & TS,
33 SystemFile & SF, long DevNr ); 32 long DevNr );
34
35protected : 33protected :
36 34
37 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 35 virtual void setSpecificAttribute( QString & Attr, QString & Value );
38 virtual void saveSpecificAttribute( QTextStream & TS ); 36 virtual void saveSpecificAttribute( QTextStream & TS );
39 37
40private : 38private :
41 39
42 CableEdit * GUI; 40 CableEdit * GUI;
43 CableData_t Data; 41 CableData_t Data;
44 CableRun * RT; 42 CableRun * RT;
45 43
46}; 44};
diff --git a/noncore/settings/networksettings2/cable/cablerun.cpp b/noncore/settings/networksettings2/cable/cablerun.cpp
index 5e99237..85660f6 100644
--- a/noncore/settings/networksettings2/cable/cablerun.cpp
+++ b/noncore/settings/networksettings2/cable/cablerun.cpp
@@ -1,26 +1,30 @@
1#include <fcntl.h> 1#include <fcntl.h>
2#include <unistd.h> 2#include <unistd.h>
3#include "cablerun.h" 3#include "cablerun.h"
4 4
5void CableRun::detectState( NodeCollection * NC ) { 5void CableRun::detectState( NodeCollection * NC ) {
6 6
7 int fd = open( D->Device.latin1(), O_RDWR ); 7 int fd = open( Data->Device.latin1(), O_RDWR );
8 8
9 if( fd < 0 ) { 9 if( fd < 0 ) {
10 NC->setCurrentState( Unavailable ); 10 NC->setCurrentState( Unavailable );
11 } 11 }
12 close( fd ); 12 close( fd );
13 NC->setCurrentState( Available ); 13 NC->setCurrentState( Available );
14} 14}
15 15
16bool CableRun::setState( NodeCollection * NC, Action_t A, bool ) { 16bool CableRun::setState( NodeCollection * NC, Action_t A, bool ) {
17 if( A == Activate ) { 17 if( A == Activate ) {
18 detectState(NC); 18 detectState(NC);
19 return (NC->currentState() == Available); 19 return (NC->currentState() == Available);
20 } 20 }
21 return 1; 21 return 1;
22} 22}
23 23
24bool CableRun::canSetState( State_t , Action_t ) { 24bool CableRun::canSetState( State_t , Action_t ) {
25 return 1; 25 return 1;
26} 26}
27
28QString CableRun::deviceFile( void ) {
29 return Data->Device;
30}
diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h
index c5b59d5..20608f6 100644
--- a/noncore/settings/networksettings2/cable/cablerun.h
+++ b/noncore/settings/networksettings2/cable/cablerun.h
@@ -1,24 +1,26 @@
1#include <asline.h> 1#include <asline.h>
2#include "cabledata.h" 2#include "cabledata.h"
3 3
4class CableRun : public AsLine { 4class CableRun : public AsLine {
5 5
6public : 6public :
7 7
8 CableRun( ANetNodeInstance * NNI, 8 CableRun( ANetNodeInstance * NNI,
9 CableData & Data ) : AsLine( NNI ) 9 CableData_t & D ) : AsLine( NNI )
10 { D = &Data; } 10 { Data = &D; }
11 11
12 virtual AsLine * asLine( void ) 12 virtual AsLine * asLine( void )
13 { return (AsLine *)this; } 13 { return (AsLine *)this; }
14 14
15 virtual QString deviceFile( void );
16
15protected : 17protected :
16 18
17 void detectState( NodeCollection * NC ); 19 void detectState( NodeCollection * NC );
18 bool setState( NodeCollection * NC, Action_t A, bool Force ); 20 bool setState( NodeCollection * NC, Action_t A, bool Force );
19 bool canSetState( State_t Curr, Action_t A ); 21 bool canSetState( State_t Curr, Action_t A );
20 22
21private : 23private :
22 24
23 CableData_t * D; 25 CableData_t * Data;
24}; 26};
diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp
index 49bc06e..9483e22 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.cpp
+++ b/noncore/settings/networksettings2/irda/irda_NN.cpp
@@ -27,34 +27,23 @@ const QString IRDANetNode::nodeDescription(){
27ANetNodeInstance * IRDANetNode::createInstance( void ) { 27ANetNodeInstance * IRDANetNode::createInstance( void ) {
28 return new AIRDA( this ); 28 return new AIRDA( this );
29} 29}
30 30
31const char ** IRDANetNode::needs( void ) { 31const char ** IRDANetNode::needs( void ) {
32 return IRDANeeds; 32 return IRDANeeds;
33} 33}
34 34
35const char * IRDANetNode::provides( void ) { 35const char * IRDANetNode::provides( void ) {
36 return "line"; 36 return "line";
37} 37}
38 38
39bool IRDANetNode::generateProperFilesFor(
40 ANetNodeInstance * ) {
41 return 0;
42}
43
44bool IRDANetNode::generateDeviceDataForCommonFile(
45 SystemFile & ,
46 long ) {
47 return 0;
48}
49
50void IRDANetNode::setSpecificAttribute( QString & , QString & ) { 39void IRDANetNode::setSpecificAttribute( QString & , QString & ) {
51} 40}
52 41
53void IRDANetNode::saveSpecificAttribute( QTextStream & ) { 42void IRDANetNode::saveSpecificAttribute( QTextStream & ) {
54} 43}
55 44
56extern "C" { 45extern "C" {
57void create_plugin( QList<ANetNode> & PNN ) { 46void create_plugin( QList<ANetNode> & PNN ) {
58 PNN.append( new IRDANetNode() ); 47 PNN.append( new IRDANetNode() );
59} 48}
60} 49}
diff --git a/noncore/settings/networksettings2/irda/irda_NN.h b/noncore/settings/networksettings2/irda/irda_NN.h
index fa6408d..900bbc6 100644
--- a/noncore/settings/networksettings2/irda/irda_NN.h
+++ b/noncore/settings/networksettings2/irda/irda_NN.h
@@ -1,43 +1,35 @@
1#ifndef IRDA_NETNODE_H 1#ifndef IRDA_NETNODE_H
2#define IRDA_NETNODE_H 2#define IRDA_NETNODE_H
3 3
4#include "netnode.h" 4#include "netnode.h"
5 5
6class AIRDA; 6class AIRDA;
7 7
8class IRDANetNode : public ANetNode { 8class IRDANetNode : public ANetNode {
9 9
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 13
14 IRDANetNode(); 14 IRDANetNode();
15 virtual ~IRDANetNode(); 15 virtual ~IRDANetNode();
16 16
17 virtual const QString pixmapName() 17 virtual const QString pixmapName()
18 { return "Devices/irda"; } 18 { return "Devices/irda"; }
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 21 virtual ANetNodeInstance * createInstance( void );
22 virtual ANetNodeInstance * createInstance( void ); 22 virtual const char ** needs( void );
23 23 virtual const char * provides( void );
24 virtual const char ** needs( void );
25 virtual const char * provides( void );
26
27 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
28 virtual bool hasDataFor( const QString & )
29 { return 0; }
30 virtual bool generateDeviceDataForCommonFile(
31 SystemFile & SF, long DevNr );
32 24
33private: 25private:
34 26
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
36 virtual void saveSpecificAttribute( QTextStream & TS ); 28 virtual void saveSpecificAttribute( QTextStream & TS );
37}; 29};
38 30
39extern "C" 31extern "C"
40{ 32{
41 void create_plugin( QList<ANetNode> & PNN ); 33 void create_plugin( QList<ANetNode> & PNN );
42}; 34};
43 35
diff --git a/noncore/settings/networksettings2/irda/irda_NNI.cpp b/noncore/settings/networksettings2/irda/irda_NNI.cpp
index f00a1d5..9cf443b 100644
--- a/noncore/settings/networksettings2/irda/irda_NNI.cpp
+++ b/noncore/settings/networksettings2/irda/irda_NNI.cpp
@@ -20,18 +20,12 @@ QWidget * AIRDA::edit( QWidget * parent ) {
20 return GUI; 20 return GUI;
21} 21}
22 22
23QString AIRDA::acceptable( void ) { 23QString AIRDA::acceptable( void ) {
24 return ( GUI ) ? GUI->acceptable( ) : QString(); 24 return ( GUI ) ? GUI->acceptable( ) : QString();
25} 25}
26 26
27void AIRDA::commit( void ) { 27void AIRDA::commit( void ) {
28 if( GUI && GUI->commit( Data ) ) 28 if( GUI && GUI->commit( Data ) )
29 setModified( 1 ); 29 setModified( 1 );
30} 30}
31 31
32bool AIRDA::generateDataForCommonFile(
33 SystemFile & ,
34 long ) {
35 return 1;
36}
37
diff --git a/noncore/settings/networksettings2/irda/irda_NNI.h b/noncore/settings/networksettings2/irda/irda_NNI.h
index 210d87d..e21b68f 100644
--- a/noncore/settings/networksettings2/irda/irda_NNI.h
+++ b/noncore/settings/networksettings2/irda/irda_NNI.h
@@ -5,42 +5,36 @@
5#include "irdadata.h" 5#include "irdadata.h"
6#include "irdarun.h" 6#include "irdarun.h"
7 7
8class IRDANetNode; 8class IRDANetNode;
9class IRDAEdit; 9class IRDAEdit;
10 10
11class AIRDA : public ANetNodeInstance { 11class AIRDA : public ANetNodeInstance {
12 12
13public : 13public :
14 14
15 AIRDA( IRDANetNode * PNN ); 15 AIRDA( IRDANetNode * PNN );
16 16
17 RuntimeInfo * runtime( void )
18 { return
19 ( RT ) ? RT : ( RT = new IRDARun( this, Data ) );
20 }
21
17 QWidget * edit( QWidget * parent ); 22 QWidget * edit( QWidget * parent );
18 QString acceptable( void ); 23 QString acceptable( void );
19 void commit( void ); 24 void commit( void );
20 25
21 RuntimeInfo * runtime( void )
22 { if( RT == 0 )
23 RT = new IRDARun( this, Data );
24 return RT;
25 }
26
27 virtual void * data( void ) 26 virtual void * data( void )
28 { return (void *)&Data; } 27 { return (void *)&Data; }
29 28
30 virtual bool hasDataFor( const QString & )
31 { return 0; }
32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr );
34
35protected : 29protected :
36 30
37 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 31 virtual void setSpecificAttribute( QString & Attr, QString & Value );
38 virtual void saveSpecificAttribute( QTextStream & TS ); 32 virtual void saveSpecificAttribute( QTextStream & TS );
39 33
40private : 34private :
41 35
42 IRDAEdit * GUI; 36 IRDAEdit * GUI;
43 IRDAData Data; 37 IRDAData Data;
44 IRDARun * RT; 38 IRDARun * RT;
45 39
46}; 40};
diff --git a/noncore/settings/networksettings2/irda/irdarun.h b/noncore/settings/networksettings2/irda/irdarun.h
index 4c903cc..4258aff 100644
--- a/noncore/settings/networksettings2/irda/irdarun.h
+++ b/noncore/settings/networksettings2/irda/irdarun.h
@@ -3,23 +3,26 @@
3 3
4class IRDARun : public AsLine { 4class IRDARun : public AsLine {
5 5
6public : 6public :
7 7
8 IRDARun( ANetNodeInstance * NNI, 8 IRDARun( ANetNodeInstance * NNI,
9 IRDAData & Data ) : AsLine( NNI ) 9 IRDAData & Data ) : AsLine( NNI )
10 { } 10 { }
11 11
12 virtual AsLine * asLine( void ) 12 virtual AsLine * asLine( void )
13 { return (AsLine *)this; } 13 { return (AsLine *)this; }
14 14
15 virtual QString deviceFile( void )
16 { return QString( "/dev/irda" ); }
17
15protected : 18protected :
16 19
17 void detectState( NodeCollection * ) 20 void detectState( NodeCollection * )
18 { } 21 { }
19 22
20 bool setState( NodeCollection * , Action_t, bool ) 23 bool setState( NodeCollection * , Action_t, bool )
21 { return 0; } 24 { return 0; }
22 25
23 bool canSetState( State_t , Action_t ) 26 bool canSetState( State_t , Action_t )
24 { return 0; } 27 { return 0; }
25}; 28};
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
index 05cd06d..20ae7f6 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp
@@ -29,47 +29,24 @@ ANetNodeInstance * LanCardNetNode::createInstance( void ) {
29 return new ALanCard( this ); 29 return new ALanCard( this );
30} 30}
31 31
32 32
33const char ** LanCardNetNode::needs( void ) { 33const char ** LanCardNetNode::needs( void ) {
34 return LanCardNeeds; 34 return LanCardNeeds;
35} 35}
36 36
37const char * LanCardNetNode::provides( void ) { 37const char * LanCardNetNode::provides( void ) {
38 return "device"; 38 return "device";
39} 39}
40 40
41bool LanCardNetNode::generateProperFilesFor(
42 ANetNodeInstance * ) {
43 return 0;
44}
45
46bool LanCardNetNode::hasDataFor( const QString & S ) {
47 return S == "interfaces";
48}
49
50bool LanCardNetNode::generateDeviceDataForCommonFile(
51 SystemFile & S ,
52 long DevNr ) {
53 QString NIC = genNic( DevNr );
54
55 if( S.name() == "interfaces" ) {
56 // generate mapping stanza for this interface
57 S << "# check if " << NIC << " can be brought UP" << endl;
58 S << "mapping " << NIC << endl;
59 S << " script networksettings2-request" << endl << endl;
60 }
61 return 0;
62}
63
64QString LanCardNetNode::genNic( long nr ) { 41QString LanCardNetNode::genNic( long nr ) {
65 QString S; 42 QString S;
66 return S.sprintf( "eth%ld", nr ); 43 return S.sprintf( "eth%ld", nr );
67} 44}
68 45
69void LanCardNetNode::setSpecificAttribute( QString & A, QString & V ) { 46void LanCardNetNode::setSpecificAttribute( QString & A, QString & V ) {
70 if( A == "interfacecount" ) { 47 if( A == "interfacecount" ) {
71 InstanceCount = V.toLong(); 48 InstanceCount = V.toLong();
72 } else if ( A == "macaddress" ) { 49 } else if ( A == "macaddress" ) {
73 NICMACAddresses.append( V ); 50 NICMACAddresses.append( V );
74 } 51 }
75} 52}
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.h b/noncore/settings/networksettings2/lancard/lancard_NN.h
index d58823c..6882af7 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NN.h
+++ b/noncore/settings/networksettings2/lancard/lancard_NN.h
@@ -9,41 +9,34 @@ class ALanCard;
9class LanCardNetNode : public ANetNode{ 9class LanCardNetNode : public ANetNode{
10 10
11 Q_OBJECT 11 Q_OBJECT
12 12
13public: 13public:
14 14
15 LanCardNetNode(); 15 LanCardNetNode();
16 virtual ~LanCardNetNode(); 16 virtual ~LanCardNetNode();
17 17
18 virtual const QString pixmapName() 18 virtual const QString pixmapName()
19 { return "Devices/card"; } 19 { return "Devices/card"; }
20 20
21 virtual const QString nodeDescription() ; 21 virtual QString genNic( long );
22 virtual long instanceCount( void )
23 { return InstanceCount; }
22 24
25 virtual const QString nodeDescription() ;
23 virtual ANetNodeInstance * createInstance( void ); 26 virtual ANetNodeInstance * createInstance( void );
24
25 virtual const char ** needs( void ); 27 virtual const char ** needs( void );
26 virtual const char * provides( void ); 28 virtual const char * provides( void );
27 29
28 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ); 30 QStringList & addressesOfNIC( void )
29 virtual bool hasDataFor( const QString & S );
30 virtual bool generateDeviceDataForCommonFile(
31 SystemFile & SF, long DevNr );
32
33 virtual long instanceCount( void )
34 { return InstanceCount; }
35
36 virtual QString genNic( long );
37 virtual QStringList & addressesOfNIC( void )
38 { return NICMACAddresses; } 31 { return NICMACAddresses; }
39 32
40private: 33private:
41 34
42 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 35 virtual void setSpecificAttribute( QString & Attr, QString & Value );
43 virtual void saveSpecificAttribute( QTextStream & TS ); 36 virtual void saveSpecificAttribute( QTextStream & TS );
44 37
45 // number of interfaces for this device 38 // number of interfaces for this device
46 long InstanceCount; 39 long InstanceCount;
47 40
48 QStringList NICMACAddresses; 41 QStringList NICMACAddresses;
49 42
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
index 99c033e..9fb05b9 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
+++ b/noncore/settings/networksettings2/lancard/lancard_NNI.cpp
@@ -34,18 +34,12 @@ QWidget * ALanCard::edit( QWidget * parent ) {
34 return GUI; 34 return GUI;
35} 35}
36 36
37QString ALanCard::acceptable( void ) { 37QString ALanCard::acceptable( void ) {
38 return ( GUI ) ? GUI->acceptable( ) : QString(); 38 return ( GUI ) ? GUI->acceptable( ) : QString();
39} 39}
40 40
41void ALanCard::commit( void ) { 41void ALanCard::commit( void ) {
42 if( GUI && GUI->commit( Data ) ) 42 if( GUI && GUI->commit( Data ) )
43 setModified( 1 ); 43 setModified( 1 );
44} 44}
45 45
46bool ALanCard::generateDataForCommonFile(
47 SystemFile & ,
48 long ) {
49 return 1;
50}
51
diff --git a/noncore/settings/networksettings2/lancard/lancard_NNI.h b/noncore/settings/networksettings2/lancard/lancard_NNI.h
index 4e91523..8e55a19 100644
--- a/noncore/settings/networksettings2/lancard/lancard_NNI.h
+++ b/noncore/settings/networksettings2/lancard/lancard_NNI.h
@@ -5,41 +5,36 @@
5#include "lancarddata.h" 5#include "lancarddata.h"
6#include "lancardrun.h" 6#include "lancardrun.h"
7 7
8class LanCardNetNode; 8class LanCardNetNode;
9class LanCardEdit; 9class LanCardEdit;
10 10
11class ALanCard : public ANetNodeInstance { 11class ALanCard : public ANetNodeInstance {
12 12
13public : 13public :
14 14
15 ALanCard( LanCardNetNode * PNN ); 15 ALanCard( LanCardNetNode * PNN );
16 16
17 RuntimeInfo * runtime( void )
18 { return
19 ( RT ) ? RT : ( RT = new LanCardRun( this, Data ) );
20 }
21
17 QWidget * edit( QWidget * parent ); 22 QWidget * edit( QWidget * parent );
18 QString acceptable( void ); 23 QString acceptable( void );
19 void commit( void ); 24 void commit( void );
20 25
21 RuntimeInfo * runtime( void )
22 { if( RT == 0 )
23 RT = new LanCardRun( this, Data );
24 return RT;
25 }
26
27 virtual void * data( void ) 26 virtual void * data( void )
28 { return (void *)&Data; } 27 { return (void *)&Data; }
29 28
30 virtual bool hasDataFor( const QString & )
31 { return 0; }
32 virtual bool generateDataForCommonFile(
33 SystemFile & S, long DevNr );
34protected : 29protected :
35 30
36 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 31 virtual void setSpecificAttribute( QString & Attr, QString & Value );
37 virtual void saveSpecificAttribute( QTextStream & TS ); 32 virtual void saveSpecificAttribute( QTextStream & TS );
38 33
39private : 34private :
40 35
41 LanCardEdit * GUI; 36 LanCardEdit * GUI;
42 LanCardData Data; 37 LanCardData Data;
43 LanCardRun * RT; 38 LanCardRun * RT;
44 39
45}; 40};
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp
index 6c969fc..b32b323 100644
--- a/noncore/settings/networksettings2/main.cpp
+++ b/noncore/settings/networksettings2/main.cpp
@@ -1,58 +1,64 @@
1#include "nsdata.h" 1#include "nsdata.h"
2#include "activateprofile.h" 2#include "activateprofile.h"
3#include "activatevpn.h"
3#include "networksettings.h" 4#include "networksettings.h"
4 5
5#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
6 7
7#include <opie2/oapplicationfactory.h> 8#include <opie2/oapplicationfactory.h>
8using namespace Opie::Core; 9using namespace Opie::Core;
9 10
10#ifdef GONE 11#ifdef GONE
11 12
12OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) 13OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> )
13 14
14#else 15#else
15 16
16// just standard GUI 17// just standard GUI
17#define ACT_GUI 0 18#define ACT_GUI 0
18// used by interfaces to request for allow of up/down 19// used by interfaces to request for allow of up/down
19#define ACT_REQUEST 1 20#define ACT_REQUEST 1
20// regenerate config files 21// regenerate config files
21#define ACT_REGEN 2 22#define ACT_REGEN 2
22// used by interfaces to request user prompt 23// used by interfaces to request user prompt
23#define ACT_PROMPT 3 24#define ACT_PROMPT 3
25// used by interfaces to trigger VPN
26#define ACT_VPN 4
24 27
25int main( int argc, char * argv[] ) { 28int main( int argc, char * argv[] ) {
26 int rv = 0; 29 int rv = 0;
27 int Action = ACT_GUI; 30 int Action = ACT_GUI;
28 // could be overruled by -qws 31 // could be overruled by -qws
29 QApplication::Type GuiType = QApplication::GuiClient; 32 QApplication::Type GuiType = QApplication::GuiClient;
30 33
31#ifdef _WS_QWS_ 34#ifdef _WS_QWS_
32 QPEApplication * TheApp; 35 QPEApplication * TheApp;
33#else 36#else
34 QApplication * TheApp; 37 QApplication * TheApp;
35#endif 38#endif
36 39
37 for ( int i = 1; i < argc; i ++ ) { 40 for ( int i = 1; i < argc; i ++ ) {
38 int rmv; 41 int rmv;
39 rmv = 0; 42 rmv = 0;
40 if( strcmp( argv[i], "--regen" ) == 0 ) { 43 if( strcmp( argv[i], "--regen" ) == 0 ) {
41 Action = ACT_REGEN; 44 Action = ACT_REGEN;
42 GuiType = QApplication::Tty; 45 GuiType = QApplication::Tty;
43 rmv = 1; 46 rmv = 1;
44 } else if( strcmp( argv[i], "--prompt" ) == 0 ) { 47 } else if( strcmp( argv[i], "--prompt" ) == 0 ) {
45 Action = ACT_PROMPT; 48 Action = ACT_PROMPT;
46 rmv = 1; 49 rmv = 1;
50 } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) {
51 Action = ACT_VPN;
52 rmv = 1;
47 } 53 }
48 if( rmv ) { 54 if( rmv ) {
49 memmove( argv+i, argv+i+rmv, 55 memmove( argv+i, argv+i+rmv,
50 sizeof( char * ) * (argc-i-rmv) ); 56 sizeof( char * ) * (argc-i-rmv) );
51 i --; 57 i --;
52 argc -= rmv; 58 argc -= rmv;
53 } 59 }
54 } 60 }
55 61
56 if( strstr( argv[0], "-request" ) ) { 62 if( strstr( argv[0], "-request" ) ) {
57 // called from system to request something 63 // called from system to request something
58 GuiType = QApplication::Tty; 64 GuiType = QApplication::Tty;
@@ -69,61 +75,61 @@ int main( int argc, char * argv[] ) {
69 } else { 75 } else {
70 TheApp = new QPEApplication( argc, argv, GuiType ); 76 TheApp = new QPEApplication( argc, argv, GuiType );
71 } 77 }
72#else 78#else
73 TheApp = new QApplication( argc, argv, GuiType ); 79 TheApp = new QApplication( argc, argv, GuiType );
74#endif 80#endif
75 81
76 // init qt with app widget 82 // init qt with app widget
77 83
78 switch( Action ) { 84 switch( Action ) {
79 case ACT_REQUEST : 85 case ACT_REQUEST :
80 { NetworkSettingsData NS; 86 { NetworkSettingsData NS;
81 Log(("ACT_REQUEST\n"));
82 if( NS.canStart( argv[1] ) ) { 87 if( NS.canStart( argv[1] ) ) {
83 QString S; 88 QString S;
84 Log(("NEED FOR PROMPT\n" ));
85 S.sprintf( QPEApplication::qpeDir()+ 89 S.sprintf( QPEApplication::qpeDir()+
86 "/bin/networksettings2" ); 90 "/bin/networksettings2" );
87 char * MyArgv[4]; 91 char * MyArgv[4];
88 MyArgv[0] = "networksettings2"; 92 MyArgv[0] = "networksettings2";
89 MyArgv[1] = "--prompt"; 93 MyArgv[1] = "--prompt";
90 MyArgv[2] = argv[1]; 94 MyArgv[2] = argv[1];
91 MyArgv[3] = NULL; 95 MyArgv[3] = NULL;
92 NSResources->system().execAsUser( S, MyArgv ); 96 NSResources->system().execAsUser( S, MyArgv );
93 // if we come here , failed 97 // if we come here , failed
94 printf( "%s-cNN-disallowed", argv[1] ); 98 printf( "%s-cNN-disallowed", argv[1] );
95 } 99 }
96 } 100 }
97 break; 101 break;
98 case ACT_REGEN : 102 case ACT_REGEN :
99 { NetworkSettingsData NS; 103 { NetworkSettingsData NS;
100 Log(("REGEN\n" ));
101 // regen returns 0 if OK 104 // regen returns 0 if OK
102 rv = (NS.regenerate()) ? 1 : 0; 105 rv = (NS.regenerate()) ? 1 : 0;
103 } 106 }
104 break; 107 break;
105 case ACT_PROMPT : 108 case ACT_PROMPT :
106 { ActivateProfile AP(argv[1]); 109 { ActivateProfile AP(argv[1]);
107 Log(("PROMPT\n" ));
108 if( AP.exec() == QDialog::Accepted ) { 110 if( AP.exec() == QDialog::Accepted ) {
109 printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); 111 printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() );
110 } else { 112 } else {
111 printf( "%s-cNN-disallowed", argv[1] ); 113 printf( "%s-cNN-disallowed", argv[1] );
112 } 114 }
113 } 115 }
114 break; 116 break;
117 case ACT_VPN :
118 { ActivateVPN AVPN;
119 AVPN.exec();
120 }
121 break;
115 case ACT_GUI : 122 case ACT_GUI :
116 { QWidget * W = new NetworkSettings(0); 123 { QWidget * W = new NetworkSettings(0);
117 Log(("GUI\n" ));
118 TheApp->setMainWidget( W ); 124 TheApp->setMainWidget( W );
119 W->show(); 125 W->show();
120#ifdef _WS_QWS_ 126#ifdef _WS_QWS_
121 W->showMaximized(); 127 W->showMaximized();
122#else 128#else
123 W->resize( W->sizeHint() ); 129 W->resize( W->sizeHint() );
124#endif 130#endif
125 rv = TheApp->exec(); 131 rv = TheApp->exec();
126 delete W; 132 delete W;
127 } 133 }
128 break; 134 break;
129 } 135 }
diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp
index 18aa480..ee61b10 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.cpp
+++ b/noncore/settings/networksettings2/modem/modem_NN.cpp
@@ -28,34 +28,23 @@ const QString ModemNetNode::nodeDescription(){
28ANetNodeInstance * ModemNetNode::createInstance( void ) { 28ANetNodeInstance * ModemNetNode::createInstance( void ) {
29 return new AModem( this ); 29 return new AModem( this );
30} 30}
31 31
32const char ** ModemNetNode::needs( void ) { 32const char ** ModemNetNode::needs( void ) {
33 return ModemNeeds; 33 return ModemNeeds;
34} 34}
35 35
36const char * ModemNetNode::provides( void ) { 36const char * ModemNetNode::provides( void ) {
37 return "line"; 37 return "line";
38} 38}
39 39
40bool ModemNetNode::generateProperFilesFor(
41 ANetNodeInstance * ) {
42 return 0;
43}
44
45bool ModemNetNode::generateDeviceDataForCommonFile(
46 SystemFile & ,
47 long ) {
48 return 0;
49}
50
51void ModemNetNode::setSpecificAttribute( QString & , QString & ) { 40void ModemNetNode::setSpecificAttribute( QString & , QString & ) {
52} 41}
53 42
54void ModemNetNode::saveSpecificAttribute( QTextStream & ) { 43void ModemNetNode::saveSpecificAttribute( QTextStream & ) {
55} 44}
56 45
57extern "C" { 46extern "C" {
58void create_plugin( QList<ANetNode> & PNN ) { 47void create_plugin( QList<ANetNode> & PNN ) {
59 PNN.append( new ModemNetNode() ); 48 PNN.append( new ModemNetNode() );
60} 49}
61} 50}
diff --git a/noncore/settings/networksettings2/modem/modem_NN.h b/noncore/settings/networksettings2/modem/modem_NN.h
index 2f496dd..a76525f 100644
--- a/noncore/settings/networksettings2/modem/modem_NN.h
+++ b/noncore/settings/networksettings2/modem/modem_NN.h
@@ -9,36 +9,28 @@ class ModemNetNode : public ANetNode{
9 9
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 13
14 ModemNetNode(); 14 ModemNetNode();
15 virtual ~ModemNetNode(); 15 virtual ~ModemNetNode();
16 16
17 virtual const QString pixmapName() 17 virtual const QString pixmapName()
18 { return "Devices/modem"; } 18 { return "Devices/modem"; }
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21
22 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
23
24 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
25 virtual const char * provides( void ); 23 virtual const char * provides( void );
26 24
27 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
28 virtual bool hasDataFor( const QString & )
29 { return 0; }
30 virtual bool generateDeviceDataForCommonFile(
31 SystemFile & SF, long DevNr );
32
33private: 25private:
34 26
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
36 virtual void saveSpecificAttribute( QTextStream & TS ); 28 virtual void saveSpecificAttribute( QTextStream & TS );
37}; 29};
38 30
39extern "C" 31extern "C"
40{ 32{
41 void create_plugin( QList<ANetNode> & PNN ); 33 void create_plugin( QList<ANetNode> & PNN );
42}; 34};
43 35
44#endif 36#endif
diff --git a/noncore/settings/networksettings2/modem/modem_NNI.cpp b/noncore/settings/networksettings2/modem/modem_NNI.cpp
index 6c76b56..91df22b 100644
--- a/noncore/settings/networksettings2/modem/modem_NNI.cpp
+++ b/noncore/settings/networksettings2/modem/modem_NNI.cpp
@@ -20,18 +20,12 @@ QWidget * AModem::edit( QWidget * parent ) {
20 return GUI; 20 return GUI;
21} 21}
22 22
23QString AModem::acceptable( void ) { 23QString AModem::acceptable( void ) {
24 return ( GUI ) ? GUI->acceptable( ) : QString(); 24 return ( GUI ) ? GUI->acceptable( ) : QString();
25} 25}
26 26
27void AModem::commit( void ) { 27void AModem::commit( void ) {
28 if( GUI && GUI->commit( Data ) ) 28 if( GUI && GUI->commit( Data ) )
29 setModified( 1 ); 29 setModified( 1 );
30} 30}
31 31
32bool AModem::generateDataForCommonFile(
33 SystemFile & ,
34 long ) {
35 return 1;
36}
37
diff --git a/noncore/settings/networksettings2/modem/modem_NNI.h b/noncore/settings/networksettings2/modem/modem_NNI.h
index a623704..ca7c279 100644
--- a/noncore/settings/networksettings2/modem/modem_NNI.h
+++ b/noncore/settings/networksettings2/modem/modem_NNI.h
@@ -5,42 +5,36 @@
5#include "modemdata.h" 5#include "modemdata.h"
6#include "modemrun.h" 6#include "modemrun.h"
7 7
8class ModemNetNode; 8class ModemNetNode;
9class ModemEdit; 9class ModemEdit;
10 10
11class AModem : public ANetNodeInstance { 11class AModem : public ANetNodeInstance {
12 12
13public : 13public :
14 14
15 AModem( ModemNetNode * PNN ); 15 AModem( ModemNetNode * PNN );
16 16
17 RuntimeInfo * runtime( void )
18 { return
19 ( RT ) ? RT : ( RT = new ModemRun( this, Data ) );
20 }
21
17 QWidget * edit( QWidget * parent ); 22 QWidget * edit( QWidget * parent );
18 QString acceptable( void ); 23 QString acceptable( void );
19 void commit( void ); 24 void commit( void );
20 25
21 RuntimeInfo * runtime( void )
22 { if( RT == 0 )
23 RT = new ModemRun( this, Data );
24 return RT;
25 }
26
27 virtual void * data( void ) 26 virtual void * data( void )
28 { return (void *)&Data; } 27 { return (void *)&Data; }
29 28
30 virtual bool hasDataFor( const QString & )
31 { return 0; }
32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr );
34
35protected : 29protected :
36 30
37 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 31 virtual void setSpecificAttribute( QString & Attr, QString & Value );
38 virtual void saveSpecificAttribute( QTextStream & TS ); 32 virtual void saveSpecificAttribute( QTextStream & TS );
39 33
40private : 34private :
41 35
42 ModemEdit * GUI; 36 ModemEdit * GUI;
43 ModemData Data; 37 ModemData Data;
44 ModemRun * RT; 38 ModemRun * RT;
45 39
46}; 40};
diff --git a/noncore/settings/networksettings2/modem/modemrun.h b/noncore/settings/networksettings2/modem/modemrun.h
index 336462e..491a677 100644
--- a/noncore/settings/networksettings2/modem/modemrun.h
+++ b/noncore/settings/networksettings2/modem/modemrun.h
@@ -3,23 +3,26 @@
3 3
4class ModemRun : public AsLine { 4class ModemRun : public AsLine {
5 5
6public : 6public :
7 7
8 ModemRun( ANetNodeInstance * NNI, 8 ModemRun( ANetNodeInstance * NNI,
9 ModemData & Data ) : AsLine ( NNI ) 9 ModemData & Data ) : AsLine ( NNI )
10 { } 10 { }
11 11
12 virtual AsLine * asLine( void ) 12 virtual AsLine * asLine( void )
13 { return (AsLine *)this; } 13 { return (AsLine *)this; }
14 14
15 virtual QString deviceFile( void )
16 { return QString("/dev/modem"); }
17
15protected : 18protected :
16 19
17 void detectState( NodeCollection * ) 20 void detectState( NodeCollection * )
18 { } 21 { }
19 22
20 bool setState( NodeCollection *, Action_t, bool ) 23 bool setState( NodeCollection *, Action_t, bool )
21 { return 0; } 24 { return 0; }
22 25
23 bool canSetState( State_t, Action_t ) 26 bool canSetState( State_t, Action_t )
24 { return 0; } 27 { return 0; }
25}; 28};
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp
index b4313c4..1feffdb 100644
--- a/noncore/settings/networksettings2/network/network_NN.cpp
+++ b/noncore/settings/networksettings2/network/network_NN.cpp
@@ -1,12 +1,13 @@
1#include <asdevice.h>
1#include "network_NN.h" 2#include "network_NN.h"
2#include "network_NNI.h" 3#include "network_NNI.h"
3 4
4static const char * NetworkNeeds[] = 5static const char * NetworkNeeds[] =
5 { "device", 6 { "device",
6 0 7 0
7 }; 8 };
8 9
9/** 10/**
10 * Constructor, find all of the possible interfaces 11 * Constructor, find all of the possible interfaces
11 */ 12 */
12NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) { 13NetworkNetNode::NetworkNetNode() : ANetNode(tr("IP Configuration")) {
@@ -21,41 +22,60 @@ NetworkNetNode::~NetworkNetNode(){
21const QString NetworkNetNode::nodeDescription(){ 22const QString NetworkNetNode::nodeDescription(){
22 return tr("\ 23 return tr("\
23<p>Sets up TCP/IP options.</p>\ 24<p>Sets up TCP/IP options.</p>\
24<p>Use this to configure the TCP/IP protocol</p>\ 25<p>Use this to configure the TCP/IP protocol</p>\
25" 26"
26); 27);
27} 28}
28 29
29ANetNodeInstance * NetworkNetNode::createInstance( void ) { 30ANetNodeInstance * NetworkNetNode::createInstance( void ) {
30 return new ANetwork( this ); 31 return new ANetwork( this );
31} 32}
32 33
33const char ** NetworkNetNode::needs( void ) { 34bool NetworkNetNode::hasDataForFile( const QString & S ) {
34 return NetworkNeeds; 35 return S == "interfaces";
35} 36}
36 37
37const char * NetworkNetNode::provides( void ) { 38short NetworkNetNode::generateFile( const QString & ID,
38 return "connection"; 39 const QString & ,
40 QTextStream & TS,
41 ANetNodeInstance * NNI,
42 long DevNr ) {
43
44 QString NIC = NNI->runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
45
46 if( ID == "interfaces" ) {
47 Log(("Generate entry for %s in %s\n", NIC.latin1(), ID.latin1() ));
48 // generate mapping stanza for this interface
49 TS << "# check if "
50 << NIC
51 << " can be brought UP"
52 << endl;
53 TS << "mapping "
54 << NIC
55 << endl;
56 TS << " script networksettings2-request"
57 << endl
58 << endl;
59 return 0;
60 }
61 return 1;
39} 62}
40 63
41bool NetworkNetNode::generateProperFilesFor( 64const char ** NetworkNetNode::needs( void ) {
42 ANetNodeInstance * ) { 65 return NetworkNeeds;
43 return 0;
44} 66}
45 67
46bool NetworkNetNode::generateDeviceDataForCommonFile( 68const char * NetworkNetNode::provides( void ) {
47 SystemFile & , 69 return "connection";
48 long ) {
49 return 0;
50} 70}
51 71
52void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { 72void NetworkNetNode::setSpecificAttribute( QString & , QString & ) {
53} 73}
54 74
55void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { 75void NetworkNetNode::saveSpecificAttribute( QTextStream & ) {
56} 76}
57 77
58extern "C" { 78extern "C" {
59void create_plugin( QList<ANetNode> & PNN ) { 79void create_plugin( QList<ANetNode> & PNN ) {
60 PNN.append( new NetworkNetNode() ); 80 PNN.append( new NetworkNetNode() );
61} 81}
diff --git a/noncore/settings/networksettings2/network/network_NN.h b/noncore/settings/networksettings2/network/network_NN.h
index 6548c32..745d1a7 100644
--- a/noncore/settings/networksettings2/network/network_NN.h
+++ b/noncore/settings/networksettings2/network/network_NN.h
@@ -1,43 +1,42 @@
1#ifndef NETWORK_NETNODE_H 1#ifndef NETWORK_NETNODE_H
2#define NETWORK_NETNODE_H 2#define NETWORK_NETNODE_H
3 3
4#include "netnode.h" 4#include "netnode.h"
5 5
6class ANetwork; 6class ANetwork;
7 7
8class NetworkNetNode : public ANetNode{ 8class NetworkNetNode : public ANetNode{
9 9
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 13
14 NetworkNetNode(); 14 NetworkNetNode();
15 virtual ~NetworkNetNode(); 15 virtual ~NetworkNetNode();
16 16
17 virtual const QString pixmapName() 17 virtual bool hasDataForFile( const QString & S );
18 { return "Devices/tcpip"; }
19 18
20 virtual const QString nodeDescription() ; 19 virtual short generateFile( const QString & ID,
20 const QString & Path,
21 QTextStream & TS,
22 ANetNodeInstance * NNI,
23 long DevNr );
24 virtual const QString pixmapName()
25 { return "Devices/tcpip"; }
21 26
22 virtual ANetNodeInstance * createInstance( void ); 27 virtual const QString nodeDescription() ;
23 28 virtual ANetNodeInstance * createInstance( void );
24 virtual const char ** needs( void ); 29 virtual const char ** needs( void );
25 virtual const char * provides( void ); 30 virtual const char * provides( void );
26
27 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
28 virtual bool hasDataFor( const QString & )
29 { return 0; }
30 virtual bool generateDeviceDataForCommonFile(
31 SystemFile & SF, long DevNr );
32 31
33private: 32private:
34 33
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 34 virtual void setSpecificAttribute( QString & Attr, QString & Value );
36 virtual void saveSpecificAttribute( QTextStream & TS ); 35 virtual void saveSpecificAttribute( QTextStream & TS );
37}; 36};
38 37
39extern "C" 38extern "C"
40{ 39{
41 void create_plugin( QList<ANetNode> & PNN ); 40 void create_plugin( QList<ANetNode> & PNN );
42}; 41};
43 42
diff --git a/noncore/settings/networksettings2/network/network_NNI.cpp b/noncore/settings/networksettings2/network/network_NNI.cpp
index 3e368a2..324c6e2 100644
--- a/noncore/settings/networksettings2/network/network_NNI.cpp
+++ b/noncore/settings/networksettings2/network/network_NNI.cpp
@@ -90,100 +90,130 @@ QWidget * ANetwork::edit( QWidget * parent ) {
90 return GUI; 90 return GUI;
91} 91}
92 92
93QString ANetwork::acceptable( void ) { 93QString ANetwork::acceptable( void ) {
94 return ( GUI ) ? GUI->acceptable( ) : QString(); 94 return ( GUI ) ? GUI->acceptable( ) : QString();
95} 95}
96 96
97void ANetwork::commit( void ) { 97void ANetwork::commit( void ) {
98 if( GUI && GUI->commit( Data ) ) 98 if( GUI && GUI->commit( Data ) )
99 setModified( 1 ); 99 setModified( 1 );
100} 100}
101 101
102bool ANetwork::hasDataFor( const QString & S ) { 102bool ANetwork::hasDataForFile( const QString & S ) {
103 return S == "interfaces"; 103 return S == "interfaces";
104} 104}
105 105
106bool ANetwork::generateDataForCommonFile( SystemFile & S, long DevNr ) { 106short ANetwork::generateFile( const QString & ID,
107 const QString & Path,
108 QTextStream &TS,
109 long DevNr
110 ) {
111
112 short rvl, rvd ;
107 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); 113 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
108 114
109 if( S.name() == "interfaces" ) { 115 rvl = 1;
116 if( ID == "interfaces" ) {
117 Log(("Generate Network for %s\n", ID.latin1() ));
110 // we can safely call from here since device item is deeper 118 // we can safely call from here since device item is deeper
111 if( Data.UseDHCP ) { 119 if( Data.UseDHCP ) {
112 S << "iface " 120 TS << "iface "
113 << NIC 121 << NIC
114 << "-c" 122 << "-c"
115 << connection()->number() 123 << connection()->number()
116 << "-allowed inet dhcp" 124 << "-allowed inet dhcp"
117 << endl; 125 << endl;
118 S << " up echo \"" 126 TS << " up echo \""
119 << NIC 127 << NIC
120 << "\" > /tmp/profile-" 128 << "\" > /tmp/profile-"
121 << connection()->number() 129 << connection()->number()
122 << ".up" 130 << ".up"
123 << endl; 131 << endl;
124 if( Data.SendHostname ) { 132 if( Data.SendHostname ) {
125 S << " hostname " 133 TS << " hostname "
126 << Data.Hostname 134 << Data.Hostname
127 << endl; 135 << endl;
128 } 136 }
129 137
130 S << " down rm -f /tmp/profile-" 138 TS << " down rm -f /tmp/profile-"
131 << connection()->number() 139 << connection()->number()
132 << ".up" 140 << ".up"
133 << endl; 141 << endl;
134 } else { 142 } else {
135 S << "iface " 143 TS << "iface "
136 << NIC << "-c" 144 << NIC << "-c"
137 << connection()->number() 145 << connection()->number()
138 << "-allowed inet static" 146 << "-allowed inet static"
139 << endl; 147 << endl;
140 S << " up echo \"" 148 TS << " up echo \""
141 << NIC 149 << NIC
142 << "\" > /tmp/profile-" 150 << "\" > /tmp/profile-"
143 << connection()->number() 151 << connection()->number()
144 << ".up" 152 << ".up"
145 << endl; 153 << endl;
146 S << " down rm -f /tmp/profile-" 154 TS << " down rm -f /tmp/profile-"
147 << connection()->number() 155 << connection()->number()
148 << ".up" 156 << ".up"
149 << endl; 157 << endl;
150 S << " address " << Data.IPAddress << endl; 158 TS << " address "
151 S << " broadcast " << Data.Broadcast << endl; 159 << Data.IPAddress
152 S << " netmask " << Data.NetMask << endl; 160 << endl;
161 TS << " broadcast "
162 << Data.Broadcast
163 << endl;
164 TS << " netmask "
165 << Data.NetMask
166 << endl;
153 167
154 // derive network address = IPAddress & netmask 168 // derive network address = IPAddress & netmask
155 { QString NW; 169 { QString NW;
156 QStringList ipal = QStringList::split( '.', Data.IPAddress ); 170 QStringList ipal = QStringList::split( '.', Data.IPAddress );
157 QStringList nmal = QStringList::split( '.', Data.NetMask ); 171 QStringList nmal = QStringList::split( '.', Data.NetMask );
158 172
159 NW = QString( "%1.%2.%3.%4" ). 173 NW = QString( "%1.%2.%3.%4" ).
160 arg( ipal[0].toShort() & nmal[0].toShort() ). 174 arg( ipal[0].toShort() & nmal[0].toShort() ).
161 arg( ipal[1].toShort() & nmal[1].toShort() ). 175 arg( ipal[1].toShort() & nmal[1].toShort() ).
162 arg( ipal[2].toShort() & nmal[2].toShort() ). 176 arg( ipal[2].toShort() & nmal[2].toShort() ).
163 arg( ipal[3].toShort() & nmal[3].toShort() ); 177 arg( ipal[3].toShort() & nmal[3].toShort() );
164 S << " network " << NW << endl; 178 TS << " network "
179 << NW
180 << endl;
165 } 181 }
166 } 182 }
167 for ( QStringList::Iterator it = Data.PreUp_SL.begin(); 183 for ( QStringList::Iterator it = Data.PreUp_SL.begin();
168 it != Data.PreUp_SL.end(); 184 it != Data.PreUp_SL.end();
169 ++it ) { 185 ++it ) {
170 S << " pre-up " << (*it) << endl; 186 TS << " pre-up "
187 << (*it)
188 << endl;
171 } 189 }
172 for ( QStringList::Iterator it = Data.PostUp_SL.begin(); 190 for ( QStringList::Iterator it = Data.PostUp_SL.begin();
173 it != Data.PostUp_SL.end(); 191 it != Data.PostUp_SL.end();
174 ++it ) { 192 ++it ) {
175 S << " up " << (*it) << endl; 193 TS << " up "
194 << (*it)
195 << endl;
176 } 196 }
177 for ( QStringList::Iterator it = Data.PreDown_SL.begin(); 197 for ( QStringList::Iterator it = Data.PreDown_SL.begin();
178 it != Data.PreDown_SL.end(); 198 it != Data.PreDown_SL.end();
179 ++it ) { 199 ++it ) {
180 S << " down " << (*it) << endl; 200 TS << " down "
201 << (*it)
202 << endl;
181 } 203 }
182 for ( QStringList::Iterator it = Data.PostDown_SL.begin(); 204 for ( QStringList::Iterator it = Data.PostDown_SL.begin();
183 it != Data.PostDown_SL.end(); 205 it != Data.PostDown_SL.end();
184 ++it ) { 206 ++it ) {
185 S << " post-down " << (*it) << endl; 207 TS << " post-down "
208 << (*it)
209 << endl;
186 } 210 }
211 rvl = 0;
187 } 212 }
188 return 0; 213
214 // embed other info in it
215 rvd = connection()->getToplevel()->generateFileEmbedded( ID, Path, TS, DevNr );
216
217 return (rvd == 2 || rvl == 2 ) ? 2 :
218 (rvd == 0 || rvl == 0 ) ? 0 : 1;
189} 219}
diff --git a/noncore/settings/networksettings2/network/network_NNI.h b/noncore/settings/networksettings2/network/network_NNI.h
index 0058793..5e42503 100644
--- a/noncore/settings/networksettings2/network/network_NNI.h
+++ b/noncore/settings/networksettings2/network/network_NNI.h
@@ -6,40 +6,41 @@
6#include "networkrun.h" 6#include "networkrun.h"
7 7
8class NetworkNetNode; 8class NetworkNetNode;
9class NetworkEdit; 9class NetworkEdit;
10class SystemFile; 10class SystemFile;
11 11
12class ANetwork : public ANetNodeInstance{ 12class ANetwork : public ANetNodeInstance{
13 13
14public : 14public :
15 15
16 ANetwork( NetworkNetNode * PNN ); 16 ANetwork( NetworkNetNode * PNN );
17 17
18 RuntimeInfo * runtime( void )
19 { return
20 ( RT ) ? RT : ( RT = new NetworkRun( this, Data ) );
21 }
22
18 QWidget * edit( QWidget * parent ); 23 QWidget * edit( QWidget * parent );
19 QString acceptable( void ); 24 QString acceptable( void );
20 void commit( void ); 25 void commit( void );
21 26
22 RuntimeInfo * runtime( void )
23 { if( RT == 0 )
24 RT = new NetworkRun( this, Data );
25 return RT;
26 }
27
28 virtual void * data( void ) 27 virtual void * data( void )
29 { return (void *)&Data; } 28 { return (void *)&Data; }
30 29
31 virtual bool hasDataFor( const QString & S ); 30 virtual bool hasDataForFile( const QString & S );
32 virtual bool generateDataForCommonFile( 31 virtual short generateFile( const QString & ID,
33 SystemFile & SF, long DevNr ); 32 const QString & Path,
33 QTextStream &TS,
34 long DevNr );
34 35
35protected : 36protected :
36 37
37 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 38 virtual void setSpecificAttribute( QString & Attr, QString & Value );
38 virtual void saveSpecificAttribute( QTextStream & TS ); 39 virtual void saveSpecificAttribute( QTextStream & TS );
39 40
40private : 41private :
41 42
42 NetworkEdit * GUI; 43 NetworkEdit * GUI;
43 NetworkData_t Data; 44 NetworkData_t Data;
44 NetworkRun * RT; 45 NetworkRun * RT;
45}; 46};
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp
index 6ee4106..ce0eabc 100644
--- a/noncore/settings/networksettings2/networksettings.cpp
+++ b/noncore/settings/networksettings2/networksettings.cpp
@@ -1,26 +1,28 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <unistd.h> 2#include <unistd.h>
3#include <errno.h>
3 4
4#include <qpe/qpeapplication.h> 5#include <qpe/qpeapplication.h>
5#include <qlistbox.h> 6#include <qlistbox.h>
6#include <qgroupbox.h> 7#include <qgroupbox.h>
7#include <qtimer.h> 8#include <qtimer.h>
8#include <qlistbox.h> 9#include <qlistbox.h>
9#include <qmessagebox.h> 10#include <qmessagebox.h>
10#include <qlabel.h> 11#include <qlabel.h>
11#include <qiconview.h> 12#include <qiconview.h>
12#include <qtimer.h> 13#include <qtimer.h>
13#include <qpe/qpeapplication.h> 14#include <qpe/qpeapplication.h>
14#include <qtoolbutton.h> 15#include <qtoolbutton.h>
16#include <qevent.h>
15 17
16#include <asdevice.h> 18#include <asdevice.h>
17#include "networksettings.h" 19#include "networksettings.h"
18#include "netnode.h" 20#include "netnode.h"
19#include "editconnection.h" 21#include "editconnection.h"
20 22
21NetworkSettings::NetworkSettings( QWidget *parent, 23NetworkSettings::NetworkSettings( QWidget *parent,
22 const char *name, 24 const char *name,
23 WFlags fl ) : NetworkSettingsGUI(parent,name,fl), 25 WFlags fl ) : NetworkSettingsGUI(parent,name,fl),
24 NSD() { 26 NSD() {
25 27
26 UpdateTimer = new QTimer( this ); 28 UpdateTimer = new QTimer( this );
@@ -32,24 +34,31 @@ NetworkSettings::NetworkSettings( QWidget *parent,
32 Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) ); 34 Enable_TB->setPixmap( NSResources->getPixmap( "disabled" ) );
33 GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) ); 35 GenConfig_TB->setPixmap( NSResources->getPixmap( "configure" ) );
34 36
35 Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) ); 37 Connect_TB->setPixmap( NSResources->getPixmap( "connected" ) );
36 Disconnect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) ); 38 Disconnect_TB->setPixmap( NSResources->getPixmap( "disconnected" ) );
37 39
38 On_TB->setPixmap( NSResources->getPixmap( "off" ) ); 40 On_TB->setPixmap( NSResources->getPixmap( "off" ) );
39 41
40 SLOT_ToProfile(); 42 SLOT_ToProfile();
41 43
42 // populate main Listbox 44 // populate main Listbox
43 Profiles_LB->clear(); 45 Profiles_LB->clear();
46 QPEApplication::setStylusOperation(
47 Profiles_LB->viewport(), QPEApplication::RightOnHold );
48
49 connect( Profiles_LB,
50 SIGNAL(rightButtonPressed(QListBoxItem*,const QPoint&)),
51 this, SLOT(SLOT_EditNode(QListBoxItem*)) );
52
44 { Name2Connection_t & M = NSResources->connections(); 53 { Name2Connection_t & M = NSResources->connections();
45 NodeCollection * NC; 54 NodeCollection * NC;
46 // for all connections 55 // for all connections
47 for( QDictIterator<NodeCollection> it(M); 56 for( QDictIterator<NodeCollection> it(M);
48 it.current(); 57 it.current();
49 ++it ) { 58 ++it ) {
50 NC = it.current(); 59 NC = it.current();
51 Profiles_LB->insertItem( NC->devicePixmap(), 60 Profiles_LB->insertItem( NC->devicePixmap(),
52 NC->name() ); 61 NC->name() );
53 } 62 }
54 } 63 }
55 64
@@ -69,40 +78,36 @@ NetworkSettings::NetworkSettings( QWidget *parent,
69 UpdateTimer->start( 5000 ); 78 UpdateTimer->start( 5000 );
70 connect( UpdateTimer, SIGNAL( timeout() ), 79 connect( UpdateTimer, SIGNAL( timeout() ),
71 this, SLOT( SLOT_RefreshStates() ) ); 80 this, SLOT( SLOT_RefreshStates() ) );
72 81
73 /* Add QCopChannel */ 82 /* Add QCopChannel */
74 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), 83 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
75 this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) ); 84 this, SLOT(SLOT_QCopMessage(const QCString&,const QByteArray&)) );
76} 85}
77 86
78NetworkSettings::~NetworkSettings() { 87NetworkSettings::~NetworkSettings() {
79 QString S; 88 QString S;
80 89
81 S = NSD.generateSettings(); 90 if( isModified() ) {
82 if( ! S.isEmpty() ) { 91 S = NSD.saveSettings();
83 QMessageBox::warning( 92 if( ! S.isEmpty() ) {
84 0, 93 // problem saving
85 tr( "In System Config" ), 94 QMessageBox::warning(
86 S 95 0,
87 ); 96 tr( "Saving setup" ), S );
88 } 97 }
89 98
90 S = NSD.saveSettings(); 99 SLOT_GenerateConfig();
91 if( ! S.isEmpty() ) {
92 // problem saving
93 QMessageBox::warning(
94 0,
95 tr( "Saving setup" ), S );
96 } 100 }
101
97} 102}
98 103
99void NetworkSettings::SLOT_CmdMessage( const QString & S ) { 104void NetworkSettings::SLOT_CmdMessage( const QString & S ) {
100 Messages_LB->insertItem( S ); 105 Messages_LB->insertItem( S );
101 Messages_LB->setCurrentItem( Messages_LB->count()-1 ); 106 Messages_LB->setCurrentItem( Messages_LB->count()-1 );
102 Messages_LB->ensureCurrentVisible(); 107 Messages_LB->ensureCurrentVisible();
103} 108}
104 109
105void NetworkSettings::SLOT_RefreshStates( void ) { 110void NetworkSettings::SLOT_RefreshStates( void ) {
106 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember 111 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); // remember
107 112
108 if( LBI ) { 113 if( LBI ) {
@@ -136,67 +141,64 @@ void NetworkSettings::SLOT_RefreshStates( void ) {
136 i ); 141 i );
137 if( is ) { 142 if( is ) {
138 Profiles_LB->setSelected( i, TRUE ); 143 Profiles_LB->setSelected( i, TRUE );
139 } 144 }
140 } 145 }
141 } 146 }
142 } 147 }
143 if( ci >= 0 ) 148 if( ci >= 0 )
144 Profiles_LB->setCurrentItem( ci ); 149 Profiles_LB->setCurrentItem( ci );
145 */ 150 */
146} 151}
147 152
148void NetworkSettings::SLOT_NoLongerBusy( void ) {
149 NSResources->busy( FALSE );
150}
151void NetworkSettings::SLOT_AddNode( void ) { 153void NetworkSettings::SLOT_AddNode( void ) {
152 SLOT_EditNode( 0 ); 154 SLOT_EditNode( 0 );
153} 155}
154 156
155void NetworkSettings::SLOT_DeleteNode( void ) { 157void NetworkSettings::SLOT_DeleteNode( void ) {
156 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 158 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
157 159
158 if ( ! LBI ) 160 if ( ! LBI )
159 return; 161 return;
160 162
161 if( QMessageBox::warning( 163 if( QMessageBox::warning(
162 0, 164 0,
163 tr( "Removing profile" ), 165 tr( "Removing profile" ),
164 tr( "Remove selected profile ?" ), 166 tr( "Remove selected profile ?" ),
165 1, 0 ) == 1 ) { 167 1, 0 ) == 1 ) {
166 NSResources->removeConnection( LBI->text() ); 168 NSResources->removeConnection( LBI->text() );
167 delete LBI; 169 delete LBI;
168 setModified( 1 ); 170 setModified( 1 );
169 NSD.forceGeneration(1);
170 } 171 }
171} 172}
172 173
173void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { 174void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) {
174 QString OldName = ""; 175 QString OldName = "";
176
177 printf( "------------------ Edit NOde\n" );
175 EditConnection EC( this ); 178 EditConnection EC( this );
176 179
177 if( LBI ) { 180 if( LBI ) {
178 NodeCollection * NC = NSResources->findConnection( LBI->text() ); 181 NodeCollection * NC = NSResources->findConnection( LBI->text() );
179 if( ! NC ) { 182 if( ! NC ) {
180 return; 183 return;
181 } 184 }
182 OldName = NC->name(); 185 OldName = NC->name();
183 EC.setConnection( NC ); 186 EC.setConnection( NC );
184 } 187 }
185 188
186 EC.showMaximized(); 189 EC.showMaximized();
187 // disable refresh timer 190 // disable refresh timer
188 UpdateTimer->stop(); 191 UpdateTimer->stop();
189 NSResources->busy( TRUE ); 192
190 QTimer::singleShot( 1000, this, SLOT( SLOT_NoLongerBusy() ));
191 // we need to retry 193 // we need to retry
192 while( 1 ) { 194 while( 1 ) {
193 if( EC.exec() == QDialog::Accepted ) { 195 if( EC.exec() == QDialog::Accepted ) {
194 // toplevel item -> store 196 // toplevel item -> store
195 NodeCollection * NC = EC.connection(); 197 NodeCollection * NC = EC.connection();
196 if( NC->isModified() ) { 198 if( NC->isModified() ) {
197 setModified( 1 ); 199 setModified( 1 );
198 if( LBI ) { 200 if( LBI ) {
199 if( NC->name() != OldName ) { 201 if( NC->name() != OldName ) {
200 // find if new name is free 202 // find if new name is free
201 NodeCollection * LCN = NSResources->findConnection( 203 NodeCollection * LCN = NSResources->findConnection(
202 NC->name() ); 204 NC->name() );
@@ -310,33 +312,25 @@ void NetworkSettings::SLOT_CheckState( void ) {
310 if ( ! LBI ) 312 if ( ! LBI )
311 return; 313 return;
312 updateProfileState( LBI ); 314 updateProfileState( LBI );
313} 315}
314 316
315void NetworkSettings::updateProfileState( QListBoxItem * LBI ) { 317void NetworkSettings::updateProfileState( QListBoxItem * LBI ) {
316 if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) { 318 if( LBI == Profiles_LB->item( Profiles_LB->currentItem() ) ) {
317 SLOT_ShowNode( LBI ); 319 SLOT_ShowNode( LBI );
318 } 320 }
319} 321}
320 322
321void NetworkSettings::SLOT_GenerateConfig( void ) { 323void NetworkSettings::SLOT_GenerateConfig( void ) {
322 QString S = NSD.generateSettings( TRUE ); 324 NSD.regenerate();
323
324 if( ! S.isEmpty() ) {
325 QMessageBox::warning(
326 0,
327 tr( "Generating system configuration" ),
328 S
329 );
330 }
331} 325}
332 326
333void NetworkSettings::SLOT_Enable( void ) { 327void NetworkSettings::SLOT_Enable( void ) {
334 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() ); 328 QListBoxItem * LBI = Profiles_LB->item( Profiles_LB->currentItem() );
335 QString Msg; 329 QString Msg;
336 if ( ! LBI ) 330 if ( ! LBI )
337 return; 331 return;
338 332
339 NodeCollection * NC = 333 NodeCollection * NC =
340 NSResources->findConnection( LBI->text() ); 334 NSResources->findConnection( LBI->text() );
341 335
342 bool rv; 336 bool rv;
diff --git a/noncore/settings/networksettings2/networksettings.h b/noncore/settings/networksettings2/networksettings.h
index 8ffde06..8ec5d08 100644
--- a/noncore/settings/networksettings2/networksettings.h
+++ b/noncore/settings/networksettings2/networksettings.h
@@ -1,54 +1,53 @@
1#include "nsdata.h" 1#include "nsdata.h"
2#include "networksettingsGUI.h" 2#include "networksettingsGUI.h"
3#include "resources.h" 3#include "resources.h"
4 4
5class ANetNode; 5class ANetNode;
6class ANetNodeInstance; 6class ANetNodeInstance;
7class QTimer; 7class QTimer;
8class QListBoxItem; 8class QListBoxItem;
9class QEvent;
9 10
10class NetworkSettings : public NetworkSettingsGUI { 11class NetworkSettings : public NetworkSettingsGUI {
11 12
12 Q_OBJECT 13 Q_OBJECT
13 14
14public : 15public :
15 16
16 NetworkSettings( QWidget *parent=0, 17 NetworkSettings( QWidget *parent=0,
17 const char *name=0, 18 const char *name=0,
18 WFlags fl = 0 ); 19 WFlags fl = 0 );
19 ~NetworkSettings( void ); 20 ~NetworkSettings( void );
20 21
21 static QString appName( void ) 22 static QString appName( void )
22 { return QString::fromLatin1("networksettings"); } 23 { return QString::fromLatin1("networksettings"); }
23 24
24 bool isModified( void ) 25 bool isModified( void )
25 { return NSD.isModified(); } 26 { return NSD.isModified(); }
26 void setModified( bool m ) 27 void setModified( bool m )
27 { NSD.setModified( m ); } 28 { NSD.setModified( m ); }
28 29
29public slots : 30public slots :
30 31
31 void SLOT_NoLongerBusy( void );
32 void SLOT_AddNode( void ); 32 void SLOT_AddNode( void );
33 void SLOT_DeleteNode( void ); 33 void SLOT_DeleteNode( void );
34 void SLOT_ShowNode( QListBoxItem * ); 34 void SLOT_ShowNode( QListBoxItem * );
35 void SLOT_EditNode( QListBoxItem * ); 35 void SLOT_EditNode( QListBoxItem * );
36 void SLOT_CheckState( void ); 36 void SLOT_CheckState( void );
37 void SLOT_Enable( void ); 37 void SLOT_Enable( void );
38 void SLOT_On( void ); 38 void SLOT_On( void );
39 void SLOT_Connect( void ); 39 void SLOT_Connect( void );
40 void SLOT_Disconnect( void ); 40 void SLOT_Disconnect( void );
41 void SLOT_GenerateConfig( void ); 41 void SLOT_GenerateConfig( void );
42 void SLOT_RefreshStates( void ); 42 void SLOT_RefreshStates( void );
43 void SLOT_QCopMessage( const QCString&,const QByteArray& ); 43 void SLOT_QCopMessage( const QCString&,const QByteArray& );
44 void SLOT_ToProfile( void ); 44 void SLOT_ToProfile( void );
45 void SLOT_ToMessages( void ); 45 void SLOT_ToMessages( void );
46 void SLOT_CmdMessage( const QString & S ); 46 void SLOT_CmdMessage( const QString & S );
47 47
48private : 48private :
49 49
50 void updateProfileState( QListBoxItem * it ); 50 void updateProfileState( QListBoxItem * it );
51 QTimer * UpdateTimer; 51 QTimer * UpdateTimer;
52 NetworkSettingsData NSD; 52 NetworkSettingsData NSD;
53
54}; 53};
diff --git a/noncore/settings/networksettings2/networksettings.pro b/noncore/settings/networksettings2/networksettings.pro
index ff147b1..f04289b 100644
--- a/noncore/settings/networksettings2/networksettings.pro
+++ b/noncore/settings/networksettings2/networksettings.pro
@@ -1,21 +1,24 @@
1# 1#
2CONFIG = qt warn_on debug 2CONFIG = qt warn_on debug
3#CONFIG = qt warn_on release 3#CONFIG = qt warn_on release
4HEADERS = networksettings.h \ 4HEADERS = networksettings.h \
5 activateprofile.h \ 5 activateprofile.h \
6 activatevpn.h \
6 editconnection.h 7 editconnection.h
7SOURCES = main.cpp \ 8SOURCES = main.cpp \
8 networksettings.cpp \ 9 networksettings.cpp \
9 nsdata.cpp \ 10 nsdata.cpp \
10 activateprofile.cpp \ 11 activateprofile.cpp \
12 activatevpn.cpp \
11 editconnection.cpp 13 editconnection.cpp
12INCLUDEPATH += $(OPIEDIR)/include networksettings2/ 14INCLUDEPATH += $(OPIEDIR)/include networksettings2/
13DEPENDPATH += $(OPIEDIR)/include networksettings2/ 15DEPENDPATH += $(OPIEDIR)/include networksettings2/
14LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings2 -lnetworksettings2 -lopiecore2 16LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings2 -lnetworksettings2 -lopiecore2
15INTERFACES = networksettingsGUI.ui \ 17INTERFACES = networksettingsGUI.ui \
16 editconnectionGUI.ui \ 18 editconnectionGUI.ui \
19 activatevpnGUI.ui \
17 activateprofileGUI.ui 20 activateprofileGUI.ui
18TARGET = $(OPIEDIR)/bin/networksettings2 21TARGET = $(OPIEDIR)/bin/networksettings2
19 22
20 23
21include ( $(OPIEDIR)/include.pro ) 24include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings2/networksettings2/Utils.h b/noncore/settings/networksettings2/networksettings2/Utils.h
index 63ef51c..739476e 100644
--- a/noncore/settings/networksettings2/networksettings2/Utils.h
+++ b/noncore/settings/networksettings2/networksettings2/Utils.h
@@ -1,8 +1,9 @@
1#ifndef __UTILS_H 1#ifndef __UTILS_H
2#define __UTILS_H 2#define __UTILS_H
3 3
4#define Log(x) VLog x 4#define Log(x) VLog x
5extern void VLog( char * Format, ... ); 5extern void VLog( char * Format, ... );
6extern void LogClose( void ); 6extern void LogClose( void );
7extern QString removeSpaces( const QString & X );
7 8
8#endif 9#endif
diff --git a/noncore/settings/networksettings2/networksettings2/asline.h b/noncore/settings/networksettings2/networksettings2/asline.h
index 6bd93ec..ee4de38 100644
--- a/noncore/settings/networksettings2/networksettings2/asline.h
+++ b/noncore/settings/networksettings2/networksettings2/asline.h
@@ -4,15 +4,17 @@
4#include <netnode.h> 4#include <netnode.h>
5 5
6// pure virtual (component oriented) interface of any 6// pure virtual (component oriented) interface of any
7// plugin that offers a line 7// plugin that offers a line
8class AsLine : public RuntimeInfo { 8class AsLine : public RuntimeInfo {
9 9
10public : 10public :
11 11
12 AsLine( ANetNodeInstance * NNI ) : 12 AsLine( ANetNodeInstance * NNI ) :
13 RuntimeInfo( NNI ) { 13 RuntimeInfo( NNI ) {
14 } 14 }
15 15
16 virtual QString deviceFile( void ) = 0;
17
16}; 18};
17 19
18#endif 20#endif
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp
index 8c80e0b..4a2440a 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.cpp
+++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp
@@ -135,25 +135,25 @@ NodeCollection::NodeCollection( QTextStream & TS ) :
135 135
136 idx = S.find('='); 136 idx = S.find('=');
137 S.stripWhiteSpace(); 137 S.stripWhiteSpace();
138 A = S.left( idx ); 138 A = S.left( idx );
139 A.lower(); 139 A.lower();
140 N = S.mid( idx+1, S.length() ); 140 N = S.mid( idx+1, S.length() );
141 N.stripWhiteSpace(); 141 N.stripWhiteSpace();
142 N = deQuote( N ); 142 N = deQuote( N );
143 143
144 if( A == "name" ) { 144 if( A == "name" ) {
145 Name = N; 145 Name = N;
146 } else if( A == "number" ) { 146 } else if( A == "number" ) {
147 Log(( "read number %s\n", N.latin1() )); 147 Log(( "Profile number %s\n", N.latin1() ));
148 setNumber( N.toLong() ); 148 setNumber( N.toLong() );
149 } else if( A == "node" ) { 149 } else if( A == "node" ) {
150 ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); 150 ANetNodeInstance * NNI = NSResources->findNodeInstance( N );
151 if( NNI && ! InError ) { 151 if( NNI && ! InError ) {
152 append( NSResources->findNodeInstance( N ) ); 152 append( NSResources->findNodeInstance( N ) );
153 } else { 153 } else {
154 // could not find a node type -> collection invalid 154 // could not find a node type -> collection invalid
155 InError = 1; 155 InError = 1;
156 } 156 }
157 } 157 }
158 } while( 1 ); 158 } while( 1 );
159} 159}
@@ -286,26 +286,45 @@ QString NodeCollection::stateName( State_t S) {
286 return QString(""); 286 return QString("");
287} 287}
288 288
289void NodeCollection::reassign( void ) { 289void NodeCollection::reassign( void ) {
290 for( QListIterator<ANetNodeInstance> it(*this); 290 for( QListIterator<ANetNodeInstance> it(*this);
291 it.current(); 291 it.current();
292 ++it ) { 292 ++it ) {
293 it.current()->setConnection( this ); 293 it.current()->setConnection( this );
294 } 294 }
295} 295}
296 296
297bool NodeCollection::triggersVPN() { 297bool NodeCollection::triggersVPN() {
298 return getToplevel()->runtime()->asFullSetup()->triggersVPN(); 298 return getToplevel()->runtime()->asFullSetup()->triggersVPN();
299} 299}
300
301bool NodeCollection::hasDataForFile( const QString & S ) {
302 return ( firstWithDataForFile( S ) != 0 );
303}
304
305ANetNodeInstance * NodeCollection::firstWithDataForFile( const QString & S ) {
306 for( QListIterator<ANetNodeInstance> it(*this);
307 it.current();
308 ++it ) {
309 if( it.current()->hasDataForFile( S ) ) {
310 Log(( "Node %s has data for %s\n",
311 it.current()->nodeClass()->name(),
312 S.latin1() ));
313 return it.current();
314 }
315 }
316 return 0;
317}
318
300// 319//
301// 320//
302// RUNTIMEINFO 321// RUNTIMEINFO
303// 322//
304// 323//
305 324
306InterfaceInfo * RuntimeInfo::assignedInterface( void ) { 325InterfaceInfo * RuntimeInfo::assignedInterface( void ) {
307 return netNode()->nextNode()->runtime()->assignedInterface(); 326 return netNode()->nextNode()->runtime()->assignedInterface();
308} 327}
309 328
310AsDevice * RuntimeInfo::device( void ) { 329AsDevice * RuntimeInfo::device( void ) {
311 return netNode()->nextNode()->runtime()->device(); 330 return netNode()->nextNode()->runtime()->device();
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index ca35c27..d3d7b34 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -1,19 +1,20 @@
1#ifndef NETNODE_H 1#ifndef NETNODE_H
2#define NETNODE_H 2#define NETNODE_H
3 3
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qlist.h> 5#include <qlist.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qstringlist.h>
8#include <qobject.h> 9#include <qobject.h>
9#include <time.h> 10#include <time.h>
10 11
11#include <Utils.h> 12#include <Utils.h>
12 13
13// difference feature interfaces 14// difference feature interfaces
14class AsDevice; 15class AsDevice;
15class AsLine; 16class AsLine;
16class AsConnection; 17class AsConnection;
17class AsFullSetup; 18class AsFullSetup;
18 19
19// needed for plugin creation function 20// needed for plugin creation function
@@ -23,216 +24,303 @@ class ANetNode;
23class ANetNodeInstance; 24class ANetNodeInstance;
24class NodeCollection; 25class NodeCollection;
25class QTextStream; 26class QTextStream;
26class RuntimeInfo; 27class RuntimeInfo;
27class InterfaceInfo; 28class InterfaceInfo;
28 29
29extern QString & deQuote( QString & X ); 30extern QString & deQuote( QString & X );
30extern QString quote( QString X ); 31extern QString quote( QString X );
31 32
32#include "systemfile.h" 33#include "systemfile.h"
33 34
34typedef enum State { 35typedef enum State {
35 // if we have not yet detected the state of the device 36 // if we have not yet detected the state of the device
36 Unchecked = 0, 37 Unchecked = 0,
37 // if we cannot determine the state 38 // if we cannot determine the state
38 Unknown = 1, 39 Unknown = 1,
39 // if connection cannot be established e.g. because 40 // if connection cannot be established e.g. because
40 // the hardware is not available 41 // the hardware is not available
41 Unavailable = 2, 42 Unavailable = 2,
42 // if the connection cannot be establishec but NOT 43 // if the connection cannot be establishec but NOT
43 // because it is physically impossible but because 44 // because it is physically impossible but because
44 // it has been disabled for FUNCTIONAL reasons 45 // it has been disabled for FUNCTIONAL reasons
45 Disabled = 3, 46 Disabled = 3,
46 // if connection is available to is currently down 47 // if connection is available to is currently down
47 // i.e. the corresponding hardware is not activated 48 // i.e. the corresponding hardware is not activated
48 Off = 4, 49 Off = 4,
49 // if connection is available to be used (i.e. the 50 // if connection is available to be used (i.e. the
50 // devices if fully ready to be used 51 // devices if fully ready to be used
51 Available = 5, 52 Available = 5,
52 // if connection is being used 53 // if connection is being used
53 IsUp = 6 54 IsUp = 6
54} State_t; 55} State_t;
55 56
56typedef enum Action { 57typedef enum Action {
57 // to make the device unavailable functionally 58 // to make the device unavailable functionally
58 Disable = 0, 59 Disable = 0,
59 // to make the device available functionally 60 // to make the device available functionally
60 Enable = 1, 61 Enable = 1,
61 // bring the hardware up 62 // bring the hardware up
62 Activate = 2, 63 Activate = 2,
63 // bring the hardware down 64 // bring the hardware down
64 Deactivate = 3, 65 Deactivate = 3,
65 // bring the connection up 66 // bring the connection up
66 Up = 4, 67 Up = 4,
67 // bring the connection down 68 // bring the connection down
68 Down = 5 69 Down = 5
69} Action_t; 70} Action_t;
70 71
71class ANetNode : public QObject{ 72class ANetNode : public QObject{
72 73
73public: 74public:
74 75
75 typedef QArray<ANetNode *> NetNodeList; 76 typedef QArray<ANetNode *> NetNodeList;
76 77
77 ANetNode( const char * Name ) : QObject( 0, Name ) {} 78 ANetNode( const char * Name ) : QObject( 0, Name ) {}
78 virtual ~ANetNode(){}; 79 virtual ~ANetNode(){};
79 80
80 // pixmap needed for this NetNode 81 //
81 virtual const QString pixmapName() = 0; 82 //
82 83 // standard methods with sensible default
83 // description for this NetNode 84 //
84 virtual const QString nodeDescription() = 0; 85 //
85 86
86 // create a blank instance of a net node 87 inline int done( void )
87 virtual ANetNodeInstance * createInstance( void ) = 0; 88 { return Done; }
88 89 inline void setDone( int D )
89 // return feature this NetNode provides 90 { Done = D; }
90 virtual const char * provides( void ) = 0; 91
91 virtual const char ** needs( void ) = 0; 92 // does this Node provide a Connection
92 93 inline bool isToplevel( void )
93 // generate files specific for this node (if any) 94 { return strcmp( provides(), "fullsetup") == 0 ; }
94 virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0; 95
95 // return TRUE if this node has data to be inserted in systemfile 96 // set the value of an attribute
96 // with name S 97 void setAttribute( QString & Attr, QString & Value ) ;
97 virtual bool hasDataFor( const QString & S ) = 0; 98 void saveAttributes( QTextStream & TS ) ;
98 // generate data specific for the device for the system file S 99
99 // called only IF data was needed 100 // compiled references to 'needed' NetNodes -> needs list
100 virtual bool generateDeviceDataForCommonFile( 101 inline void setAlternatives( NetNodeList * Alt )
101 SystemFile & SF, long DevNr ) = 0; 102 { Alternatives = Alt; }
102 103 inline NetNodeList & alternatives( void )
103 // does this Node provide a Connection 104 { return *Alternatives; }
104 bool isToplevel( void ) 105
105 { return strcmp( provides(), "fullsetup") == 0 ; } 106 //
106 107 //
107 // generate NIC name based on instance nr 108 // Virtual methods with sensible default
108 // only relevant if node instances are devices 109 //
109 virtual QString genNic( long ) 110 //
110 { return QString(""); } 111
111 112 // do instances of this noce class have data for this file
112 // max number of instances for this node type 113 virtual bool hasDataForFile( const QString & )
113 // only relevant if node instances are devices 114 { return 0; }
114 virtual long instanceCount( void ) 115
115 { return 1; } 116 // generate instance independent stuff
116 117 // 0 : data output, 1 no data, 2 error
117 // set the value of an attribute 118 virtual short generateFile( const QString & ,
118 void setAttribute( QString & Attr, QString & Value ) ; 119 const QString & ,
119 void saveAttributes( QTextStream & TS ) ; 120 QTextStream & ,
120 121 long )
121 // compiled references to 'needed' NetNodes -> needs list 122 { return 1; }
122 void setAlternatives( NetNodeList * Alt ) 123
123 { Alternatives = Alt; } 124 // generate instance dependent but profile common stuff
124 NetNodeList & alternatives( void ) 125 // 0 : data output, 1 no data, 2 error
125 { return *Alternatives; } 126 virtual short generateFile( const QString & ,
127 const QString & ,
128 QTextStream & ,
129 ANetNodeInstance * ,
130 long )
131 { return 1; }
132
133
134 // generate NIC name based on instance nr
135 // only relevant if node instances are devices
136 virtual QString genNic( long )
137 { return QString(""); }
138
139 // max number of instances for this node type
140 // only relevant if node instances are devices
141 virtual long instanceCount( void )
142 { return 1; }
143
144 // return list of files that are specific for this node class
145 virtual QStringList * properFiles( void )
146 { return 0; }
147
148 //
149 //
150 // pure virtual methods with sensible default
151 //
152 //
153
154 // pixmap needed for this NetNode
155 virtual const QString pixmapName() = 0;
156
157 // description for this NetNode
158 virtual const QString nodeDescription() = 0;
159
160 // create a blank instance of a net node
161 virtual ANetNodeInstance * createInstance( void ) = 0;
162
163 // return feature this NetNode provides
164 virtual const char * provides( void ) = 0;
165 virtual const char ** needs( void ) = 0;
126 166
127protected : 167protected :
128 168
129 NetNodeList * Alternatives; 169 NetNodeList * Alternatives;
130 170
131private : 171private :
132 172
133 virtual void setSpecificAttribute( QString & , QString & ) = 0; 173 virtual void setSpecificAttribute( QString & , QString & ) = 0;
134 virtual void saveSpecificAttribute( QTextStream & ) = 0; 174 virtual void saveSpecificAttribute( QTextStream & ) = 0;
175 int Done;
135 176
136}; 177};
137 178
138class ANetNodeInstance : public QObject { 179class ANetNodeInstance : public QObject {
139 180
140public: 181public:
141 182
142 ANetNodeInstance( ANetNode * NN ) : QObject() 183 ANetNodeInstance( ANetNode * NN ) : QObject()
143 { IsModified=0; NodeType = NN; IsNew = TRUE; } 184 { IsModified=0; NodeType = NN; IsNew = TRUE; }
144 virtual ~ANetNodeInstance( void ) { } 185 virtual ~ANetNodeInstance( void ) { }
145 186
146 virtual RuntimeInfo * runtime( void ) = 0; 187 inline int done( void )
147 188 { return Done; }
148 void setConnection( NodeCollection * NC ) 189 inline void setDone( int D )
149 { Connection = NC; } 190 { Done = D; }
150 NodeCollection * connection( void ) 191
151 { return Connection; } 192 // return data was modified
152 193 inline void setModified( bool M )
153 // create edit widget under parent 194 { IsModified = M; }
154 virtual QWidget * edit( QWidget * parent ) = 0; 195 inline bool isModified( void )
155 // is given data acceptable 196 { return IsModified; }
156 virtual QString acceptable( void ) = 0; 197
157 198 // get next node
158 // return data was modified 199 ANetNodeInstance * nextNode();
159 void setModified( bool M ) 200 // return NetNode this is an instance of
160 { IsModified = M; } 201 ANetNode * nodeClass( void )
161 bool isModified( void ) 202 { return NodeType; }
162 { return IsModified; } 203
163 204 // intialize am instance of a net node
164 // get data from GUI and store in node 205 void initialize( void );
165 virtual void commit( void ) = 0; 206
166 207 // set the value of an attribute
167 // get next node 208 void setAttribute( QString & Attr, QString & Value ) ;
168 ANetNodeInstance * nextNode(); 209 void saveAttributes( QTextStream & TS ) ;
169 // return NetNode this is an instance of 210
170 ANetNode * nodeClass( void ) 211 // return true if node isntance is NEW and not loaded
171 { return NodeType; } 212 inline void setNew( bool IsN )
172 213 { IsNew = IsN; }
173 // intialize am instance of a net node 214 inline bool isNew( void )
174 void initialize( void ); 215 { return IsNew; }
175 216
176 // set the value of an attribute 217 // return description for this instance
177 void setAttribute( QString & Attr, QString & Value ) ; 218 inline QString & description( void )
178 void saveAttributes( QTextStream & TS ) ; 219 { return Description; }
220 inline void setDescription( const QString & S )
221 { Description = S; }
222
223 // pixmap for this instance -> from NetNode
224 inline const QString pixmapName( void )
225 { return NodeType->pixmapName(); }
226
227 inline const char * provides( void )
228 { return NodeType->provides(); }
229
230 inline const char ** needs( void )
231 { return NodeType->needs(); }
232
233 inline void setConnection( NodeCollection * NC )
234 { Connection = NC; }
235 inline NodeCollection * connection( void )
236 { return Connection; }
237
238 //
239 //
240 // Virtual methods with sensible defaults
241 //
242 //
243
244
245
246 // open proper file identified by S
247 virtual QFile * openFile( const QString & )
248 { return 0; }
249
250 // check if this node (or sub nodes) have data for this file
251 virtual bool hasDataForFile( const QString & S )
252 { return nodeClass()->hasDataForFile( S ); }
253
254 // generate code specific for this node but embedded
255 // in the section of the parent
256 // this is called within the code of the parent
257 virtual short generateFileEmbedded( const QString & ID,
258 const QString & Path,
259 QTextStream & TS,
260 long DevNr )
261 { ANetNodeInstance * NNI = nextNode();
262 return (NNI) ? NNI->generateFileEmbedded( ID, Path, TS, DevNr ) : 1;
263 }
179 264
180 // return true if node isntance is NEW and not loaded 265 // generate code specific for this node
181 void setNew( bool IsN ) 266 // (or find the first node that does)
182 { IsNew = IsN; } 267 virtual short generateFile( const QString & ID,
183 bool isNew( void ) 268 const QString & Path,
184 { return IsNew; } 269 QTextStream & TS,
270 long DevNr )
271 { ANetNodeInstance * NNI = nextNode();
272 return (NNI) ? NNI->generateFile( ID, Path, TS, DevNr ) : 1;
273 }
185 274
186 // return description for this instance 275 // return true if this node instance is triggered by this trigger
187 QString & description( void ) 276 // could be delegated to deeper instances
188 { return Description; } 277 virtual bool triggeredBy( const QString & )
189 void setDescription( const QString & S ) 278 { return 0; }
190 { Description = S; }
191 279
192 // pixmap for this instance -> from NetNode 280 //
193 const QString pixmapName( void ) 281 //
194 { return NodeType->pixmapName(); } 282 // Pure virtual functions
283 //
284 //
195 285
196 const char * provides( void ) 286 // return runtime information for this node
197 { return NodeType->provides(); } 287 virtual RuntimeInfo * runtime( void ) = 0;
198 288
199 const char ** needs( void ) 289 // create edit widget under parent
200 { return NodeType->needs(); } 290 virtual QWidget * edit( QWidget * parent ) = 0;
201 291
202 // returns node specific data -> only useful for 'buddy' 292 // is given data acceptable
203 virtual void * data( void ) = 0; 293 virtual QString acceptable( void ) = 0;
204 294
205 // return TRUE if this node has data to be inserted in systemfile 295 // get data from GUI and store in node
206 // with name S 296 virtual void commit( void ) = 0;
207 virtual bool hasDataFor( const QString & S ) = 0;
208 297
209 // generate data specific for a profile and for the system file S 298 // returns node specific data -> only useful for 'buddy'
210 // called only IF data was needed 299 virtual void * data( void ) = 0;
211 virtual bool generateDataForCommonFile(
212 SystemFile & SF, long DevNr ) = 0;
213 300
214protected : 301protected :
215 302
216 virtual void setSpecificAttribute( QString & , QString & ) = 0; 303 virtual void setSpecificAttribute( QString & , QString & ) = 0;
217 virtual void saveSpecificAttribute( QTextStream & ) = 0; 304 virtual void saveSpecificAttribute( QTextStream & ) = 0;
218 305
219 ANetNode * NodeType; 306 ANetNode * NodeType;
220 // connection to which this node belongs to 307 // connection to which this node belongs to
221 NodeCollection * Connection; 308 NodeCollection * Connection;
222 QString Description; 309 QString Description;
223 bool IsModified; 310 bool IsModified;
224 bool IsNew; 311 bool IsNew;
312 int Done;
225 313
226 static long InstanceCounter; 314 static long InstanceCounter;
227}; 315};
228 316
229class RuntimeInfo : public QObject { 317class RuntimeInfo : public QObject {
230 318
231 Q_OBJECT 319 Q_OBJECT
232 320
233public : 321public :
234 322
235 RuntimeInfo( ANetNodeInstance * TheNNI ) 323 RuntimeInfo( ANetNodeInstance * TheNNI )
236 { NNI = TheNNI; } 324 { NNI = TheNNI; }
237 325
238 // downcast implemented by specify runtime classes 326 // downcast implemented by specify runtime classes
@@ -273,112 +361,134 @@ protected :
273 // connection this runtime info belongs to 361 // connection this runtime info belongs to
274 ANetNodeInstance * NNI; 362 ANetNodeInstance * NNI;
275}; 363};
276 364
277class NodeCollection : public QList<ANetNodeInstance> { 365class NodeCollection : public QList<ANetNodeInstance> {
278 366
279public : 367public :
280 368
281 NodeCollection( void ); 369 NodeCollection( void );
282 NodeCollection( QTextStream & TS ); 370 NodeCollection( QTextStream & TS );
283 ~NodeCollection( void ); 371 ~NodeCollection( void );
284 372
285 int number( void ) 373 inline int done( void )
374 { return Done; }
375 inline void setDone( int D )
376 { Done = D; }
377
378 inline int number( void )
286 { return Number; } 379 { return Number; }
287 void setNumber( int i ) 380 inline void setNumber( int i )
288 { Number = i; } 381 { Number = i; }
289 bool isNew( void ) 382 inline bool isNew( void )
290 { return IsNew; } 383 { return IsNew; }
291 void setNew( bool N ) 384 inline void setNew( bool N )
292 { IsNew = N ; } 385 { IsNew = N ; }
293 bool isModified( void ) 386 inline bool isModified( void )
294 { return IsModified; } 387 { return IsModified; }
295 void setModified( bool N ) 388 inline void setModified( bool N )
296 { IsModified = N ; } 389 { IsModified = N ; }
297 390
298 bool handlesInterface( const QString & S ) { 391 inline bool handlesInterface( const QString & S ) {
299 return getToplevel()->runtime()->handlesInterface( S ); 392 return getToplevel()->runtime()->handlesInterface( S );
300 } 393 }
301 394
302 InterfaceInfo * assignedInterface( void ) { 395 inline InterfaceInfo * assignedInterface( void ) {
303 return getToplevel()->runtime()->assignedInterface(); 396 return getToplevel()->runtime()->assignedInterface();
304 } 397 }
305 398
306 AsDevice * device() { 399 inline AsDevice * device() {
307 return getToplevel()->runtime()->device(); 400 return getToplevel()->runtime()->device();
308 } 401 }
309 402
310 bool triggersVPN(); 403 bool triggersVPN();
311 404
312 State_t state( bool Update = 0 ) 405 inline State_t state( bool Update = 0 )
313 { Log(( "%s state %d(=%d?)\n", Name.latin1(), CurrentState, 406 { Log(( "%s state %d(=%d?)\n", Name.latin1(), CurrentState,
314 Unchecked )); 407 Unchecked ));
315 if( CurrentState == Unchecked || Update ) { 408 if( CurrentState == Unchecked || Update ) {
316 Log(( "TL %p TLR %p\n", 409 Log(( "TL %p TLR %p\n",
317 getToplevel(), 410 getToplevel(),
318 getToplevel()->runtime() )); 411 getToplevel()->runtime() ));
319 // need to get current state 412 // need to get current state
320 getToplevel()->runtime()->detectState( this ); 413 getToplevel()->runtime()->detectState( this );
321 } 414 }
322 return CurrentState; 415 return CurrentState;
323 } 416 }
324 417
325 // get the ixmap for this device 418 // get the ixmap for this device
326 QPixmap devicePixmap( void ); 419 QPixmap devicePixmap( void );
327 QPixmap statePixmap( State_t S ); 420 QPixmap statePixmap( State_t S );
328 QPixmap statePixmap( bool Update = 0 ) 421 inline QPixmap statePixmap( bool Update = 0 )
329 { return statePixmap( state(Update) ); } 422 { return statePixmap( state(Update) ); }
330 QString stateName( State_t ); 423 QString stateName( State_t );
331 QString stateName( bool Update = 0 ) 424 inline QString stateName( bool Update = 0 )
332 { return stateName( state(Update) ); } 425 { return stateName( state(Update) ); }
333 426
334 bool setState( Action_t A, bool Force =0 ) 427 inline bool setState( Action_t A, bool Force =0 )
335 { return getToplevel()->runtime()->setState( this, A, Force ); } 428 { return getToplevel()->runtime()->setState( this, A, Force ); }
336 bool canSetState( Action_t A ) 429 inline bool canSetState( Action_t A )
337 { return getToplevel()->runtime()->canSetState( CurrentState, A ); } 430 { return getToplevel()->runtime()->canSetState( CurrentState, A ); }
338 431
339 void save( QTextStream & TS ); 432 void save( QTextStream & TS );
340 433
341 void append( ANetNodeInstance * NNI ); 434 void append( ANetNodeInstance * NNI );
342 435
343 // makes sure that all items in the connection point to 436 // makes sure that all items in the connection point to
344 // that connectoin 437 // that connectoin
345 void reassign( void ); 438 void reassign( void );
346 439
347 ANetNodeInstance * getToplevel( void ); 440 ANetNodeInstance * getToplevel( void );
348 ANetNodeInstance * findNext( ANetNodeInstance * NNI ); 441 ANetNodeInstance * findNext( ANetNodeInstance * NNI );
349 ANetNodeInstance * findByName( const QString & S ); 442 ANetNodeInstance * findByName( const QString & S );
350 443
351 const QString & name() 444 inline const QString & name()
352 { return Name; } 445 { return Name; }
353 446
354 const QString & description( void ); 447 const QString & description( void );
355 448
356 void setName( const QString & N) 449 inline void setName( const QString & N)
357 { Name = N; } 450 { Name = N; }
358 451
359 State_t currentState( void ) 452 inline State_t currentState( void )
360 { return CurrentState; } 453 { return CurrentState; }
361 void setCurrentState( State_t S ) 454 inline void setCurrentState( State_t S )
362 { CurrentState = S; } 455 { CurrentState = S; }
363 456
457 // return TRUE if this node can have data to be inserted in
458 // file identified by S
459 bool hasDataForFile( const QString & S );
460 ANetNodeInstance * firstWithDataForFile( const QString & S );
461
462 // generate items for this file -> toplevel call
463 short generateFile( const QString & FID, // identification of file
464 const QString & FName, // effective filename of file
465 QTextStream & TS, // stream to file
466 long DN // device number
467 )
468 { return getToplevel()->generateFile( FID, FName, TS, DN ); }
469
470 bool triggeredBy( const QString & Trigger )
471 { return getToplevel()->triggeredBy( Trigger ); }
472
364private : 473private :
365 474
366 int compareItems ( QCollection::Item item1, 475 int compareItems ( QCollection::Item item1,
367 QCollection::Item item2 ); 476 QCollection::Item item2 );
368 477
369 long Number; 478 long Number;
370 479
371 // state of this connection 480 // state of this connection
372 State_t CurrentState; 481 State_t CurrentState;
373 482
374 QString Name; 483 QString Name;
375 // true if this collection was just created (and not 484 // true if this collection was just created (and not
376 // loaded from file 485 // loaded from file
377 bool IsNew; 486 bool IsNew;
378 // index in listbox 487 // index in listbox
379 int Index; 488 int Index;
380 bool IsModified; 489 bool IsModified;
490 int Done;
381 491
382}; 492};
383 493
384#endif 494#endif
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp
index 71e84cd..7ece817 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.cpp
+++ b/noncore/settings/networksettings2/networksettings2/resources.cpp
@@ -68,36 +68,45 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(),
68 NodeTypeNameMap.insert( "fullsetup", tr( "Connection Profile" ) ); 68 NodeTypeNameMap.insert( "fullsetup", tr( "Connection Profile" ) );
69 69
70 NodeTypeDescriptionMap.insert( "device", 70 NodeTypeDescriptionMap.insert( "device",
71 tr( "<p>Devices that can handle IP packets</p>" ) ); 71 tr( "<p>Devices that can handle IP packets</p>" ) );
72 NodeTypeDescriptionMap.insert( "line", 72 NodeTypeDescriptionMap.insert( "line",
73 tr( "<p>Devices that can handle single bytes</p>" ) ); 73 tr( "<p>Devices that can handle single bytes</p>" ) );
74 NodeTypeDescriptionMap.insert( "connection", 74 NodeTypeDescriptionMap.insert( "connection",
75 tr( "<p>Nodes that provide working IP connections</p>" ) ); 75 tr( "<p>Nodes that provide working IP connections</p>" ) );
76 NodeTypeDescriptionMap.insert( "fullsetup", 76 NodeTypeDescriptionMap.insert( "fullsetup",
77 tr( "<p>Fully configured connection profile</p>" ) ); 77 tr( "<p>Fully configured connection profile</p>" ) );
78 78
79 // define system files 79 // define system files
80 addSystemFile( new SystemFile( "interfaces", "./interfaces" ) ); 80 addSystemFile( "interfaces", "/tmp/interfaces", 1 );
81 81
82 // get access to the system 82 // get access to the system
83 TheSystem = new System(); 83 TheSystem = new System();
84 84
85} 85}
86 86
87TheNSResources::~TheNSResources( void ) { 87TheNSResources::~TheNSResources( void ) {
88 delete TheSystem; 88 delete TheSystem;
89} 89}
90 90
91void TheNSResources::busy( bool B ) { 91void TheNSResources::addSystemFile( const QString & ID,
92 const QString & P,
93 bool KDI ) {
94 if( ! SystemFiles.find( ID ) ) {
95 // new system file
96 SystemFiles.insert( ID, new SystemFile( ID, P, KDI ) );
97 } // else existed
98}
99
100void TheNSResources::busy( bool ) {
92/* 101/*
93 if( B ) { 102 if( B ) {
94 ShowWait->show(); 103 ShowWait->show();
95 qApp->process 104 qApp->process
96 } else { 105 } else {
97 ShowWait->hide(); 106 ShowWait->hide();
98 } 107 }
99*/ 108*/
100} 109}
101 110
102/** 111/**
103 * Load all modules that are found in the path 112 * Load all modules that are found in the path
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h
index 55d2f29..16355ba 100644
--- a/noncore/settings/networksettings2/networksettings2/resources.h
+++ b/noncore/settings/networksettings2/networksettings2/resources.h
@@ -57,26 +57,27 @@ public :
57 57
58 Name2NetNode_t & netNodes( void ) 58 Name2NetNode_t & netNodes( void )
59 { return AllNodeTypes; } 59 { return AllNodeTypes; }
60 bool netNodeExists( const QString & X ) 60 bool netNodeExists( const QString & X )
61 { return AllNodeTypes.find(X)!=0; } 61 { return AllNodeTypes.find(X)!=0; }
62 ANetNode * findNetNode( const QString & N ) 62 ANetNode * findNetNode( const QString & N )
63 { NetNode_t * NNT = AllNodeTypes.find(N); 63 { NetNode_t * NNT = AllNodeTypes.find(N);
64 return (NNT) ? NNT->NetNode : 0; 64 return (NNT) ? NNT->NetNode : 0;
65 } 65 }
66 66
67 Name2SystemFile_t & systemFiles( void ) 67 Name2SystemFile_t & systemFiles( void )
68 { return SystemFiles; } 68 { return SystemFiles; }
69 void addSystemFile( SystemFile * SF ) 69 void addSystemFile( const QString & ID,
70 { SystemFiles.insert( SF->name(), SF ); } 70 const QString & P,
71 bool KDI );
71 72
72 ANetNodeInstance * createNodeInstance( const QString & S ) 73 ANetNodeInstance * createNodeInstance( const QString & S )
73 { ANetNodeInstance * NNI = 0; 74 { ANetNodeInstance * NNI = 0;
74 NetNode_t * NNT = AllNodeTypes[S]; 75 NetNode_t * NNT = AllNodeTypes[S];
75 if( ! NNT ) { 76 if( ! NNT ) {
76 return 0; 77 return 0;
77 } 78 }
78 NNI = NNT->NetNode->createInstance(); 79 NNI = NNT->NetNode->createInstance();
79 NNI->initialize(); 80 NNI->initialize();
80 return NNI; 81 return NNI;
81 } 82 }
82 83
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index a579396..271e73d 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -381,37 +381,49 @@ void System::execAsUser( QString & Cmd, char * argv[] ) {
381 Log(("Could not exec : %d\n", errno )); 381 Log(("Could not exec : %d\n", errno ));
382} 382}
383 383
384#include <stdarg.h> 384#include <stdarg.h>
385static FILE * logf = 0; 385static FILE * logf = 0;
386 386
387void VLog( char * Format, ... ) { 387void VLog( char * Format, ... ) {
388 va_list l; 388 va_list l;
389 389
390 va_start(l, Format ); 390 va_start(l, Format );
391 391
392 if( logf == (FILE *)0 ) { 392 if( logf == (FILE *)0 ) {
393 // logf = fopen( "/tmp/ns2log", "a" ); 393 if( getenv("NS2STDERR") ) {
394 logf = stderr; 394 logf = stderr;
395 } else {
396 logf = fopen( "/tmp/ns2log", "a" );
397 }
395 if( ! logf ) { 398 if( ! logf ) {
396 fprintf( stderr, "Cannot open logfile /tmp/ns2log %d\n", 399 fprintf( stderr, "Cannot open logfile /tmp/ns2log %d\n",
397 errno ); 400 errno );
398 logf = (FILE *)1; 401 logf = (FILE *)1;
399 } else { 402 } else {
400 fprintf( logf, "____ OPEN LOGFILE ____\n"); 403 fprintf( logf, "____ OPEN LOGFILE ____\n");
401 } 404 }
402 } 405 }
403 406
404 if( (long)logf > 1 ) { 407 if( (long)logf > 1 ) {
405 vfprintf( logf, Format, l ); 408 vfprintf( logf, Format, l );
406 } 409 }
407 va_end( l ); 410 va_end( l );
408 411
409} 412}
410 413
411void LogClose( void ) { 414void LogClose( void ) {
412 if( (long)logf > 1 ) { 415 if( (long)logf > 1 ) {
413 fprintf( logf, "____ CLOSE LOGFILE ____\n"); 416 fprintf( logf, "____ CLOSE LOGFILE ____\n");
414 fclose( logf ); 417 if( logf != stderr ) {
418 fclose( logf );
419 }
415 logf = 0; 420 logf = 0;
416 } 421 }
417} 422}
423
424QString removeSpaces( const QString & X ) {
425 QStringList SL;
426
427 SL = QStringList::split( " ", X );
428 return SL.join( "_" );
429}
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
index b3fc1a5..2b40834 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
@@ -2,25 +2,27 @@
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qfileinfo.h> 3#include <qfileinfo.h>
4#include <qmessagebox.h> 4#include <qmessagebox.h>
5#include <qfile.h> 5#include <qfile.h>
6#include <qtextstream.h> 6#include <qtextstream.h>
7 7
8#include "resources.h" 8#include "resources.h"
9#include "systemfile.h" 9#include "systemfile.h"
10 10
11#define TEMPLATEDIR "networktemplates/" 11#define TEMPLATEDIR "networktemplates/"
12QString TemplDir; 12QString TemplDir;
13 13
14SystemFile::SystemFile( const QString & N, const QString & P ){ 14SystemFile::SystemFile( const QString & N,
15 const QString & P,
16 bool KDI ){
15 Name = N; 17 Name = N;
16 Path = P; 18 Path = P;
17 F = 0; 19 F = 0;
18 // get template info 20 // get template info
19 { QString S; 21 { QString S;
20 QFileInfo FI; 22 QFileInfo FI;
21 23
22 // find location of templates 24 // find location of templates
23 TemplDir = QPEApplication::qpeDir() + "etc/" + TEMPLATEDIR; 25 TemplDir = QPEApplication::qpeDir() + "etc/" + TEMPLATEDIR;
24 FI.setFile( TemplDir ); 26 FI.setFile( TemplDir );
25 if( ! FI.isDir() ) { 27 if( ! FI.isDir() ) {
26 // try current dir 28 // try current dir
@@ -48,24 +50,26 @@ SystemFile::SystemFile( const QString & N, const QString & P ){
48 FI.setFile( S ); 50 FI.setFile( S );
49 hasPreNodeSection = ( FI.exists() && FI.isReadable() ); 51 hasPreNodeSection = ( FI.exists() && FI.isReadable() );
50 S = TemplDir + Name + "/postnodesection"; 52 S = TemplDir + Name + "/postnodesection";
51 FI.setFile( S ); 53 FI.setFile( S );
52 hasPostNodeSection = ( FI.exists() && FI.isReadable() ); 54 hasPostNodeSection = ( FI.exists() && FI.isReadable() );
53 S = TemplDir + Name + "/predevicesection"; 55 S = TemplDir + Name + "/predevicesection";
54 FI.setFile( S ); 56 FI.setFile( S );
55 hasPreDeviceSection = ( FI.exists() && FI.isReadable() ); 57 hasPreDeviceSection = ( FI.exists() && FI.isReadable() );
56 S = TemplDir + Name + "/postdevicesection"; 58 S = TemplDir + Name + "/postdevicesection";
57 FI.setFile( S ); 59 FI.setFile( S );
58 hasPostDeviceSection = ( FI.exists() && FI.isReadable() ); 60 hasPostDeviceSection = ( FI.exists() && FI.isReadable() );
59 } 61 }
62
63 KnowsDeviceInstances = KDI;
60} 64}
61 65
62SystemFile::~SystemFile( void ) { 66SystemFile::~SystemFile( void ) {
63 if( F ) 67 if( F )
64 delete F; 68 delete F;
65} 69}
66 70
67bool SystemFile::open( void ) { 71bool SystemFile::open( void ) {
68 if( F ) { 72 if( F ) {
69 F->close(); 73 F->close();
70 delete F; 74 delete F;
71 } 75 }
@@ -87,99 +91,99 @@ bool SystemFile::close( void ) {
87 91
88 F->close(); 92 F->close();
89 delete F; 93 delete F;
90 F = 0; 94 F = 0;
91 95
92 return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); 96 return ( rename( OldP.latin1(), Path.latin1() ) >= 0 );
93} 97}
94 98
95bool SystemFile::preSection( void ) { 99bool SystemFile::preSection( void ) {
96 if( hasPreSection ) { 100 if( hasPreSection ) {
97 QFile Fl( TemplDir + Name + "/presection" ); 101 QFile Fl( TemplDir + Name + "/presection" );
98 if( ! Fl.open( IO_ReadOnly ) ) 102 if( ! Fl.open( IO_ReadOnly ) )
99 return 1; // error 103 return 0; // error
100 // copy file to this file 104 // copy file to this file
101 F->writeBlock( Fl.readAll() ); 105 F->writeBlock( Fl.readAll() );
102 } 106 }
103 return 0; 107 return 1;
104} 108}
105 109
106bool SystemFile::postSection( void ) { 110bool SystemFile::postSection( void ) {
107 if( hasPostSection ) { 111 if( hasPostSection ) {
108 QFile Fl( TemplDir + Name + "/postsection" ); 112 QFile Fl( TemplDir + Name + "/postsection" );
109 if( ! Fl.open( IO_ReadOnly ) ) 113 if( ! Fl.open( IO_ReadOnly ) )
110 return 1; // error 114 return 0; // error
111 // copy file to this file 115 // copy file to this file
112 F->writeBlock( Fl.readAll() ); 116 F->writeBlock( Fl.readAll() );
113 } 117 }
114 return 0; 118 return 1;
115} 119}
116 120
117bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { 121bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) {
118 if( hasPreNodeSection ) { 122 if( hasPreNodeSection ) {
119 QFile Fl( TemplDir + Name + "/prenodesection" ); 123 QFile Fl( TemplDir + Name + "/prenodesection" );
120 if( ! Fl.open( IO_ReadOnly ) ) 124 if( ! Fl.open( IO_ReadOnly ) )
121 return 1; // error 125 return 0; // error
122 QTextStream TX( &Fl ); 126 QTextStream TX( &Fl );
123 QString Out; 127 QString Out;
124 QString S = TX.readLine(); 128 QString S = TX.readLine();
125 while( ! TX.eof() ) { 129 while( ! TX.eof() ) {
126 Out = S. 130 Out = S.
127 arg(NNI->nodeClass()->name()); 131 arg(NNI->nodeClass()->name());
128 (*this) << Out << endl; 132 (*this) << Out << endl;
129 S = TX.readLine(); 133 S = TX.readLine();
130 } 134 }
131 } 135 }
132 return 0; 136 return 1;
133} 137}
134 138
135bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) { 139bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) {
136 if( hasPostNodeSection ) { 140 if( hasPostNodeSection ) {
137 QFile Fl( TemplDir + Name + "/postnodesection" ); 141 QFile Fl( TemplDir + Name + "/postnodesection" );
138 if( ! Fl.open( IO_ReadOnly ) ) 142 if( ! Fl.open( IO_ReadOnly ) )
139 return 1; // error 143 return 0; // error
140 QTextStream TX( &Fl ); 144 QTextStream TX( &Fl );
141 QString Out; 145 QString Out;
142 QString S = TX.readLine(); 146 QString S = TX.readLine();
143 while( ! TX.eof() ) { 147 while( ! TX.eof() ) {
144 Out = S. 148 Out = S.
145 arg(NNI->name()); 149 arg(NNI->name());
146 (*this) << Out << endl; 150 (*this) << Out << endl;
147 S = TX.readLine(); 151 S = TX.readLine();
148 } 152 }
149 } 153 }
150 return 0; 154 return 1;
151} 155}
152 156
153bool SystemFile::preDeviceSection( ANetNode * NN ) { 157bool SystemFile::preDeviceSection( ANetNode * NN ) {
154 if( hasPreDeviceSection ) { 158 if( hasPreDeviceSection ) {
155 QFile Fl( TemplDir + Name + "/predevicesection" ); 159 QFile Fl( TemplDir + Name + "/predevicesection" );
156 if( ! Fl.open( IO_ReadOnly ) ) 160 if( ! Fl.open( IO_ReadOnly ) )
157 return 1; // error 161 return 0; // error
158 QTextStream TX( &Fl ); 162 QTextStream TX( &Fl );
159 QString Out; 163 QString Out;
160 QString S = TX.readLine(); 164 QString S = TX.readLine();
161 while( ! TX.eof() ) { 165 while( ! TX.eof() ) {
162 Out = S.arg(NN->name()); 166 Out = S.arg(NN->name());
163 (*this) << Out << endl; 167 (*this) << Out << endl;
164 S = TX.readLine(); 168 S = TX.readLine();
165 } 169 }
166 } 170 }
167 return 0; 171 return 1;
168} 172}
169 173
170bool SystemFile::postDeviceSection( ANetNode * NN ) { 174bool SystemFile::postDeviceSection( ANetNode * NN ) {
171 if( hasPostDeviceSection ) { 175 if( hasPostDeviceSection ) {
172 QFile Fl( TemplDir + Name + "/postdevicesection" ); 176 QFile Fl( TemplDir + Name + "/postdevicesection" );
173 if( ! Fl.open( IO_ReadOnly ) ) 177 if( ! Fl.open( IO_ReadOnly ) )
174 return 1; // error 178 return 0; // error
175 QTextStream TX( &Fl ); 179 QTextStream TX( &Fl );
176 QString Out; 180 QString Out;
177 QString S = TX.readLine(); 181 QString S = TX.readLine();
178 while( ! TX.eof() ) { 182 while( ! TX.eof() ) {
179 Out = S.arg(NN->name()); 183 Out = S.arg(NN->name());
180 (*this) << Out << endl; 184 (*this) << Out << endl;
181 S = TX.readLine(); 185 S = TX.readLine();
182 } 186 }
183 } 187 }
184 return 0; 188 return 1;
185} 189}
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.h b/noncore/settings/networksettings2/networksettings2/systemfile.h
index f57dab0..ceed605 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.h
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.h
@@ -2,42 +2,49 @@
2#define __SYSTEMFILE__H 2#define __SYSTEMFILE__H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qtextstream.h> 5#include <qtextstream.h>
6 6
7class QFile; 7class QFile;
8class ANetNodeInstance; 8class ANetNodeInstance;
9 9
10class SystemFile : public QTextStream { 10class SystemFile : public QTextStream {
11 11
12public : 12public :
13 13
14 SystemFile( const QString & Name, const QString & Path ); 14 SystemFile( const QString & Name,
15 const QString & Path,
16 bool KnowsDevicesInstances );
15 ~SystemFile( void ); 17 ~SystemFile( void );
16 18
17 const QString & name( void ) 19 const QString & name( void ) const
18 { return Name; } 20 { return Name; }
21 const QString & path( void ) const
22 { return Path; }
23 bool knowsDeviceInstances( void ) const
24 { return KnowsDeviceInstances; }
19 25
20 bool open( void ); 26 bool open( void );
21 bool close( void ); 27 bool close( void );
22 28
23 bool preSection( void ); 29 bool preSection( void );
24 bool postSection( void ); 30 bool postSection( void );
25 bool preNodeSection( ANetNodeInstance * NNI, long DevNr ); 31 bool preNodeSection( ANetNodeInstance * NNI, long DevNr );
26 bool postNodeSection( ANetNodeInstance * NNI, long DevNr ); 32 bool postNodeSection( ANetNodeInstance * NNI, long DevNr );
27 bool preDeviceSection( ANetNode * NN ); 33 bool preDeviceSection( ANetNode * NN );
28 bool postDeviceSection( ANetNode * NN ); 34 bool postDeviceSection( ANetNode * NN );
29 35
30private : 36private :
31 37
32 QString Name; 38 QString Name;
33 QString Path; 39 QString Path;
34 QFile * F; 40 QFile * F;
35 bool hasPreSection; 41 bool hasPreSection;
36 bool hasPostSection; 42 bool hasPostSection;
37 bool hasPreNodeSection; 43 bool hasPreNodeSection;
38 bool hasPostNodeSection; 44 bool hasPostNodeSection;
39 bool hasPreDeviceSection; 45 bool hasPreDeviceSection;
40 bool hasPostDeviceSection; 46 bool hasPostDeviceSection;
47 bool KnowsDeviceInstances;
41 48
42}; 49};
43#endif 50#endif
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index 3b17548..d709c0a 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -11,25 +11,24 @@
11 11
12static QString CfgFile; 12static QString CfgFile;
13 13
14NetworkSettingsData::NetworkSettingsData( void ) { 14NetworkSettingsData::NetworkSettingsData( void ) {
15 // init global resources structure 15 // init global resources structure
16 new TheNSResources(); 16 new TheNSResources();
17 17
18 CfgFile.sprintf( "%s/Settings/NS2.conf", 18 CfgFile.sprintf( "%s/Settings/NS2.conf",
19 NSResources->currentUser().HomeDir.latin1() ); 19 NSResources->currentUser().HomeDir.latin1() );
20 Log(( "Cfg from %s\n", CfgFile.latin1() )); 20 Log(( "Cfg from %s\n", CfgFile.latin1() ));
21 21
22 // load settings 22 // load settings
23 Force = 0;
24 IsModified = 0; 23 IsModified = 0;
25 loadSettings(); 24 loadSettings();
26} 25}
27 26
28// saving is done by caller 27// saving is done by caller
29NetworkSettingsData::~NetworkSettingsData( void ) { 28NetworkSettingsData::~NetworkSettingsData( void ) {
30 delete NSResources; 29 delete NSResources;
31} 30}
32 31
33void NetworkSettingsData::loadSettings( void ) { 32void NetworkSettingsData::loadSettings( void ) {
34 QString Line, S; 33 QString Line, S;
35 QString Attr, Value; 34 QString Attr, Value;
@@ -209,184 +208,306 @@ QString NetworkSettingsData::saveSettings( void ) {
209 208
210 QDir D("."); 209 QDir D(".");
211 D.rename( CfgFile + ".bup", CfgFile ); 210 D.rename( CfgFile + ".bup", CfgFile );
212 211
213 // 212 //
214 // proper files AND system files regenerated 213 // proper files AND system files regenerated
215 // 214 //
216 215
217 setModified( 0 ); 216 setModified( 0 );
218 return ErrS; 217 return ErrS;
219} 218}
220 219
221QString NetworkSettingsData::generateSettings( bool ForceReq ) { 220QString NetworkSettingsData::generateSettings( void ) {
222 bool ForceIt;
223 QString S = ""; 221 QString S = "";
224 222 Name2SystemFile_t & SFM = NSResources->systemFiles();
225 // include own force flag 223 Name2Connection_t & M = NSResources->connections();
226 ForceIt = (Force) ? 1 : ForceReq; 224 NodeCollection * NC;
227 225 ANetNodeInstance * NNI;
228 if( ! ForceIt && ! isModified() ) 226 ANetNodeInstance * FirstWithData;
229 return S; 227 SystemFile * SF;
228 AsDevice * CurDev;
229 ANetNode * NN, * CurDevNN = 0;
230 long NoOfDevs;
231 long DevCtStart;
232 bool needToGenerate;
230 233
231 // regenerate system files 234 // regenerate system files
232 Log( ( "Generating settings from %s\n", CfgFile.latin1() )); 235 Log( ( "Generating settings from %s\n", CfgFile.latin1() ));
233 236
234 { Name2SystemFile_t & SFM = NSResources->systemFiles(); 237 //
235 Name2Connection_t & M = NSResources->connections(); 238 // generate files proper to each netnodeinstance
236 NodeCollection * NC; 239 //
237 ANetNodeInstance * NNI; 240 { Name2Instance_t & NNIs = NSResources->netNodeInstances();
238 SystemFile * SF; 241
239 AsDevice * CurDev; 242 for( QDictIterator<ANetNodeInstance> NNIIt(NNIs);
240 ANetNode * CurDevNN; 243 NNIIt.current();
241 bool needToRegenerate = ForceIt; 244 ++NNIIt ) {
242 245 // for all nodes find those that are modified
243 // 246 NNI = NNIIt.current();
244 // check if we need to generate at least one of the system files 247
245 // 248 { // get list of proper files for this nodeclass (if any)
246 if( ! ForceIt ) { 249 QStringList * PF = NNI->nodeClass()->properFiles();
247 for( QDictIterator<SystemFile> sfit(SFM); 250
248 sfit.current(); 251 if( PF ) {
249 ++sfit ) { 252 for ( QStringList::Iterator it = PF->begin();
250 SF = sfit.current(); 253 it != PF->end();
251 254 ++it ) {
252 // check if there are nodes that are modified and require 255 QFile * F = NNI->openFile( (*it) );
253 // data for this system file 256 if( F ) {
254 257 QTextStream TS( F );
255 // for all connections 258 if( NNI->generateFile( (*it), F->name(), TS, -1 ) == 2 ) {
256 for( QDictIterator<NodeCollection> ncit(M); 259 // problem generating
257 ncit.current(); 260 S = qApp->translate( "NetworkSettings",
258 ++ncit ) { 261 "<p>Cannot generate files proper to \"%1\"</p>" ).
259 NC = ncit.current(); 262 arg(NNI->nodeClass()->name()) ;
260 263 delete F;
261 if( NC->isModified() ) { 264 return S;
262 // does this connection 'touch' this system file ?
263 for( QListIterator<ANetNodeInstance> cncit(*NC);
264 cncit.current();
265 ++cncit ) {
266 NNI = cncit.current();
267 if( ( NNI->nodeClass()->hasDataFor( SF->name() ) ||
268 NNI->hasDataFor( SF->name() )
269 ) &&
270 NNI->isModified() ) {
271 needToRegenerate = 1;
272 break;
273 } 265 }
266 delete F;
274 } 267 }
275 } 268 }
276 if( needToRegenerate )
277 break;
278 } 269 }
279 if( needToRegenerate )
280 break;
281 } 270 }
282 } 271 }
272 }
283 273
284 // 274 //
285 // generate files proper to each netnodeinstance 275 // generate all system files
286 // 276 //
287 { Name2Instance_t & NNIs = NSResources->netNodeInstances(); 277 for( QDictIterator<SystemFile> sfit(SFM);
288 278 sfit.current();
289 for( QDictIterator<ANetNodeInstance> NNIIt(NNIs); 279 ++sfit ) {
290 NNIIt.current(); 280 SF = sfit.current();
291 ++NNIIt 281
292 ){ 282 // reset all
293 // for all nodes find those that are modified 283 for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() );
294 NNI = NNIIt.current(); 284 nnit.current();
295 285 ++nnit ) {
296 if( ForceIt || NNI->isModified() ) { 286 nnit.current()->NetNode->setDone(0);
297 if( NNI->nodeClass()->generateProperFilesFor( NNI ) ) { 287 }
298 // problem generating 288
299 S = qApp->translate( "NetworkSettings", 289 for( QDictIterator<ANetNodeInstance> nniit(
300 "<p>Cannot generate files proper to \"%1\"</p>" ). 290 NSResources->netNodeInstances() );
301 arg(NNI->nodeClass()->name()) ; 291 nniit.current();
302 return S; 292 ++nniit ) {
293 nniit.current()->setDone(0);
294 }
295
296 for( QDictIterator<NodeCollection> ncit(M);
297 ncit.current();
298 ++ncit ) {
299 ncit.current()->setDone(0);
300 }
301
302 Log( ( "Generating %s\n", SF->name().latin1() ));
303
304 needToGenerate = 0;
305
306 // are there netnodes that have instances and need
307 // to write data in this system file ?
308 for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() );
309 ! needToGenerate && nnit.current();
310 ++nnit ) {
311
312 NN = nnit.current()->NetNode;
313
314 if( NN->hasDataForFile( SF->name() ) ) {
315 // netnode can have data
316
317 // are there instances of this node ?
318 for( QDictIterator<ANetNodeInstance> nniit(
319 NSResources->netNodeInstances() );
320 ! needToGenerate && nniit.current();
321 ++nniit ) {
322 if( nniit.current()->nodeClass() == NN ) {
323 // yes
324 Log(("Node %s has data\n",
325 nniit.current()->name() ));
326 needToGenerate = 1;
327 break;
303 } 328 }
304 } 329 }
305 } 330 }
306 } 331 }
307 332
308 // 333 if( ! needToGenerate ) {
309 // generate all system files 334 // no instances found that might need to write data
310 // 335 // in this systemfile
311 for( QDictIterator<SystemFile> sfit(SFM); 336 Log(("No nodes for systemfile %s\n", SF->name().latin1() ));
312 sfit.current(); 337 continue;
313 ++sfit ) { 338 }
314 SF = sfit.current();
315 339
316 Log( ( "Generating %s\n", SF->name().latin1() )); 340 // ok generate this system file
317 SF->open(); 341 SF->open();
318 342
319 do { // so we can break; 343 // global presection for this system file
344 if( ! SF->preSection() ) {
345 S = qApp->translate( "NetworkSettings",
346 "<p>Error in section \"Preamble\" for file \"%1\"</p>" ).
347 arg( SF->name() );
348 return S;
349 }
320 350
321 // global presection for this system file 351 // find connections that want to write to this file
322 if( SF->preSection() ) { 352 for( QDictIterator<NodeCollection> ncit(M);
353 ncit.current();
354 ++ncit ) {
355
356 NC = ncit.current();
357
358 if( NC->done() ) {
359 // already done
360 continue;
361 }
362
363 if( ! NC->hasDataForFile( SF->name() ) ) {
364 // no data
365 continue;
366 }
367
368 Log(("Generating %s for connection %s\n",
369 SF->name().latin1(), NC->name().latin1() ));
370 // find highest item that wants to write data to this file
371 FirstWithData = NC->firstWithDataForFile( SF->name() );
372
373 // find device on which this connection works
374 CurDev = NC->device();
375 // class of that node
376 CurDevNN = CurDev->netNode()->nodeClass();
377
378 Log(( "%s is done %d\n",
379 FirstWithData->nodeClass()->name(),
380 FirstWithData->nodeClass()->done() ));
381
382 if( ! FirstWithData->nodeClass()->done() ) {
383 // generate fixed part
384 if( ! SF->preDeviceSection( CurDevNN ) ) {
323 S = qApp->translate( "NetworkSettings", 385 S = qApp->translate( "NetworkSettings",
324 "<p>Error in preSection for file \"%1\"</p>" ). 386 "<p>Error in section \"Pre-Device\" for file \"%1\"</p>" ).
325 arg( SF->name() ); 387 arg( SF->name() );
326 return S; 388 return S;
327 } 389 }
328 390
329 // find all netnodes and figure out if 391 if( FirstWithData->nodeClass()->generateFile(
330 // for that node there are instances 392 SF->name(), SF->path(), *SF, -1 ) == 2 ) {
331 for( QDictIterator<NetNode_t> nnit( 393 S = qApp->translate( "NetworkSettings",
332 NSResources->netNodes() ); 394 "<p>Error in section \"Common\" for file \"%1\" and node \"%2\"</p>" ).
333 nnit.current(); 395 arg( SF->name() ).
334 ++nnit ) { 396 arg( CurDevNN->name() );
335 397 return S;
336 CurDevNN = nnit.current()->NetNode; 398 }
337 399 FirstWithData->nodeClass()->setDone( 1 );
338 // are there instances for this netnode ? 400 }
339 NNI = 0; 401
340 for( QDictIterator<ANetNodeInstance> nniit( 402 NoOfDevs = 0;
341 NSResources->netNodeInstances() ); 403 DevCtStart = -1;
342 nniit.current(); 404
343 ++nniit ) { 405 if( SF->knowsDeviceInstances() ) {
344 if( nniit.current()->nodeClass() == CurDevNN ) { 406 DevCtStart = 0;
345 NNI = nniit.current(); 407 NoOfDevs = CurDevNN->instanceCount();
346 break; 408 }
347 } 409
410 Log(( "Node %s is done %d\n",
411 CurDev->netNode()->nodeClass()->name(),
412 CurDev->netNode()->nodeClass()->done() ));
413
414 if( ! CurDev->netNode()->nodeClass()->done() ) {
415 // first time this device is handled
416 // generate common device specific part
417 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
418
419 if( FirstWithData->nodeClass()->generateFile(
420 SF->name(), SF->path(), *SF, CurDev->netNode(), i ) == 2 ) {
421 S = qApp->translate( "NetworkSettings",
422 "<p>Error in section \"Device\" for file \"%1\" and node \"%2\"</p>" ).
423 arg( SF->name() ).
424 arg( CurDevNN->name() );
425 return S;
348 } 426 }
427 }
428 CurDev->netNode()->nodeClass()->setDone( 1 );
429 }
349 430
350 if( ! NNI ) 431 // generate profile specific info
351 // no instances -> next netnode type 432 // for all nodeconnections that work on the same device
352 continue; 433 for( QDictIterator<NodeCollection> ncit2(M);
434 ncit2.current();
435 ++ncit2 ) {
353 436
354 // has this node data for this system file ? 437 if( ncit2.current()->device() != CurDev ) {
355 if( (CurDev = NNI->runtime()->asDevice() ) ) { 438 // different device
356 // generate start for this nodetype for all possible devices of this type 439 continue;
357 for( int i = 0; i < CurDevNN->instanceCount(); i ++ ) { 440 }
358 S = generateSystemFileNode( *SF, CurDev, NNI, i ); 441
359 if( ! S.isEmpty() ) 442 Log(("Connection %s of same family\n", ncit2.current()->name().latin1() ));
360 return S; 443 // generate
361 } 444 NNI = ncit2.current()->firstWithDataForFile( SF->name() );
362 } else { 445 for( int i = DevCtStart; i < NoOfDevs ; i ++ ) {
363 S = generateSystemFileNode( *SF, 0, NNI, -1 ); 446 if( ! SF->preNodeSection( NNI, i ) ) {
364 if( ! S.isEmpty() ) 447 S = qApp->translate( "NetworkSettings",
448 "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
449 arg( SF->name() ).
450 arg( CurDevNN->name() );
451 return S;
452 }
453
454 switch( NNI->generateFile(
455 SF->name(), SF->path(), *SF, i ) ) {
456 case 0 :
457 (*SF) << endl;
458 break;
459 case 1 :
460 break;
461 case 2 :
462 S = qApp->translate( "NetworkSettings",
463 "<p>Error in section \"Node\" for file \"%1\" and node \"%2\"</p>" ).
464 arg( SF->name() ).
465 arg( CurDevNN->name() );
365 return S; 466 return S;
366 } 467 }
367 }
368 468
369 if( SF->postSection() ) { 469 if( ! SF->postNodeSection( NNI, i ) ) {
370 S = qApp->translate( "NetworkSettings", 470 S = qApp->translate( "NetworkSettings",
371 "<p>Error in postSection for file \"%1\"</p>" ). 471 "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
372 arg( SF->name() ); 472 arg( SF->name() ).
373 return S; 473 arg( CurDevNN->name() );
474 return S;
475 }
374 } 476 }
375 477
376 } while( 0 ); 478 ncit2.current()->setDone( 1 );
377 SF->close(); 479
480 }
481 }
482
483 if( ! SF->postDeviceSection( CurDevNN ) ) {
484 S = qApp->translate( "NetworkSettings",
485 "<p>Error in section \"Post-Device\" for file \"%1\" and node \"%2\"</p>" ).
486 arg( SF->name() ).
487 arg( CurDevNN->name() );
488 return S;
489 }
490
491
492 if( ! SF->postSection() ) {
493 S = qApp->translate( "NetworkSettings",
494 "<p>Error in section \"Closure\" for file \"%1\"</p>" ).
495 arg( SF->name() );
496 return S;
378 } 497 }
498
499 // end of file
500 SF->close();
379 } 501 }
380 Force = 0;
381 return S; 502 return S;
382} 503}
383 504
384QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) { 505QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) {
385 // collect connections that can work on top of this interface 506 // collect connections that can work on top of this interface
386 NodeCollection * NC; 507 NodeCollection * NC;
387 QList<NodeCollection> PossibleConnections; 508 QList<NodeCollection> PossibleConnections;
388 Name2Connection_t & M = NSResources->connections(); 509 Name2Connection_t & M = NSResources->connections();
389 510
390 // for all connections 511 // for all connections
391 for( QDictIterator<NodeCollection> it(M); 512 for( QDictIterator<NodeCollection> it(M);
392 it.current(); 513 it.current();
@@ -454,120 +575,19 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
454 } 575 }
455 576
456 // if we come here no alternatives are possible 577 // if we come here no alternatives are possible
457 printf( "%s-cnn-disallowed\n", Interface ); 578 printf( "%s-cnn-disallowed\n", Interface );
458 return 0; 579 return 0;
459} 580}
460 581
461/* 582/*
462 Called by the system to regenerate config files 583 Called by the system to regenerate config files
463*/ 584*/
464 585
465bool NetworkSettingsData::regenerate( void ) { 586bool NetworkSettingsData::regenerate( void ) {
466 QString S; 587 QString S = generateSettings();
467 // load situation
468 S = generateSettings( TRUE );
469 if( ! S.isEmpty() ) { 588 if( ! S.isEmpty() ) {
470 fprintf( stdout, "%s\n", S.latin1() ); 589 fprintf( stdout, "%s\n", S.latin1() );
471 return 1; 590 return 1;
472 } 591 }
473 return 0; 592 return 0;
474} 593}
475
476QString NetworkSettingsData::generateSystemFileNode(
477 SystemFile &SF,
478 AsDevice * CurDev,
479 ANetNodeInstance * DevNNI,
480 long DevInstNr ) {
481
482 QString S="";
483 ANetNode * CurDevNN = DevNNI->nodeClass();
484 Name2Connection_t & M = NSResources->connections();
485
486 if( SF.preDeviceSection( CurDevNN ) ) {
487 S = qApp->translate( "NetworkSettings",
488 "<p>Error in \"Pre-Device Part\" for file \"%1\" and nodetype \"%2\"</p>" ).
489 arg( SF.name() ).
490 arg( CurDevNN->name() );
491 return S;
492 }
493
494 if( CurDevNN->hasDataFor( SF.name() ) ) {
495 if( CurDevNN->generateDeviceDataForCommonFile( SF, DevInstNr ) ) {
496 S = qApp->translate( "NetworkSettings",
497 "<p>Error in \"Device Part\" for file \"%1\" and node \"%2\"</p>" ).
498 arg( SF.name() ).
499 arg( CurDevNN->name() );
500 return S;
501 }
502 }
503
504 // now generate profile specific data for all
505 // connections working on a device of the current
506 // netnode type
507 for( QDictIterator<NodeCollection> ncit(M);
508 ncit.current();
509 ++ncit ) {
510 NodeCollection * NC = ncit.current();
511
512 // currenly only those connections that work on
513 // the current device (or on no device if no current)
514 AsDevice * Dev = NC->device();
515
516 if( CurDev ) {
517 if( CurDevNN != Dev->netNode()->nodeClass() ) {
518 // other device type -> later
519 continue;
520 }
521 } else {
522 if( Dev ) {
523 // other
524 continue;
525 }
526 }
527
528 // generate 'entry'
529 if( SF.preNodeSection( DevNNI, DevInstNr ) ) {
530 S = qApp->translate( "NetworkSettings",
531 "<p>Error in \"Pre-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
532 arg( SF.name() ).
533 arg( CurDevNN->name() );
534 return S;
535 }
536
537 // ask all nodes in connection
538 for( QListIterator<ANetNodeInstance> cncit(*NC);
539 cncit.current();
540 ++cncit ) {
541 ANetNodeInstance * NNI = cncit.current();
542
543 if( NNI->hasDataFor( SF.name() ) ) {
544 if( NNI->generateDataForCommonFile(SF,DevInstNr) ) {
545 S = qApp->translate( "NetworkSettings",
546 "<p>Error in \"Node Part\" for file \"%1\" and node \"%2\"</p>" ).
547 arg( SF.name() ).
548 arg( NNI->nodeClass()->name() );
549 return S;
550 }
551 }
552 }
553
554 if( SF.postNodeSection( DevNNI, DevInstNr ) ) {
555 S = qApp->translate( "NetworkSettings",
556 "<p>Error in \"Post-Node Part\" for file \"%1\" and node \"%2\"</p>" ).
557 arg( SF.name() ).
558 arg( CurDevNN->name() );
559 return S;
560 }
561 SF << endl;
562 }
563
564 if( SF.postDeviceSection( CurDevNN ) ) {
565 S = qApp->translate( "NetworkSettings",
566 "<p>Error in \"Post-Device Part\" for file \"%1\" and node \"%2\"</p>" ).
567 arg( SF.name() ).
568 arg( CurDevNN->name() );
569 return S;
570 }
571
572 return S;
573}
diff --git a/noncore/settings/networksettings2/nsdata.h b/noncore/settings/networksettings2/nsdata.h
index 57eb722..507185e 100644
--- a/noncore/settings/networksettings2/nsdata.h
+++ b/noncore/settings/networksettings2/nsdata.h
@@ -4,43 +4,34 @@
4#include "netnode.h" 4#include "netnode.h"
5 5
6class NetworkSettingsData { 6class NetworkSettingsData {
7 7
8public : 8public :
9 9
10 NetworkSettingsData( void ); 10 NetworkSettingsData( void );
11 ~NetworkSettingsData( void ); 11 ~NetworkSettingsData( void );
12 12
13 void loadSettings( void ); 13 void loadSettings( void );
14 QString saveSettings( void ); 14 QString saveSettings( void );
15 15
16 QString generateSettings( bool Force = FALSE ); 16 QString generateSettings( void );
17 17
18 bool isModified( void ) 18 bool isModified( void )
19 { return IsModified; } 19 { return IsModified; }
20 void setModified( bool m ) 20 void setModified( bool m )
21 { IsModified = m; } 21 { IsModified = m; }
22 22
23 QList<NodeCollection> collectPossible( const char * Interface ); 23 QList<NodeCollection> collectPossible( const char * Interface );
24 // return TRUE if we need gui to decide 24 // return TRUE if we need gui to decide
25 bool canStart( const char * Interface ); 25 bool canStart( const char * Interface );
26 bool regenerate( void ); 26 bool regenerate( void );
27 27
28 void forceGeneration( bool m )
29 { Force = m; }
30
31private : 28private :
32 29
33 QString NetworkSettingsData::generateSystemFileNode(
34 SystemFile & SF,
35 AsDevice * CurDev,
36 ANetNodeInstance * DevNNI,
37 long DevInstNr );
38 bool IsModified; 30 bool IsModified;
39 bool Force;
40 31
41 // collect strings in config file nobody wants 32 // collect strings in config file nobody wants
42 QStringList LeftOvers; 33 QStringList LeftOvers;
43 34
44}; 35};
45 36
46#endif 37#endif
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui b/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui
index 826843a..0c5f4c8 100644
--- a/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui
+++ b/noncore/settings/networksettings2/ppp/PPPAuthGUI.ui
@@ -2,25 +2,25 @@
2<class>PPPAuthGUI</class> 2<class>PPPAuthGUI</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>PPPAuthGUI</cstring> 7 <cstring>PPPAuthGUI</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>249</width> 14 <width>245</width>
15 <height>209</height> 15 <height>209</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>PPPAuth</string> 20 <string>PPPAuth</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
@@ -48,29 +48,29 @@
48 <name>title</name> 48 <name>title</name>
49 <string></string> 49 <string></string>
50 </property> 50 </property>
51 <property> 51 <property>
52 <name>layoutMargin</name> 52 <name>layoutMargin</name>
53 </property> 53 </property>
54 <property> 54 <property>
55 <name>layoutSpacing</name> 55 <name>layoutSpacing</name>
56 </property> 56 </property>
57 <vbox> 57 <vbox>
58 <property stdset="1"> 58 <property stdset="1">
59 <name>margin</name> 59 <name>margin</name>
60 <number>0</number> 60 <number>3</number>
61 </property> 61 </property>
62 <property stdset="1"> 62 <property stdset="1">
63 <name>spacing</name> 63 <name>spacing</name>
64 <number>0</number> 64 <number>2</number>
65 </property> 65 </property>
66 <widget> 66 <widget>
67 <class>QRadioButton</class> 67 <class>QRadioButton</class>
68 <property stdset="1"> 68 <property stdset="1">
69 <name>name</name> 69 <name>name</name>
70 <cstring>Login_RB</cstring> 70 <cstring>Login_RB</cstring>
71 </property> 71 </property>
72 <property stdset="1"> 72 <property stdset="1">
73 <name>text</name> 73 <name>text</name>
74 <string>Login</string> 74 <string>Login</string>
75 </property> 75 </property>
76 <property stdset="1"> 76 <property stdset="1">
@@ -182,33 +182,72 @@
182 <widget row="1" column="1" > 182 <widget row="1" column="1" >
183 <class>QLineEdit</class> 183 <class>QLineEdit</class>
184 <property stdset="1"> 184 <property stdset="1">
185 <name>name</name> 185 <name>name</name>
186 <cstring>PasswordSend_LE</cstring> 186 <cstring>PasswordSend_LE</cstring>
187 </property> 187 </property>
188 </widget> 188 </widget>
189 </grid> 189 </grid>
190 </widget> 190 </widget>
191 </hbox> 191 </hbox>
192 </widget> 192 </widget>
193 <widget> 193 <widget>
194 <class>QRadioButton</class> 194 <class>QLayoutWidget</class>
195 <property stdset="1"> 195 <property stdset="1">
196 <name>name</name> 196 <name>name</name>
197 <cstring>PapChap_RB</cstring> 197 <cstring>Layout3</cstring>
198 </property>
199 <property stdset="1">
200 <name>text</name>
201 <string>Pap/Chap/EAP</string>
202 </property> 198 </property>
199 <hbox>
200 <property stdset="1">
201 <name>margin</name>
202 <number>0</number>
203 </property>
204 <property stdset="1">
205 <name>spacing</name>
206 <number>6</number>
207 </property>
208 <widget>
209 <class>QRadioButton</class>
210 <property stdset="1">
211 <name>name</name>
212 <cstring>Pap_RB</cstring>
213 </property>
214 <property stdset="1">
215 <name>text</name>
216 <string>Pap</string>
217 </property>
218 </widget>
219 <widget>
220 <class>QRadioButton</class>
221 <property stdset="1">
222 <name>name</name>
223 <cstring>Chap_RB</cstring>
224 </property>
225 <property stdset="1">
226 <name>text</name>
227 <string>Chap</string>
228 </property>
229 </widget>
230 <widget>
231 <class>QRadioButton</class>
232 <property stdset="1">
233 <name>name</name>
234 <cstring>EAP_RB</cstring>
235 </property>
236 <property stdset="1">
237 <name>text</name>
238 <string>EAP</string>
239 </property>
240 </widget>
241 </hbox>
203 </widget> 242 </widget>
204 <widget> 243 <widget>
205 <class>QLayoutWidget</class> 244 <class>QLayoutWidget</class>
206 <property stdset="1"> 245 <property stdset="1">
207 <name>name</name> 246 <name>name</name>
208 <cstring>Layout5</cstring> 247 <cstring>Layout5</cstring>
209 </property> 248 </property>
210 <hbox> 249 <hbox>
211 <property stdset="1"> 250 <property stdset="1">
212 <name>margin</name> 251 <name>margin</name>
213 <number>0</number> 252 <number>0</number>
214 </property> 253 </property>
@@ -266,167 +305,122 @@
266 <name>layoutMargin</name> 305 <name>layoutMargin</name>
267 </property> 306 </property>
268 <property> 307 <property>
269 <name>layoutSpacing</name> 308 <name>layoutSpacing</name>
270 </property> 309 </property>
271 <grid> 310 <grid>
272 <property stdset="1"> 311 <property stdset="1">
273 <name>margin</name> 312 <name>margin</name>
274 <number>2</number> 313 <number>2</number>
275 </property> 314 </property>
276 <property stdset="1"> 315 <property stdset="1">
277 <name>spacing</name> 316 <name>spacing</name>
278 <number>1</number> 317 <number>2</number>
279 </property> 318 </property>
280 <widget row="2" column="0" > 319 <widget row="1" column="0" >
281 <class>QLabel</class> 320 <class>QLabel</class>
282 <property stdset="1"> 321 <property stdset="1">
283 <name>name</name> 322 <name>name</name>
284 <cstring>TextLabel1_2</cstring> 323 <cstring>TextLabel1_2</cstring>
285 </property> 324 </property>
286 <property stdset="1"> 325 <property stdset="1">
287 <name>text</name> 326 <name>text</name>
288 <string>Server</string> 327 <string>Server</string>
289 </property> 328 </property>
290 </widget> 329 </widget>
291 <widget row="3" column="0" > 330 <widget row="2" column="0" >
292 <class>QLabel</class> 331 <class>QLabel</class>
293 <property stdset="1"> 332 <property stdset="1">
294 <name>name</name> 333 <name>name</name>
295 <cstring>TextLabel1_3</cstring> 334 <cstring>TextLabel1_3</cstring>
296 </property> 335 </property>
297 <property stdset="1"> 336 <property stdset="1">
298 <name>text</name> 337 <name>text</name>
299 <string>Secret</string> 338 <string>Secret</string>
300 </property> 339 </property>
301 </widget> 340 </widget>
302 <widget row="0" column="1" > 341 <widget row="1" column="1" >
303 <class>QComboBox</class> 342 <class>QLineEdit</class>
304 <item>
305 <property>
306 <name>text</name>
307 <string>PAP</string>
308 </property>
309 </item>
310 <item>
311 <property>
312 <name>text</name>
313 <string>CHAP</string>
314 </property>
315 </item>
316 <item>
317 <property>
318 <name>text</name>
319 <string>EAP</string>
320 </property>
321 </item>
322 <property stdset="1">
323 <name>name</name>
324 <cstring>AuthMethod_CB</cstring>
325 </property>
326 </widget>
327 <widget row="1" column="0" >
328 <class>QLabel</class>
329 <property stdset="1"> 343 <property stdset="1">
330 <name>name</name> 344 <name>name</name>
331 <cstring>TextLabel1</cstring> 345 <cstring>Server_LE</cstring>
332 </property> 346 </property>
333 <property stdset="1"> 347 <property stdset="1">
334 <name>text</name> 348 <name>text</name>
335 <string>Client</string> 349 <string>*</string>
336 </property> 350 </property>
337 </widget> 351 </widget>
338 <widget row="0" column="0" > 352 <widget row="2" column="1" >
339 <class>QLabel</class> 353 <class>QLineEdit</class>
340 <property stdset="1"> 354 <property stdset="1">
341 <name>name</name> 355 <name>name</name>
342 <cstring>TextLabel1_4</cstring> 356 <cstring>Secret_LE</cstring>
343 </property>
344 <property stdset="1">
345 <name>text</name>
346 <string>Method</string>
347 </property> 357 </property>
348 </widget> 358 </widget>
349 <widget row="1" column="1" rowspan="1" colspan="2" > 359 <widget row="0" column="1" >
350 <class>QLineEdit</class> 360 <class>QLineEdit</class>
351 <property stdset="1"> 361 <property stdset="1">
352 <name>name</name> 362 <name>name</name>
353 <cstring>Client_LE</cstring> 363 <cstring>Client_LE</cstring>
354 </property> 364 </property>
355 <property stdset="1"> 365 <property stdset="1">
356 <name>text</name> 366 <name>text</name>
357 <string>*</string> 367 <string>*</string>
358 </property> 368 </property>
359 </widget> 369 </widget>
360 <widget row="2" column="1" rowspan="1" colspan="2" > 370 <widget row="0" column="0" >
361 <class>QLineEdit</class> 371 <class>QLabel</class>
362 <property stdset="1"> 372 <property stdset="1">
363 <name>name</name> 373 <name>name</name>
364 <cstring>Server_LE</cstring> 374 <cstring>TextLabel1</cstring>
365 </property> 375 </property>
366 <property stdset="1"> 376 <property stdset="1">
367 <name>text</name> 377 <name>text</name>
368 <string>*</string> 378 <string>Client</string>
369 </property>
370 </widget>
371 <widget row="3" column="1" rowspan="1" colspan="2" >
372 <class>QLineEdit</class>
373 <property stdset="1">
374 <name>name</name>
375 <cstring>Secret_LE</cstring>
376 </property> 379 </property>
377 </widget> 380 </widget>
378 <spacer row="0" column="2" >
379 <property>
380 <name>name</name>
381 <cstring>Spacer7</cstring>
382 </property>
383 <property stdset="1">
384 <name>orientation</name>
385 <enum>Horizontal</enum>
386 </property>
387 <property stdset="1">
388 <name>sizeType</name>
389 <enum>Expanding</enum>
390 </property>
391 <property>
392 <name>sizeHint</name>
393 <size>
394 <width>20</width>
395 <height>20</height>
396 </size>
397 </property>
398 </spacer>
399 </grid> 381 </grid>
400 </widget> 382 </widget>
401 </hbox> 383 </hbox>
402 </widget> 384 </widget>
403 <widget> 385 <widget>
404 <class>QRadioButton</class> 386 <class>QRadioButton</class>
405 <property stdset="1"> 387 <property stdset="1">
406 <name>name</name> 388 <name>name</name>
407 <cstring>Terminal_RB</cstring> 389 <cstring>Terminal_RB</cstring>
408 </property> 390 </property>
409 <property stdset="1"> 391 <property stdset="1">
410 <name>text</name> 392 <name>text</name>
411 <string>Terminal</string> 393 <string>Terminal</string>
412 </property> 394 </property>
413 </widget> 395 </widget>
414 </vbox> 396 </vbox>
415 </widget> 397 </widget>
416 </vbox> 398 </vbox>
417</widget> 399</widget>
418<connections> 400<connections>
419 <connection> 401 <connection>
420 <sender>PapChap_RB</sender> 402 <sender>Pap_RB</sender>
421 <signal>toggled(bool)</signal> 403 <signal>toggled(bool)</signal>
422 <receiver>GroupBox3</receiver> 404 <receiver>GroupBox3</receiver>
423 <slot>setEnabled(bool)</slot> 405 <slot>setEnabled(bool)</slot>
424 </connection> 406 </connection>
425 <connection> 407 <connection>
426 <sender>Login_RB</sender> 408 <sender>Login_RB</sender>
427 <signal>toggled(bool)</signal> 409 <signal>toggled(bool)</signal>
428 <receiver>GroupBox1</receiver> 410 <receiver>GroupBox1</receiver>
429 <slot>setEnabled(bool)</slot> 411 <slot>setEnabled(bool)</slot>
430 </connection> 412 </connection>
413 <connection>
414 <sender>Chap_RB</sender>
415 <signal>toggled(bool)</signal>
416 <receiver>GroupBox3</receiver>
417 <slot>setEnabled(bool)</slot>
418 </connection>
419 <connection>
420 <sender>EAP_RB</sender>
421 <signal>toggled(bool)</signal>
422 <receiver>GroupBox3</receiver>
423 <slot>setEnabled(bool)</slot>
424 </connection>
431</connections> 425</connections>
432</UI> 426</UI>
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp
index f305cc4..450d560 100644
--- a/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp
+++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.cpp
@@ -1,85 +1,105 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <qcombobox.h> 2#include <qcombobox.h>
3#include <qmessagebox.h> 3#include <qmessagebox.h>
4#include <qradiobutton.h> 4#include <qradiobutton.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6#include <GUIUtils.h> 6#include <GUIUtils.h>
7#include "PPPAuthedit.h" 7#include "PPPAuthedit.h"
8 8
9PPPAuthEdit::PPPAuthEdit( QWidget * Parent ) : PPPAuthGUI( Parent ){ 9PPPAuthEdit::PPPAuthEdit( QWidget * Parent ) : PPPAuthGUI( Parent ){
10} 10}
11 11
12bool PPPAuthEdit::PAP_Checked( void ) {
13 return ( Pap_RB->isChecked() ||
14 Chap_RB->isChecked() ||
15 EAP_RB->isChecked()
16 );
17}
18
12QString PPPAuthEdit::acceptable( void ) { 19QString PPPAuthEdit::acceptable( void ) {
13 if( Login_RB->isChecked() ) { 20 if( Login_RB->isChecked() ) {
14 if( LoginSend_LE->text().isEmpty() ) 21 if( LoginSend_LE->text().isEmpty() )
15 return tr("Login send missing"); 22 return tr("Login send missing");
16 if( LoginExpect_LE->text().isEmpty() ) 23 if( LoginExpect_LE->text().isEmpty() )
17 return tr("Login expect missing"); 24 return tr("Login expect missing");
18 if( PasswordSend_LE->text().isEmpty() ) 25 if( PasswordSend_LE->text().isEmpty() )
19 return tr("Password send missing"); 26 return tr("Password send missing");
20 if( PasswordExpect_LE->text().isEmpty() ) 27 if( PasswordExpect_LE->text().isEmpty() )
21 return tr("Password expect missing"); 28 return tr("Password expect missing");
22 } else if( PapChap_RB->isChecked() ) { 29 } else if( PAP_Checked() ) {
23 if( Client_LE->text().isEmpty() ) 30 if( Client_LE->text().isEmpty() )
24 return tr("Pap/Chap/EAP client id missing"); 31 return tr("Pap/Chap/EAP client id missing");
25 if( Server_LE->text().isEmpty() ) 32 if( Server_LE->text().isEmpty() )
26 return tr("Pap/Chap/EAP server id missing"); 33 return tr("Pap/Chap/EAP server id missing");
27 if( Secret_LE->text().isEmpty() ) 34 if( Secret_LE->text().isEmpty() )
28 return tr("Pap/Chap/EAP secret id missing"); 35 return tr("Pap/Chap/EAP secret id missing");
29 } 36 }
30 return QString(); 37 return QString();
31} 38}
32 39
33bool PPPAuthEdit::commit( PPPData_t & D ) { 40bool PPPAuthEdit::commit( PPPData_t & D ) {
34 bool SM = 0; 41 bool SM = 0;
35 42
36 if( ( D.Auth.Mode == 0 && ! Login_RB->isChecked() ) || 43 if( ( D.Auth.Mode == 0 && ! Login_RB->isChecked() ) ||
37 ( D.Auth.Mode == 1 && ! PapChap_RB->isChecked() ) || 44 ( D.Auth.Mode == 1 && ! PAP_Checked() ) ||
38 ( D.Auth.Mode == 2 && ! Terminal_RB->isChecked() ) ) { 45 ( D.Auth.Mode == 2 && ! Terminal_RB->isChecked() ) ) {
39 // mode modifed 46 // mode modifed
40 SM = 1; 47 SM = 1;
41 D.Auth.Mode = ( Login_RB->isChecked() ) ? 48 D.Auth.Mode = ( Login_RB->isChecked() ) ?
42 0 : 49 0 :
43 ( ( PapChap_RB->isChecked() ) ? 50 ( PAP_Checked() ) ? 1 : 2;
44 1 : 2 );
45 } 51 }
46 52
47 if( Login_RB->isChecked() ) { 53 if( Login_RB->isChecked() ) {
48 TXTM( D.Auth.Login.Expect, LoginExpect_LE, SM ); 54 TXTM( D.Auth.Login.Expect, LoginExpect_LE, SM );
49 TXTM( D.Auth.Login.Send, LoginSend_LE, SM ); 55 TXTM( D.Auth.Login.Send, LoginSend_LE, SM );
50 TXTM( D.Auth.Password.Expect, PasswordExpect_LE, SM ); 56 TXTM( D.Auth.Password.Expect, PasswordExpect_LE, SM );
51 TXTM( D.Auth.Password.Send, PasswordSend_LE, SM ); 57 TXTM( D.Auth.Password.Send, PasswordSend_LE, SM );
52 } else if( PapChap_RB->isChecked() ) { 58 } else if( PAP_Checked() ) {
53 TXTM( D.Auth.Client, Client_LE, SM ); 59 TXTM( D.Auth.Client, Client_LE, SM );
54 TXTM( D.Auth.Server, Server_LE, SM ); 60 TXTM( D.Auth.Server, Server_LE, SM );
55 TXTM( D.Auth.Secret, Secret_LE, SM ); 61 TXTM( D.Auth.Secret, Secret_LE, SM );
56 CIM( D.Auth.PCEMode, AuthMethod_CB, SM ); 62 if( Pap_RB->isChecked() ) {
63 D.Auth.PCEMode = 0;
64 } else if( Chap_RB->isChecked() ) {
65 D.Auth.PCEMode = 1;
66 } else if( EAP_RB->isChecked() ) {
67 D.Auth.PCEMode = 2;
68 }
57 } 69 }
58 return SM; 70 return SM;
59} 71}
60 72
61void PPPAuthEdit::showData( PPPData_t & D ) { 73void PPPAuthEdit::showData( PPPData_t & D ) {
62 74
63 switch( D.Auth.Mode ) { 75 switch( D.Auth.Mode ) {
64 case 0 : 76 case 0 :
65 Login_RB->isChecked(); 77 Login_RB->setChecked( TRUE );
66 break; 78 break;
67 case 1 : 79 case 1 :
68 PapChap_RB->isChecked(); 80 switch( D.Auth.PCEMode ) {
81 case 0 :
82 Pap_RB->setChecked( TRUE );
83 break;
84 case 1 :
85 Chap_RB->setChecked( TRUE );
86 break;
87 case 2 :
88 EAP_RB->setChecked( TRUE );
89 break;
90 }
69 break; 91 break;
70 case 2 : 92 case 2 :
71 Terminal_RB->isChecked(); 93 Terminal_RB->setChecked( TRUE );
72 break; 94 break;
73 } 95 }
74 96
75 LoginExpect_LE->setText( D.Auth.Login.Expect ); 97 LoginExpect_LE->setText( D.Auth.Login.Expect );
76 PasswordExpect_LE->setText( D.Auth.Password.Expect ); 98 PasswordExpect_LE->setText( D.Auth.Password.Expect );
77 LoginSend_LE->setText( D.Auth.Login.Send ); 99 LoginSend_LE->setText( D.Auth.Login.Send );
78 PasswordSend_LE->setText( D.Auth.Password.Send ); 100 PasswordSend_LE->setText( D.Auth.Password.Send );
79 101
80 Client_LE->setText( D.Auth.Client ); 102 Client_LE->setText( D.Auth.Client );
81 Server_LE->setText( D.Auth.Server ); 103 Server_LE->setText( D.Auth.Server );
82 Secret_LE->setText( D.Auth.Secret ); 104 Secret_LE->setText( D.Auth.Secret );
83
84 AuthMethod_CB->setCurrentItem( D.Auth.PCEMode );
85} 105}
diff --git a/noncore/settings/networksettings2/ppp/PPPAuthedit.h b/noncore/settings/networksettings2/ppp/PPPAuthedit.h
index cbd540e..2392569 100644
--- a/noncore/settings/networksettings2/ppp/PPPAuthedit.h
+++ b/noncore/settings/networksettings2/ppp/PPPAuthedit.h
@@ -1,15 +1,17 @@
1#include "pppdata.h" 1#include "pppdata.h"
2#include "PPPAuthGUI.h" 2#include "PPPAuthGUI.h"
3 3
4class PPPAuthEdit : public PPPAuthGUI { 4class PPPAuthEdit : public PPPAuthGUI {
5 5
6public : 6public :
7 7
8 PPPAuthEdit( QWidget * parent ); 8 PPPAuthEdit( QWidget * parent );
9 QString acceptable( void ); 9 QString acceptable( void );
10 bool commit( PPPData_t & Data ); 10 bool commit( PPPData_t & Data );
11 void showData( PPPData_t & Data ); 11 void showData( PPPData_t & Data );
12 bool PAP_Checked( void );
13
12 14
13private : 15private :
14 16
15}; 17};
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
index b7edf87..ff4465c 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp
@@ -1,25 +1,40 @@
1#include <qfile.h>
2#include <qtextstream.h>
1#include "ppp_NN.h" 3#include "ppp_NN.h"
2#include "ppp_NNI.h" 4#include "ppp_NNI.h"
3 5
6QStringList * PPPNetNode::ProperFiles = 0;
7
4static const char * PPPNeeds[] = 8static const char * PPPNeeds[] =
5 { "line", 9 { "line",
6 "modem", 10 "modem",
7 0 11 0
8 }; 12 };
9 13
10/** 14/**
11 * Constructor, find all of the possible interfaces 15 * Constructor, find all of the possible interfaces
12 */ 16 */
13PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) { 17PPPNetNode::PPPNetNode() : ANetNode(tr("PPP Connection")) {
18
19 // proper files : will leak
20 ProperFiles =new QStringList;
21 *ProperFiles << "peers";
22 *ProperFiles << "chatscript";
23
24 // system files
25 NSResources->addSystemFile(
26 "pap-secrets", "/tmp/pap-secrets", 0 );
27 NSResources->addSystemFile(
28 "chap-secrets", "/tmp/chap-secrets", 0 );
14} 29}
15 30
16/** 31/**
17 * Delete any interfaces that we own. 32 * Delete any interfaces that we own.
18 */ 33 */
19PPPNetNode::~PPPNetNode(){ 34PPPNetNode::~PPPNetNode(){
20} 35}
21 36
22const QString PPPNetNode::nodeDescription(){ 37const QString PPPNetNode::nodeDescription(){
23 return tr("\ 38 return tr("\
24<p>Sets up IP using PPP.</p>\ 39<p>Sets up IP using PPP.</p>\
25<p>Use this for dialup devices or serial setups</p>\ 40<p>Use this for dialup devices or serial setups</p>\
@@ -30,33 +45,35 @@ const QString PPPNetNode::nodeDescription(){
30ANetNodeInstance * PPPNetNode::createInstance( void ) { 45ANetNodeInstance * PPPNetNode::createInstance( void ) {
31 return new APPP( this ); 46 return new APPP( this );
32} 47}
33 48
34const char ** PPPNetNode::needs( void ) { 49const char ** PPPNetNode::needs( void ) {
35 return PPPNeeds; 50 return PPPNeeds;
36} 51}
37 52
38const char * PPPNetNode::provides( void ) { 53const char * PPPNetNode::provides( void ) {
39 return "connection"; 54 return "connection";
40} 55}
41 56
42bool PPPNetNode::generateProperFilesFor( 57QStringList * PPPNetNode::properFiles( void ) {
43 ANetNodeInstance * ) { 58 return ProperFiles;
44 return 0; 59
45} 60}
46 61
47bool PPPNetNode::generateDeviceDataForCommonFile( 62// need to generate :
48 SystemFile & , 63// /etc/ppp/pap-secrets
49 long ) { 64// /etc/ppp/pap-secrets
50 return 0; 65bool PPPNetNode::hasDataForFile( const QString & S ) {
66 return S == "pap-secrets" ||
67 S == "chap-secrets" ;
51} 68}
52 69
53QString PPPNetNode::genNic( long NicNr ) { 70QString PPPNetNode::genNic( long NicNr ) {
54 QString S; 71 QString S;
55 return S.sprintf( "ppp%ld", NicNr ); 72 return S.sprintf( "ppp%ld", NicNr );
56} 73}
57 74
58void PPPNetNode::setSpecificAttribute( QString & , QString & ) { 75void PPPNetNode::setSpecificAttribute( QString & , QString & ) {
59} 76}
60 77
61void PPPNetNode::saveSpecificAttribute( QTextStream & ) { 78void PPPNetNode::saveSpecificAttribute( QTextStream & ) {
62} 79}
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.h b/noncore/settings/networksettings2/ppp/ppp_NN.h
index b1483c4..249be5a 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NN.h
+++ b/noncore/settings/networksettings2/ppp/ppp_NN.h
@@ -1,46 +1,43 @@
1#ifndef PPP_NETNODE_H 1#ifndef PPP_NETNODE_H
2#define PPP_NETNODE_H 2#define PPP_NETNODE_H
3 3
4#include "netnode.h" 4#include "netnode.h"
5 5
6class APPP; 6class APPP;
7 7
8class PPPNetNode : public ANetNode{ 8class PPPNetNode : public ANetNode{
9 9
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 13
14 PPPNetNode(); 14 PPPNetNode();
15 virtual ~PPPNetNode(); 15 virtual ~PPPNetNode();
16 16
17 virtual const QString pixmapName() 17 virtual const QString pixmapName()
18 { return "Devices/ppp"; } 18 { return "Devices/ppp"; }
19 19
20 virtual const QString nodeDescription() ; 20 virtual bool hasDataForFile( const QString & S );
21 21
22 virtual ANetNodeInstance * createInstance( void ); 22 virtual const QString nodeDescription() ;
23 virtual ANetNodeInstance * createInstance( void );
24 virtual const char ** needs( void );
25 virtual const char * provides( void );
23 26
24 virtual const char ** needs( void ); 27 virtual QString genNic( long NicNr );
25 virtual const char * provides( void ); 28 virtual QStringList * properFiles( void );
26
27 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
28 virtual bool hasDataFor( const QString & )
29 { return 0; }
30 virtual bool generateDeviceDataForCommonFile(
31 SystemFile & SF, long DevNr );
32
33 virtual QString genNic( long NicNr );
34 29
35private: 30private:
36 31
37 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 32 virtual void setSpecificAttribute( QString & Attr, QString & Value );
38 virtual void saveSpecificAttribute( QTextStream & TS ); 33 virtual void saveSpecificAttribute( QTextStream & TS );
34
35 static QStringList * ProperFiles;
39}; 36};
40 37
41extern "C" 38extern "C"
42{ 39{
43 void create_plugin( QList<ANetNode> & PNN ); 40 void create_plugin( QList<ANetNode> & PNN );
44}; 41};
45 42
46#endif 43#endif
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
index d0fd31c..ba639de 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
+++ b/noncore/settings/networksettings2/ppp/ppp_NNI.cpp
@@ -1,12 +1,14 @@
1#include <qfile.h>
2#include <qfileinfo.h>
1#include "PPPedit.h" 3#include "PPPedit.h"
2#include "ppp_NNI.h" 4#include "ppp_NNI.h"
3#include "ppp_NN.h" 5#include "ppp_NN.h"
4 6
5APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) { 7APPP::APPP( PPPNetNode * PNN ) : ANetNodeInstance( PNN ) {
6 Data.DNS.ServerAssigned = 1; 8 Data.DNS.ServerAssigned = 1;
7 Data.DNS.DomainName = ""; 9 Data.DNS.DomainName = "";
8 10
9 Data.Auth.Mode = 0; 11 Data.Auth.Mode = 0;
10 Data.Auth.Login.Expect = "ogin:"; 12 Data.Auth.Login.Expect = "ogin:";
11 Data.Auth.Password.Expect = "assword:"; 13 Data.Auth.Password.Expect = "assword:";
12 Data.Auth.PCEMode = 0; 14 Data.Auth.PCEMode = 0;
@@ -104,18 +106,116 @@ QWidget * APPP::edit( QWidget * parent ) {
104} 106}
105 107
106QString APPP::acceptable( void ) { 108QString APPP::acceptable( void ) {
107 return ( GUI ) ? GUI->acceptable( ) : QString(); 109 return ( GUI ) ? GUI->acceptable( ) : QString();
108} 110}
109 111
110void APPP::commit( void ) { 112void APPP::commit( void ) {
111 if( GUI && GUI->commit( Data ) ) { 113 if( GUI && GUI->commit( Data ) ) {
112 setModified( 1 ); 114 setModified( 1 );
113 } 115 }
114} 116}
115 117
116bool APPP::generateDataForCommonFile( 118QFile * APPP::openFile( const QString & ID ) {
117 SystemFile & , 119 QFile * F = 0;
118 long) { 120 QString S;
119 return 1; 121
122 if( ID == "peers" ) {
123 S = removeSpaces( QString("/tmp/") + connection()->name() );
124
125 F = new QFile( S );
126
127 if( ! F->open( IO_WriteOnly ) ) {
128 Log(("Cannot open file %s\n", S.latin1() ));
129 return 0;
130 }
131 } else if ( ID == "chatscripts" ) {
132 S = removeSpaces( QString("/tmp/") + connection()->name() + ".chat" );
133 F = new QFile( S );
134
135 if( ! F->open( IO_WriteOnly ) ) {
136 Log(("Cannot open file %s\n", S.latin1() ));
137 return 0;
138 }
139 }
140 if( F ) {
141 Log(("Generate proper file %s = %s\n",
142 ID.latin1(), F->name().latin1()));
143 }
144 return F;
120} 145}
121 146
147short APPP::generateFile( const QString & ID,
148 const QString & Path,
149 QTextStream & TS,
150 long DevNr ) {
151 short rvl, rvd;
152
153 rvl = 1;
154 rvd = 1;
155
156 if( ID == "pap-secrets" ) {
157 Log(("Generate PPP for %s\n", ID.latin1() ));
158 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode == 0 ) {
159 TS << "# secrets for "
160 << connection()->name().latin1()
161 << endl;
162 TS << Data.Auth.Client
163 << " "
164 << Data.Auth.Server
165 << " "
166 << Data.Auth.Secret
167 << endl;
168 rvl = 0;
169 rvd = connection()->getToplevel()->generateFileEmbedded(
170 ID, Path, TS, DevNr );
171 }
172 } else if( ID == "chap-secrets" ) {
173 Log(("Generate PPP for %s\n", ID.latin1() ));
174 if( Data.Auth.Mode == 1 && Data.Auth.PCEMode != 0 ) {
175 // used for both EAP and Chap
176 TS << "# secrets for "
177 << connection()->name().latin1()
178 << endl;
179 TS << Data.Auth.Client
180 << " "
181 << Data.Auth.Server
182 << " "
183 << Data.Auth.Secret
184 << endl;
185
186 rvl = 0;
187 rvd = connection()->getToplevel()->generateFileEmbedded(
188 ID, Path, TS, DevNr );
189 }
190 } else if ( ID == "peers" ) {
191 QFileInfo FI(Path);
192 Log(("Generate PPP for %s\n", ID.latin1() ));
193
194 TS << "connect \"/usr/sbin/chat -v -f /etc/ppp/"
195 << FI.baseName()
196 << ".chat\""
197 << endl;
198
199 if( Data.IP.GWIsDefault ) {
200 TS << "defaultroute"
201 << endl;
202 }
203
204 TS << "linkname "
205 << removeSpaces( ID.latin1() )
206 << endl;
207
208 // insert other data here
209 rvl = 0;
210 rvd = connection()->getToplevel()->generateFileEmbedded(
211 ID, Path, TS, DevNr );
212 } else if ( ID == "chatscripts" ) {
213 Log(("Generate PPP for %s\n", ID.latin1() ));
214 rvl = 0;
215 rvd = connection()->getToplevel()->generateFileEmbedded(
216 ID, Path, TS, DevNr );
217 }
218
219 return (rvd == 2 || rvl == 2 ) ? 2 :
220 (rvd == 0 || rvl == 0 ) ? 0 : 1;
221}
diff --git a/noncore/settings/networksettings2/ppp/ppp_NNI.h b/noncore/settings/networksettings2/ppp/ppp_NNI.h
index 989c2f0..0bf8fa9 100644
--- a/noncore/settings/networksettings2/ppp/ppp_NNI.h
+++ b/noncore/settings/networksettings2/ppp/ppp_NNI.h
@@ -1,46 +1,49 @@
1#ifndef PPP_H 1#ifndef PPP_H
2#define PPP_H 2#define PPP_H
3 3
4#include <netnode.h> 4#include <netnode.h>
5#include "pppdata.h" 5#include "pppdata.h"
6#include "ppprun.h" 6#include "ppprun.h"
7 7
8class PPPNetNode; 8class PPPNetNode;
9class PPPEdit; 9class PPPEdit;
10class QTextStream;
10 11
11class APPP : public ANetNodeInstance { 12class APPP : public ANetNodeInstance {
12 13
13public : 14public :
14 15
15 APPP( PPPNetNode * PNN ); 16 APPP( PPPNetNode * PNN );
16 17
17 QWidget * edit( QWidget * parent );
18 QString acceptable( void );
19 void commit( void );
20
21 RuntimeInfo * runtime( void ) 18 RuntimeInfo * runtime( void )
22 { if( RT == 0 ) 19 { if( RT == 0 ) {
23 RT = new PPPRun( this, Data ); 20 RT = new PPPRun( this, Data );
21 }
24 return RT->runtimeInfo(); 22 return RT->runtimeInfo();
25 } 23 }
26 24
25 QWidget * edit( QWidget * parent );
26 QString acceptable( void );
27 void commit( void );
28
27 virtual void * data( void ) 29 virtual void * data( void )
28 { return (void *)&Data; } 30 { return (void *)&Data; }
29 31
30 virtual bool hasDataFor( const QString & ) 32 virtual QFile * openFile( const QString & ID );
31 { return 0; } 33 short generateFile( const QString & ID,
34 const QString & Path,
35 QTextStream & TS,
36 long DevNr );
32 37
33 virtual bool generateDataForCommonFile(
34 SystemFile & SF, long DevNr );
35protected : 38protected :
36 39
37 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 40 virtual void setSpecificAttribute( QString & Attr, QString & Value );
38 virtual void saveSpecificAttribute( QTextStream & TS ); 41 virtual void saveSpecificAttribute( QTextStream & TS );
39 42
40private : 43private :
41 44
42 PPPEdit * GUI; 45 PPPEdit * GUI;
43 PPPData Data; 46 PPPData Data;
44 PPPRun * RT; 47 PPPRun * RT;
45 48
46}; 49};
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp
index 59c34a3..945b48d 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NN.cpp
@@ -1,24 +1,24 @@
1#include "profile_NN.h" 1#include "profile_NN.h"
2#include "profile_NNI.h" 2#include "profile_NNI.h"
3 3
4static const char * ProfileNeeds[] = 4static const char * ProfileNeeds[] =
5 { "connection", 5 { "connection",
6 0 6 0
7 }; 7 };
8 8
9/** 9/**
10 * Constructor, find all of the possible interfaces 10 * Constructor, find all of the possible interfaces
11 */ 11 */
12ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular profile")) { 12ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) {
13} 13}
14 14
15/** 15/**
16 * Delete any interfaces that we own. 16 * Delete any interfaces that we own.
17 */ 17 */
18ProfileNetNode::~ProfileNetNode(){ 18ProfileNetNode::~ProfileNetNode(){
19} 19}
20 20
21const QString ProfileNetNode::nodeDescription(){ 21const QString ProfileNetNode::nodeDescription(){
22 return tr("\ 22 return tr("\
23<p>Define use of an IP connection.</p>\ 23<p>Define use of an IP connection.</p>\
24<p>Configure if and when this connection needs to be established</p>\ 24<p>Configure if and when this connection needs to be established</p>\
@@ -29,34 +29,23 @@ const QString ProfileNetNode::nodeDescription(){
29ANetNodeInstance * ProfileNetNode::createInstance( void ) { 29ANetNodeInstance * ProfileNetNode::createInstance( void ) {
30 return new AProfile( this ); 30 return new AProfile( this );
31} 31}
32 32
33const char ** ProfileNetNode::needs( void ) { 33const char ** ProfileNetNode::needs( void ) {
34 return ProfileNeeds; 34 return ProfileNeeds;
35} 35}
36 36
37const char * ProfileNetNode::provides( void ) { 37const char * ProfileNetNode::provides( void ) {
38 return "fullsetup"; 38 return "fullsetup";
39} 39}
40 40
41bool ProfileNetNode::generateProperFilesFor(
42 ANetNodeInstance * ) {
43 return 0;
44}
45
46bool ProfileNetNode::generateDeviceDataForCommonFile(
47 SystemFile & ,
48 long ) {
49 return 0;
50}
51
52void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { 41void ProfileNetNode::setSpecificAttribute( QString & , QString & ) {
53} 42}
54 43
55void ProfileNetNode::saveSpecificAttribute( QTextStream & ) { 44void ProfileNetNode::saveSpecificAttribute( QTextStream & ) {
56} 45}
57 46
58extern "C" { 47extern "C" {
59void create_plugin( QList<ANetNode> & PNN ) { 48void create_plugin( QList<ANetNode> & PNN ) {
60 PNN.append( new ProfileNetNode() ); 49 PNN.append( new ProfileNetNode() );
61} 50}
62} 51}
diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h
index e602bd7..1f1ee2c 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.h
+++ b/noncore/settings/networksettings2/profile/profile_NN.h
@@ -9,36 +9,28 @@ class ProfileNetNode : public ANetNode{
9 9
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 13
14 ProfileNetNode(); 14 ProfileNetNode();
15 virtual ~ProfileNetNode(); 15 virtual ~ProfileNetNode();
16 16
17 virtual const QString pixmapName() 17 virtual const QString pixmapName()
18 { return "Devices/commprofile"; } 18 { return "Devices/commprofile"; }
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21
22 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
23
24 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
25 virtual const char * provides( void ); 23 virtual const char * provides( void );
26 24
27 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
28 virtual bool hasDataFor( const QString & )
29 { return 0; }
30 virtual bool generateDeviceDataForCommonFile(
31 SystemFile & SF, long DevNr);
32
33private: 25private:
34 26
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
36 virtual void saveSpecificAttribute( QTextStream & TS ); 28 virtual void saveSpecificAttribute( QTextStream & TS );
37}; 29};
38 30
39extern "C" 31extern "C"
40{ 32{
41 void create_plugin( QList<ANetNode> & PNN ); 33 void create_plugin( QList<ANetNode> & PNN );
42}; 34};
43 35
44#endif 36#endif
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp
index cb52b2a..f0f0b97 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp
@@ -41,18 +41,37 @@ QWidget * AProfile::edit( QWidget * parent ) {
41 return GUI; 41 return GUI;
42} 42}
43 43
44QString AProfile::acceptable( void ) { 44QString AProfile::acceptable( void ) {
45 return ( GUI ) ? GUI->acceptable( ) : QString(); 45 return ( GUI ) ? GUI->acceptable( ) : QString();
46} 46}
47 47
48void AProfile::commit( void ) { 48void AProfile::commit( void ) {
49 if( GUI && GUI->commit( Data ) ) 49 if( GUI && GUI->commit( Data ) )
50 setModified( 1 ); 50 setModified( 1 );
51} 51}
52 52
53bool AProfile::generateDataForCommonFile( 53short AProfile::generateFileEmbedded( const QString & ID,
54 SystemFile & , 54 const QString & Path,
55 long) { 55 QTextStream & TS,
56 return 1; 56 long DevNr ) {
57
58 short rvl, rvd;
59
60 rvl = 1;
61
62 if( ID == "interfaces" ) {
63 Log(("Generate Profile for %s\n", ID.latin1() ));
64 if( Data.TriggerVPN ) {
65 // this profile triggers VPN -> insert trigger
66 TS << " up networksettings2 --triggervpn"
67 << endl;
68 rvl = 0;
69 }
70 }
71 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr );
72 return (rvd == 2 || rvl == 2 ) ? 2 :
73 (rvd == 0 || rvl == 0 ) ? 0 : 1;
57} 74}
58 75
76
77
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.h b/noncore/settings/networksettings2/profile/profile_NNI.h
index 2c2db7f..957f4af 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.h
+++ b/noncore/settings/networksettings2/profile/profile_NNI.h
@@ -5,44 +5,43 @@
5#include "profiledata.h" 5#include "profiledata.h"
6#include "profilerun.h" 6#include "profilerun.h"
7 7
8class ProfileNetNode; 8class ProfileNetNode;
9class ProfileEdit; 9class ProfileEdit;
10 10
11class AProfile : public ANetNodeInstance { 11class AProfile : public ANetNodeInstance {
12 12
13public : 13public :
14 14
15 AProfile( ProfileNetNode * PNN ); 15 AProfile( ProfileNetNode * PNN );
16 16
17 RuntimeInfo * runtime( void )
18 { return
19 ( RT ) ? RT : ( RT = new ProfileRun( this, Data ) );
20 }
21
17 QWidget * edit( QWidget * parent ); 22 QWidget * edit( QWidget * parent );
18 QString acceptable( void ); 23 QString acceptable( void );
19 void commit( void ); 24 void commit( void );
20 25
21 const QString & description( void )
22 { return Data.Description; }
23 RuntimeInfo * runtime( void )
24 { if( RT == 0 )
25 RT = new ProfileRun( this, Data );
26 return RT;
27 }
28
29 virtual void * data( void ) 26 virtual void * data( void )
30 { return (void *)&Data; } 27 { return (void *)&Data; }
31 28
32 virtual bool hasDataFor( const QString & ) 29 virtual short generateFileEmbedded( const QString & ID,
33 { return 0; } 30 const QString & Path,
31 QTextStream & TS,
32 long DevNr );
34 33
35 virtual bool generateDataForCommonFile( 34 const QString & description( void )
36 SystemFile & SF, long DevNr); 35 { return Data.Description; }
37 36
38protected : 37protected :
39 38
40 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 39 virtual void setSpecificAttribute( QString & Attr, QString & Value );
41 virtual void saveSpecificAttribute( QTextStream & TS ); 40 virtual void saveSpecificAttribute( QTextStream & TS );
42 41
43private : 42private :
44 43
45 ProfileEdit * GUI; 44 ProfileEdit * GUI;
46 ProfileData Data; 45 ProfileData Data;
47 ProfileRun * RT; 46 ProfileRun * RT;
48 47
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp
index c10a09c..14c479a 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NN.cpp
@@ -28,47 +28,24 @@ const QString USBNetNode::nodeDescription(){
28ANetNodeInstance * USBNetNode::createInstance( void ) { 28ANetNodeInstance * USBNetNode::createInstance( void ) {
29 return new AUSB( this ); 29 return new AUSB( this );
30} 30}
31 31
32const char ** USBNetNode::needs( void ) { 32const char ** USBNetNode::needs( void ) {
33 return USBNeeds; 33 return USBNeeds;
34} 34}
35 35
36const char * USBNetNode::provides( void ) { 36const char * USBNetNode::provides( void ) {
37 return "device"; 37 return "device";
38} 38}
39 39
40bool USBNetNode::generateProperFilesFor(
41 ANetNodeInstance * ) {
42 return 0;
43}
44
45bool USBNetNode::hasDataFor( const QString & S ) {
46 return (S== "interfaces");
47}
48
49bool USBNetNode::generateDeviceDataForCommonFile(
50 SystemFile & S ,
51 long DevNr ) {
52 QString NIC = genNic( DevNr );
53
54 if( S.name() == "interfaces" ) {
55 // generate mapping stanza for this interface
56 S << "# check if " << NIC << " can be brought UP" << endl;
57 S << "mapping " << NIC << endl;
58 S << " script networksettings2-request" << endl << endl;
59 }
60 return 0;
61}
62
63QString USBNetNode::genNic( long ) { 40QString USBNetNode::genNic( long ) {
64 return QString( "usbf" ); 41 return QString( "usbf" );
65} 42}
66 43
67void USBNetNode::setSpecificAttribute( QString & , QString & ) { 44void USBNetNode::setSpecificAttribute( QString & , QString & ) {
68} 45}
69 46
70void USBNetNode::saveSpecificAttribute( QTextStream & ) { 47void USBNetNode::saveSpecificAttribute( QTextStream & ) {
71} 48}
72 49
73extern "C" { 50extern "C" {
74void create_plugin( QList<ANetNode> & PNN ) { 51void create_plugin( QList<ANetNode> & PNN ) {
diff --git a/noncore/settings/networksettings2/usb/usb_NN.h b/noncore/settings/networksettings2/usb/usb_NN.h
index fea89f0..73da15a 100644
--- a/noncore/settings/networksettings2/usb/usb_NN.h
+++ b/noncore/settings/networksettings2/usb/usb_NN.h
@@ -9,35 +9,28 @@ class USBNetNode : public ANetNode{
9 9
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 13
14 USBNetNode(); 14 USBNetNode();
15 virtual ~USBNetNode(); 15 virtual ~USBNetNode();
16 16
17 virtual const QString pixmapName() 17 virtual const QString pixmapName()
18 { return "Devices/usb"; } 18 { return "Devices/usb"; }
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21
22 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
23
24 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
25 virtual const char * provides( void ); 23 virtual const char * provides( void );
26 24
27 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
28 virtual bool hasDataFor( const QString & S);
29 virtual bool generateDeviceDataForCommonFile(
30 SystemFile & SF, long DevNr );
31
32 virtual QString genNic( long nr ); 25 virtual QString genNic( long nr );
33 26
34private: 27private:
35 28
36 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 29 virtual void setSpecificAttribute( QString & Attr, QString & Value );
37 virtual void saveSpecificAttribute( QTextStream & TS ); 30 virtual void saveSpecificAttribute( QTextStream & TS );
38}; 31};
39 32
40extern "C" 33extern "C"
41{ 34{
42 void create_plugin( QList<ANetNode> & PNN ); 35 void create_plugin( QList<ANetNode> & PNN );
43}; 36};
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.cpp b/noncore/settings/networksettings2/usb/usb_NNI.cpp
index e90204c..50c6e8d 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.cpp
+++ b/noncore/settings/networksettings2/usb/usb_NNI.cpp
@@ -23,30 +23,39 @@ QWidget * AUSB::edit( QWidget * parent ) {
23} 23}
24 24
25QString AUSB::acceptable( void ) { 25QString AUSB::acceptable( void ) {
26 return ( GUI ) ? GUI->acceptable( ) : QString(); 26 return ( GUI ) ? GUI->acceptable( ) : QString();
27} 27}
28 28
29void AUSB::commit( void ) { 29void AUSB::commit( void ) {
30 if( GUI && GUI->commit( Data ) ) { 30 if( GUI && GUI->commit( Data ) ) {
31 setModified( 1 ); 31 setModified( 1 );
32 } 32 }
33} 33}
34 34
35bool AUSB::hasDataFor( const QString & S ) { 35short AUSB::generateFileEmbedded( const QString & ID,
36 return (S== "interfaces"); 36 const QString & Path,
37} 37 QTextStream & TS,
38 38 long DevNr ) {
39bool AUSB::generateDataForCommonFile( SystemFile & S, long DevNr ) { 39
40 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr ); 40 QString NIC = runtime()->device()->netNode()->nodeClass()->genNic( DevNr );
41 short rvl, rvd;
42
43 rvl = 1;
41 44
42 if( S.name() == "interfaces" ) { 45 if( ID == "interfaces" ) {
46 Log(("Generate USB for %s\n", ID.latin1() ));
43 // generate mapping stanza for this interface 47 // generate mapping stanza for this interface
44 S << " pre-up " 48 TS << " pre-up "
45 << QPEApplication::qpeDir() 49 << QPEApplication::qpeDir()
46 << "bin/setmacaddress.sh " 50 << "bin/setmacaddress.sh "
47 << NIC 51 << NIC
48 << " || true" 52 << " || true"
49 << endl; 53 << endl;
54 rvl = 0;
50 } 55 }
51 return 0; 56 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr );
57
58 return (rvd == 2 || rvl == 2 ) ? 2 :
59 (rvd == 0 || rvl == 0 ) ? 0 : 1;
60
52} 61}
diff --git a/noncore/settings/networksettings2/usb/usb_NNI.h b/noncore/settings/networksettings2/usb/usb_NNI.h
index d2ee217..fcdfd91 100644
--- a/noncore/settings/networksettings2/usb/usb_NNI.h
+++ b/noncore/settings/networksettings2/usb/usb_NNI.h
@@ -5,40 +5,40 @@
5#include "usbdata.h" 5#include "usbdata.h"
6#include "usbrun.h" 6#include "usbrun.h"
7 7
8class USBNetNode; 8class USBNetNode;
9class USBEdit; 9class USBEdit;
10 10
11class AUSB : public ANetNodeInstance { 11class AUSB : public ANetNodeInstance {
12 12
13public : 13public :
14 14
15 AUSB( USBNetNode * PNN ); 15 AUSB( USBNetNode * PNN );
16 16
17 RuntimeInfo * runtime( void )
18 { return
19 ( RT ) ? RT : ( RT = new USBRun( this, Data ) );
20 }
21
17 QWidget * edit( QWidget * parent ); 22 QWidget * edit( QWidget * parent );
18 QString acceptable( void ); 23 QString acceptable( void );
19 void commit( void ); 24 void commit( void );
20 25
21 RuntimeInfo * runtime( void )
22 { if( RT == 0 )
23 RT = new USBRun( this, Data );
24 return RT;
25 }
26
27 virtual void * data( void ) 26 virtual void * data( void )
28 { return (void *)&Data; } 27 { return (void *)&Data; }
29 28
30 virtual bool hasDataFor( const QString & S); 29 virtual short generateFileEmbedded( const QString & ID,
31 virtual bool generateDataForCommonFile( 30 const QString & Path,
32 SystemFile & SF, long DevNr ); 31 QTextStream & TS,
32 long DevNr );
33 33
34protected : 34protected :
35 35
36 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 36 virtual void setSpecificAttribute( QString & Attr, QString & Value );
37 virtual void saveSpecificAttribute( QTextStream & TS ); 37 virtual void saveSpecificAttribute( QTextStream & TS );
38 38
39private : 39private :
40 40
41 USBEdit * GUI; 41 USBEdit * GUI;
42 USBData Data; 42 USBData Data;
43 USBRun * RT; 43 USBRun * RT;
44}; 44};
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
index 6c7b308..9d3b6e7 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp
@@ -1,18 +1,17 @@
1#include "vpn_NN.h" 1#include "vpn_NN.h"
2#include "vpn_NNI.h" 2#include "vpn_NNI.h"
3 3
4static const char * VPNNeeds[] = 4static const char * VPNNeeds[] =
5 { "connection", 5 { 0
6 0
7 }; 6 };
8 7
9/** 8/**
10 * Constructor, find all of the possible interfaces 9 * Constructor, find all of the possible interfaces
11 */ 10 */
12VPNNetNode::VPNNetNode() : ANetNode(tr("VPN Connection")) { 11VPNNetNode::VPNNetNode() : ANetNode(tr("VPN Connection")) {
13} 12}
14 13
15/** 14/**
16 * Delete any interfaces that we own. 15 * Delete any interfaces that we own.
17 */ 16 */
18VPNNetNode::~VPNNetNode(){ 17VPNNetNode::~VPNNetNode(){
@@ -29,34 +28,23 @@ const QString VPNNetNode::nodeDescription(){
29ANetNodeInstance * VPNNetNode::createInstance( void ) { 28ANetNodeInstance * VPNNetNode::createInstance( void ) {
30 return new AVPN( this ); 29 return new AVPN( this );
31} 30}
32 31
33const char ** VPNNetNode::needs( void ) { 32const char ** VPNNetNode::needs( void ) {
34 return VPNNeeds; 33 return VPNNeeds;
35} 34}
36 35
37const char * VPNNetNode::provides( void ) { 36const char * VPNNetNode::provides( void ) {
38 return "connection"; 37 return "connection";
39} 38}
40 39
41bool VPNNetNode::generateProperFilesFor(
42 ANetNodeInstance * ) {
43 return 0;
44}
45
46bool VPNNetNode::generateDeviceDataForCommonFile(
47 SystemFile & ,
48 long ) {
49 return 0;
50}
51
52void VPNNetNode::setSpecificAttribute( QString & , QString & ) { 40void VPNNetNode::setSpecificAttribute( QString & , QString & ) {
53} 41}
54 42
55void VPNNetNode::saveSpecificAttribute( QTextStream & ) { 43void VPNNetNode::saveSpecificAttribute( QTextStream & ) {
56} 44}
57 45
58extern "C" { 46extern "C" {
59void create_plugin( QList<ANetNode> & PNN ) { 47void create_plugin( QList<ANetNode> & PNN ) {
60 PNN.append( new VPNNetNode() ); 48 PNN.append( new VPNNetNode() );
61} 49}
62} 50}
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.h b/noncore/settings/networksettings2/vpn/vpn_NN.h
index 5b6632e..3c7b5e0 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NN.h
+++ b/noncore/settings/networksettings2/vpn/vpn_NN.h
@@ -9,36 +9,28 @@ class VPNNetNode : public ANetNode{
9 9
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 13
14 VPNNetNode(); 14 VPNNetNode();
15 virtual ~VPNNetNode(); 15 virtual ~VPNNetNode();
16 16
17 virtual const QString pixmapName() 17 virtual const QString pixmapName()
18 { return "Devices/vpn"; } 18 { return "Devices/vpn"; }
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21
22 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
23
24 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
25 virtual const char * provides( void ); 23 virtual const char * provides( void );
26 24
27 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
28 virtual bool hasDataFor( const QString & )
29 { return 0; }
30 virtual bool generateDeviceDataForCommonFile(
31 SystemFile & SF, long DevNr );
32
33private: 25private:
34 26
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
36 virtual void saveSpecificAttribute( QTextStream & TS ); 28 virtual void saveSpecificAttribute( QTextStream & TS );
37}; 29};
38 30
39extern "C" 31extern "C"
40{ 32{
41 void create_plugin( QList<ANetNode> & PNN ); 33 void create_plugin( QList<ANetNode> & PNN );
42}; 34};
43 35
44#endif 36#endif
diff --git a/noncore/settings/networksettings2/vpn/vpn_NNI.cpp b/noncore/settings/networksettings2/vpn/vpn_NNI.cpp
index ee999e8..6c20aeb 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NNI.cpp
+++ b/noncore/settings/networksettings2/vpn/vpn_NNI.cpp
@@ -19,18 +19,12 @@ QWidget * AVPN::edit( QWidget * parent ) {
19 return GUI; 19 return GUI;
20} 20}
21 21
22QString AVPN::acceptable( void ) { 22QString AVPN::acceptable( void ) {
23 return ( GUI ) ? GUI->acceptable( ) : QString(); 23 return ( GUI ) ? GUI->acceptable( ) : QString();
24} 24}
25 25
26void AVPN::commit( void ) { 26void AVPN::commit( void ) {
27 if( GUI && GUI->commit( Data ) ) 27 if( GUI && GUI->commit( Data ) )
28 setModified( 1 ); 28 setModified( 1 );
29} 29}
30 30
31bool AVPN::generateDataForCommonFile(
32 SystemFile & ,
33 long) {
34 return 1;
35}
36
diff --git a/noncore/settings/networksettings2/vpn/vpn_NNI.h b/noncore/settings/networksettings2/vpn/vpn_NNI.h
index c3eb016..aee5891 100644
--- a/noncore/settings/networksettings2/vpn/vpn_NNI.h
+++ b/noncore/settings/networksettings2/vpn/vpn_NNI.h
@@ -5,41 +5,37 @@
5#include "vpndata.h" 5#include "vpndata.h"
6#include "vpnrun.h" 6#include "vpnrun.h"
7 7
8class VPNNetNode; 8class VPNNetNode;
9class VPNEdit; 9class VPNEdit;
10 10
11class AVPN : public ANetNodeInstance { 11class AVPN : public ANetNodeInstance {
12 12
13public : 13public :
14 14
15 AVPN( VPNNetNode * PNN ); 15 AVPN( VPNNetNode * PNN );
16 16
17 RuntimeInfo * runtime( void )
18 { return
19 ( RT ) ? RT : ( RT = new VPNRun( this, Data ) );
20 }
21
17 QWidget * edit( QWidget * parent ); 22 QWidget * edit( QWidget * parent );
18 QString acceptable( void ); 23 QString acceptable( void );
19 void commit( void ); 24 void commit( void );
20 25
21 RuntimeInfo * runtime( void )
22 { if( RT == 0 )
23 RT = new VPNRun( this, Data );
24 return RT;
25 }
26
27 virtual void * data( void ) 26 virtual void * data( void )
28 { return (void *)&Data; } 27 { return (void *)&Data; }
29 28
30 virtual bool hasDataFor( const QString & ) 29
31 { return 0; }
32 virtual bool generateDataForCommonFile(
33 SystemFile & SF, long DevNr );
34protected : 30protected :
35 31
36 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 32 virtual void setSpecificAttribute( QString & Attr, QString & Value );
37 virtual void saveSpecificAttribute( QTextStream & TS ); 33 virtual void saveSpecificAttribute( QTextStream & TS );
38 34
39private : 35private :
40 36
41 VPNEdit * GUI; 37 VPNEdit * GUI;
42 VPNData Data; 38 VPNData Data;
43 VPNRun * RT; 39 VPNRun * RT;
44 40
45}; 41};
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
index ce8a734..e4c3f60 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp
@@ -29,47 +29,24 @@ const QString WLanNetNode::nodeDescription(){
29ANetNodeInstance * WLanNetNode::createInstance( void ) { 29ANetNodeInstance * WLanNetNode::createInstance( void ) {
30 return new AWLan( this ); 30 return new AWLan( this );
31} 31}
32 32
33const char ** WLanNetNode::needs( void ) { 33const char ** WLanNetNode::needs( void ) {
34 return WLanNeeds; 34 return WLanNeeds;
35} 35}
36 36
37const char * WLanNetNode::provides( void ) { 37const char * WLanNetNode::provides( void ) {
38 return "device"; 38 return "device";
39} 39}
40 40
41bool WLanNetNode::generateProperFilesFor(
42 ANetNodeInstance * ) {
43 return 0;
44}
45
46bool WLanNetNode::hasDataFor( const QString & S ) {
47 return S == "interfaces";
48}
49
50bool WLanNetNode::generateDeviceDataForCommonFile(
51 SystemFile & S,
52 long DevNr ) {
53 QString NIC = genNic( DevNr );
54
55 if( S.name() == "interfaces" ) {
56 // generate mapping stanza for this interface
57 S << "# check if " << NIC << " can be brought UP" << endl;
58 S << "mapping " << NIC << endl;
59 S << " script networksettings2-request" << endl << endl;
60 }
61 return 0;
62}
63
64QString WLanNetNode::genNic( long nr ) { 41QString WLanNetNode::genNic( long nr ) {
65 QString S; 42 QString S;
66 return S.sprintf( "wlan%ld", nr ); 43 return S.sprintf( "wlan%ld", nr );
67} 44}
68 45
69void WLanNetNode::setSpecificAttribute( QString & A, QString & V ) { 46void WLanNetNode::setSpecificAttribute( QString & A, QString & V ) {
70 if( A == "interfacecount" ) { 47 if( A == "interfacecount" ) {
71 InstanceCount = V.toLong(); 48 InstanceCount = V.toLong();
72 } 49 }
73} 50}
74 51
75void WLanNetNode::saveSpecificAttribute( QTextStream & TS ) { 52void WLanNetNode::saveSpecificAttribute( QTextStream & TS ) {
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.h b/noncore/settings/networksettings2/wlan/wlan_NN.h
index b5ff3fd..c13c05c 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NN.h
+++ b/noncore/settings/networksettings2/wlan/wlan_NN.h
@@ -9,39 +9,30 @@ class WLanNetNode : public ANetNode{
9 9
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
13 13
14 WLanNetNode(); 14 WLanNetNode();
15 virtual ~WLanNetNode(); 15 virtual ~WLanNetNode();
16 16
17 virtual const QString pixmapName() 17 virtual const QString pixmapName()
18 { return "Devices/wlan"; } 18 { return "Devices/wlan"; }
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21
22 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
23
24 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
25 virtual const char * provides( void ); 23 virtual const char * provides( void );
26 24
27 virtual bool generateProperFilesFor( ANetNodeInstance * NNI );
28
29 virtual bool hasDataFor( const QString & S );
30 virtual bool generateDeviceDataForCommonFile(
31 SystemFile & SF, long DevNr );
32
33 virtual long instanceCount( void ) 25 virtual long instanceCount( void )
34 { return InstanceCount; } 26 { return InstanceCount; }
35
36 virtual QString genNic( long ); 27 virtual QString genNic( long );
37 28
38private: 29private:
39 30
40 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 31 virtual void setSpecificAttribute( QString & Attr, QString & Value );
41 virtual void saveSpecificAttribute( QTextStream & TS ); 32 virtual void saveSpecificAttribute( QTextStream & TS );
42 33
43 // number of interfaces for this device 34 // number of interfaces for this device
44 long InstanceCount; 35 long InstanceCount;
45 36
46}; 37};
47 38
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
index 61969f2..0e4fc4c 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
+++ b/noncore/settings/networksettings2/wlan/wlan_NNI.cpp
@@ -70,71 +70,82 @@ QWidget * AWLan::edit( QWidget * parent ) {
70 return GUI; 70 return GUI;
71} 71}
72 72
73QString AWLan::acceptable( void ) { 73QString AWLan::acceptable( void ) {
74 return ( GUI ) ? GUI->acceptable( ) : QString(); 74 return ( GUI ) ? GUI->acceptable( ) : QString();
75} 75}
76 76
77void AWLan::commit( void ) { 77void AWLan::commit( void ) {
78 if( GUI && GUI->commit( Data ) ) 78 if( GUI && GUI->commit( Data ) )
79 setModified( 1 ); 79 setModified( 1 );
80} 80}
81 81
82bool AWLan::generateDataForCommonFile( 82short AWLan::generateFileEmbedded( const QString & ID,
83 SystemFile & S, 83 const QString & Path,
84 long ) { 84 QTextStream & TS,
85 long DevNr ) {
85 86
86 S << " wireless_essid \"" 87 short rvl, rvd;
87 << Data.ESSID
88 << "\""
89 << endl;
90 88
91 if( ! Data.NodeName.isEmpty() ) { 89 rvl = 1;
92 if( Data.NodeName == tr("<UseHostName>") ) { 90
93 char Buf[100]; 91 if( ID == "interfaces" ) {
94 if( gethostname(Buf, sizeof(Buf) ) == 0 ) { 92 Log(("Generate WLanNNI for %s\n", ID.latin1() ));
95 Buf[99] = '\0'; // just to make sure 93 TS << " wireless_essid \""
96 S << " wireless_nick " 94 << Data.ESSID
97 << Buf 95 << "\""
98 << endl; 96 << endl;
97
98 if( ! Data.NodeName.isEmpty() ) {
99 if( Data.NodeName == tr("<UseHostName>") ) {
100 char Buf[100];
101 if( gethostname(Buf, sizeof(Buf) ) == 0 ) {
102 Buf[99] = '\0'; // just to make sure
103 TS << " wireless_nick "
104 << Buf
105 << endl;
106 }
107 } else {
108 TS << " wireless_nick \""
109 << Data.NodeName
110 << "\""
111 << endl;
99 } 112 }
100 } else {
101 S << " wireless_nick \""
102 << Data.NodeName
103 << "\""
104 << endl;
105 } 113 }
106 }
107 114
108 char * M; 115 char * M = "Auto";
109 switch ( Data.Mode ) { 116 switch ( Data.Mode ) {
110 case 0 : 117 case 0 :
111 M = "Auto"; 118 break;
112 break; 119 case 1 :
113 case 1 : 120 M = "Managed";
114 M = "Managed"; 121 break;
115 break; 122 case 2 :
116 case 2 : 123 M = "Ad-Hoc";
117 M = "Ad-Hoc"; 124 break;
118 break; 125 }
119 }
120 126
121 S << " wireless_mode " 127 TS << " wireless_mode "
122 << M 128 << M
123 << endl; 129 << endl;
124 if( Data.Encrypted ) { 130 if( Data.Encrypted ) {
125 for( int i = 0; i < 4; i ++ ) { 131 for( int i = 0; i < 4; i ++ ) {
126 if( ! Data.Key[i].isEmpty() ) { 132 if( ! Data.Key[i].isEmpty() ) {
127 S << " wireless_key" 133 TS << " wireless_key"
128 << i 134 << i
129 << " " 135 << " "
130 << Data.Key[i] 136 << Data.Key[i]
131 << endl; 137 << endl;
138 }
132 } 139 }
140 TS << " wireless_keymode "
141 << ((Data.AcceptNonEncrypted) ? "open" : "restricted")
142 << endl;
133 } 143 }
134 S << " wireless_keymode " 144 rvl = 0;
135 << ((Data.AcceptNonEncrypted) ? "open" : "restricted")
136 << endl;
137 } 145 }
138 return 0; 146 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr);
147
148 return (rvd == 2 || rvl == 2 ) ? 2 :
149 (rvd == 0 || rvl == 0 ) ? 0 : 1;
139} 150}
140 151
diff --git a/noncore/settings/networksettings2/wlan/wlan_NNI.h b/noncore/settings/networksettings2/wlan/wlan_NNI.h
index 2211c47..a9be65f 100644
--- a/noncore/settings/networksettings2/wlan/wlan_NNI.h
+++ b/noncore/settings/networksettings2/wlan/wlan_NNI.h
@@ -5,41 +5,41 @@
5#include "wlandata.h" 5#include "wlandata.h"
6#include "wlanrun.h" 6#include "wlanrun.h"
7 7
8class WLanNetNode; 8class WLanNetNode;
9class WLanEdit; 9class WLanEdit;
10 10
11class AWLan : public ANetNodeInstance { 11class AWLan : public ANetNodeInstance {
12 12
13public : 13public :
14 14
15 AWLan( WLanNetNode * PNN ); 15 AWLan( WLanNetNode * PNN );
16 16
17 RuntimeInfo * runtime( void )
18 { return
19 ( RT ) ? RT : ( RT = new WLanRun( this, Data ) );
20 }
21
17 QWidget * edit( QWidget * parent ); 22 QWidget * edit( QWidget * parent );
18 QString acceptable( void ); 23 QString acceptable( void );
19 void commit( void ); 24 void commit( void );
20 25
21 RuntimeInfo * runtime( void )
22 { if( RT == 0 )
23 RT = new WLanRun( this, Data );
24 return RT;
25 }
26
27 virtual void * data( void ) 26 virtual void * data( void )
28 { return (void *)&Data; } 27 { return (void *)&Data; }
29 28
30 virtual bool hasDataFor( const QString & ) 29 virtual short generateFileEmbedded( const QString & ID,
31 { return 1; } 30 const QString & Path,
32 virtual bool generateDataForCommonFile( 31 QTextStream & TS,
33 SystemFile & SF, long DevNr ); 32 long DevNr );
33
34protected : 34protected :
35 35
36 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 36 virtual void setSpecificAttribute( QString & Attr, QString & Value );
37 virtual void saveSpecificAttribute( QTextStream & TS ); 37 virtual void saveSpecificAttribute( QTextStream & TS );
38 38
39private : 39private :
40 40
41 WLanEdit * GUI; 41 WLanEdit * GUI;
42 WLanData Data; 42 WLanData Data;
43 WLanRun * RT; 43 WLanRun * RT;
44 44
45}; 45};