21 files changed, 222 insertions, 518 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp index 5e4d951..5c2b8b2 100644 --- a/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp +++ b/noncore/settings/networksettings2/bluetooth/bluetoothBNEP_NN.cpp | |||
@@ -1,22 +1,18 @@ | |||
1 | #include "bluetoothBNEP_NN.h" | 1 | #include "bluetoothBNEP_NN.h" |
2 | #include "bluetoothBNEP_NNI.h" | 2 | #include "bluetoothBNEP_NNI.h" |
3 | #include "bluetoothRFCOMM_NNI.h" | 3 | #include "bluetoothRFCOMM_NNI.h" |
4 | 4 | ||
5 | #ifndef MYPLUGIN | ||
6 | |||
7 | #include "netnodeinterface.h" | 5 | #include "netnodeinterface.h" |
8 | 6 | ||
9 | #endif | ||
10 | |||
11 | // | 7 | // |
12 | // | 8 | // |
13 | // BLUETOOTH PAN/NAP node | 9 | // BLUETOOTH PAN/NAP node |
14 | // | 10 | // |
15 | // | 11 | // |
16 | 12 | ||
17 | static const char * BluetoothBNEPNeeds[] = | 13 | static const char * BluetoothBNEPNeeds[] = |
18 | { 0 | 14 | { 0 |
19 | }; | 15 | }; |
20 | 16 | ||
21 | static const char * BluetoothBNEPProvides[] = | 17 | static const char * BluetoothBNEPProvides[] = |
22 | { "device", | 18 | { "device", |
@@ -66,29 +62,14 @@ QString BluetoothBNEPNetNode::genNic( long nr ) { | |||
66 | void BluetoothBNEPNetNode::setSpecificAttribute( QString & A, QString & V ) { | 62 | void BluetoothBNEPNetNode::setSpecificAttribute( QString & A, QString & V ) { |
67 | if( A == "interfacecount" ) { | 63 | if( A == "interfacecount" ) { |
68 | InstanceCount = V.toLong(); | 64 | InstanceCount = V.toLong(); |
69 | } | 65 | } |
70 | } | 66 | } |
71 | 67 | ||
72 | void BluetoothBNEPNetNode::saveSpecificAttribute( QTextStream & TS) { | 68 | void BluetoothBNEPNetNode::saveSpecificAttribute( QTextStream & TS) { |
73 | TS << "interfacecount=" | 69 | TS << "interfacecount=" |
74 | << InstanceCount | 70 | << InstanceCount |
75 | << endl; | 71 | << endl; |
76 | } | 72 | } |
77 | 73 | ||
78 | #ifndef MYPLUGIN | ||
79 | |||
80 | extern "C" { | ||
81 | // create plugin registers both BT functions | ||
82 | void create_plugin( QList<ANetNode> & PNN ) { | ||
83 | PNN.append( new BluetoothBNEPNetNode() ); | ||
84 | PNN.append( new BluetoothRFCOMMNetNode() ); | ||
85 | } | ||
86 | |||
87 | #else | ||
88 | |||
89 | typedef Opie::Core::MakeTypelist<BluetoothBNEPNetNode, BluetoothRFCOMMNetNode>::Result BluetoothTypes; | 74 | typedef Opie::Core::MakeTypelist<BluetoothBNEPNetNode, BluetoothRFCOMMNetNode>::Result BluetoothTypes; |
90 | OPIE_NS2_PLUGIN( NetNodeInterface<BluetoothTypes> ) | 75 | OPIE_NS2_PLUGIN( NetNodeInterface_T<BluetoothTypes> ) |
91 | |||
92 | #endif | ||
93 | |||
94 | } | ||
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp index 20299e4..58237a1 100644 --- a/noncore/settings/networksettings2/cable/cable_NN.cpp +++ b/noncore/settings/networksettings2/cable/cable_NN.cpp | |||
@@ -1,21 +1,17 @@ | |||
1 | #include "cable_NN.h" | 1 | #include "cable_NN.h" |
2 | #include "cable_NNI.h" | 2 | #include "cable_NNI.h" |
3 | 3 | ||
4 | #ifndef MYPLUGIN | ||
5 | |||
6 | #include "netnodeinterface.h" | 4 | #include "netnodeinterface.h" |
7 | 5 | ||
8 | #endif | ||
9 | |||
10 | static const char * CableNeeds[] = | 6 | static const char * CableNeeds[] = |
11 | { 0 | 7 | { 0 |
12 | }; | 8 | }; |
13 | 9 | ||
14 | static const char * CableProvides[] = | 10 | static const char * CableProvides[] = |
15 | { "line", | 11 | { "line", |
16 | 0 | 12 | 0 |
17 | }; | 13 | }; |
18 | 14 | ||
19 | /** | 15 | /** |
20 | * Constructor, find all of the possible interfaces | 16 | * Constructor, find all of the possible interfaces |
21 | */ | 17 | */ |
@@ -44,26 +40,13 @@ const char ** CableNetNode::needs( void ) { | |||
44 | } | 40 | } |
45 | 41 | ||
46 | const char ** CableNetNode::provides( void ) { | 42 | const char ** CableNetNode::provides( void ) { |
47 | return CableProvides; | 43 | return CableProvides; |
48 | } | 44 | } |
49 | 45 | ||
50 | void CableNetNode::setSpecificAttribute( QString & , QString & ) { | 46 | void CableNetNode::setSpecificAttribute( QString & , QString & ) { |
51 | } | 47 | } |
52 | 48 | ||
53 | void CableNetNode::saveSpecificAttribute( QTextStream & ) { | 49 | void CableNetNode::saveSpecificAttribute( QTextStream & ) { |
54 | } | 50 | } |
55 | 51 | ||
56 | #ifdef MYPLUGIN | 52 | OPIE_NS2_PLUGIN( NetNodeInterface_T<CableNetNode> ) |
57 | |||
58 | extern "C" { | ||
59 | void create_plugin( QList<ANetNode> & PNN ) { | ||
60 | PNN.append( new CableNetNode() ); | ||
61 | } | ||
62 | |||
63 | #else | ||
64 | |||
65 | OPIE_NS2_PLUGIN( NetNodeInterface<CableNetNode> ) | ||
66 | |||
67 | #endif | ||
68 | |||
69 | } | ||
diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index 3f8a53f..0c3ead6 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp | |||
@@ -312,29 +312,28 @@ void EditConnection::buildFullTree( void ) { | |||
312 | // toplevel item | 312 | // toplevel item |
313 | MyQCheckListItem * TheTop = new MyQCheckListItem( | 313 | MyQCheckListItem * TheTop = new MyQCheckListItem( |
314 | Nodes_LV, | 314 | Nodes_LV, |
315 | NSResources->netNode2Name("fullsetup"), | 315 | NSResources->netNode2Name("fullsetup"), |
316 | QCheckListItem::Controller ); | 316 | QCheckListItem::Controller ); |
317 | TheTop->setOpen( TRUE ); | 317 | TheTop->setOpen( TRUE ); |
318 | Description_LBL->setText( | 318 | Description_LBL->setText( |
319 | NSResources->netNode2Description( "fullsetup" ) ); | 319 | NSResources->netNode2Description( "fullsetup" ) ); |
320 | Nodes_LV->setSelected( TheTop, TRUE ); | 320 | Nodes_LV->setSelected( TheTop, TRUE ); |
321 | 321 | ||
322 | // find all Nodes that are toplevel nodes -> ie provide | 322 | // find all Nodes that are toplevel nodes -> ie provide |
323 | // TCP/IP Connection | 323 | // TCP/IP Connection |
324 | for( QDictIterator<NetNode_t> Iter(NSResources->netNodes()); | 324 | for( QDictIterator<ANetNode> Iter(NSResources->netNodes()); |
325 | Iter.current(); | 325 | Iter.current(); |
326 | ++Iter ) { | 326 | ++Iter ) { |
327 | 327 | NN = Iter.current(); | |
328 | NN = Iter.current()->NetNode; | ||
329 | 328 | ||
330 | if( ! NN->isToplevel() ) { | 329 | if( ! NN->isToplevel() ) { |
331 | continue; | 330 | continue; |
332 | } | 331 | } |
333 | 332 | ||
334 | MyQCheckListItem * it = new MyQCheckListItem( TheTop, | 333 | MyQCheckListItem * it = new MyQCheckListItem( TheTop, |
335 | NN->name(), | 334 | NN->name(), |
336 | QCheckListItem::RadioButton ); | 335 | QCheckListItem::RadioButton ); |
337 | it->setPixmap( 0, | 336 | it->setPixmap( 0, |
338 | NSResources->getPixmap( NN->pixmapName() ) | 337 | NSResources->getPixmap( NN->pixmapName() ) |
339 | ); | 338 | ); |
340 | // remember that this node maps to this listitem | 339 | // remember that this node maps to this listitem |
diff --git a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp index 4415739..e9553a6 100644 --- a/noncore/settings/networksettings2/gprs/GPRS_NN.cpp +++ b/noncore/settings/networksettings2/gprs/GPRS_NN.cpp | |||
@@ -1,24 +1,20 @@ | |||
1 | #include <resources.h> | 1 | #include <resources.h> |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <netnode.h> | 3 | #include <netnode.h> |
4 | #include "GPRS_NN.h" | 4 | #include "GPRS_NN.h" |
5 | #include "GPRS_NNI.h" | 5 | #include "GPRS_NNI.h" |
6 | 6 | ||
7 | #ifndef MYPLUGIN | ||
8 | |||
9 | #include "netnodeinterface.h" | 7 | #include "netnodeinterface.h" |
10 | 8 | ||
11 | #endif | ||
12 | |||
13 | static const char * GPRSNeeds[] = | 9 | static const char * GPRSNeeds[] = |
14 | { "GPRS", | 10 | { "GPRS", |
15 | 0 | 11 | 0 |
16 | }; | 12 | }; |
17 | 13 | ||
18 | static const char * GPRSProvides[] = | 14 | static const char * GPRSProvides[] = |
19 | { "connection", | 15 | { "connection", |
20 | 0 | 16 | 0 |
21 | }; | 17 | }; |
22 | 18 | ||
23 | /** | 19 | /** |
24 | * Constructor, find all of the possible interfaces | 20 | * Constructor, find all of the possible interfaces |
@@ -70,26 +66,13 @@ void GPRSNetNode::setSpecificAttribute( QString & , QString & ) { | |||
70 | void GPRSNetNode::saveSpecificAttribute( QTextStream & ) { | 66 | void GPRSNetNode::saveSpecificAttribute( QTextStream & ) { |
71 | } | 67 | } |
72 | 68 | ||
73 | QStringList GPRSNetNode::properFiles( void ) { | 69 | QStringList GPRSNetNode::properFiles( void ) { |
74 | QStringList SL; | 70 | QStringList SL; |
75 | 71 | ||
76 | SL << "peers"; | 72 | SL << "peers"; |
77 | SL << "chatscripts"; | 73 | SL << "chatscripts"; |
78 | SL << "extra"; | 74 | SL << "extra"; |
79 | return SL; | 75 | return SL; |
80 | } | 76 | } |
81 | 77 | ||
82 | #ifdef MYPLUGIN | 78 | OPIE_NS2_PLUGIN( NetNodeInterface_T<GPRSNetNode> ) |
83 | |||
84 | extern "C" { | ||
85 | void create_plugin( QList<ANetNode> & PNN ) { | ||
86 | PNN.append( new GPRSNetNode() ); | ||
87 | } | ||
88 | |||
89 | #else | ||
90 | |||
91 | OPIE_NS2_PLUGIN( NetNodeInterface<GPRSNetNode> ) | ||
92 | |||
93 | #endif | ||
94 | |||
95 | } | ||
diff --git a/noncore/settings/networksettings2/irda/irda_NN.cpp b/noncore/settings/networksettings2/irda/irda_NN.cpp index 6858157..a1ed686 100644 --- a/noncore/settings/networksettings2/irda/irda_NN.cpp +++ b/noncore/settings/networksettings2/irda/irda_NN.cpp | |||
@@ -1,21 +1,17 @@ | |||
1 | #include "irda_NN.h" | 1 | #include "irda_NN.h" |
2 | #include "irda_NNI.h" | 2 | #include "irda_NNI.h" |
3 | 3 | ||
4 | #ifndef MYPLUGIN | ||
5 | |||
6 | #include "netnodeinterface.h" | 4 | #include "netnodeinterface.h" |
7 | 5 | ||
8 | #endif | ||
9 | |||
10 | static const char * IRDANeeds[] = | 6 | static const char * IRDANeeds[] = |
11 | { 0 | 7 | { 0 |
12 | }; | 8 | }; |
13 | 9 | ||
14 | static const char * IRDAProvides[] = | 10 | static const char * IRDAProvides[] = |
15 | { "line", | 11 | { "line", |
16 | 0 | 12 | 0 |
17 | }; | 13 | }; |
18 | 14 | ||
19 | /** | 15 | /** |
20 | * Constructor, find all of the possible interfaces | 16 | * Constructor, find all of the possible interfaces |
21 | */ | 17 | */ |
@@ -44,26 +40,13 @@ const char ** IRDANetNode::needs( void ) { | |||
44 | } | 40 | } |
45 | 41 | ||
46 | const char ** IRDANetNode::provides( void ) { | 42 | const char ** IRDANetNode::provides( void ) { |
47 | return IRDAProvides; | 43 | return IRDAProvides; |
48 | } | 44 | } |
49 | 45 | ||
50 | void IRDANetNode::setSpecificAttribute( QString & , QString & ) { | 46 | void IRDANetNode::setSpecificAttribute( QString & , QString & ) { |
51 | } | 47 | } |
52 | 48 | ||
53 | void IRDANetNode::saveSpecificAttribute( QTextStream & ) { | 49 | void IRDANetNode::saveSpecificAttribute( QTextStream & ) { |
54 | } | 50 | } |
55 | 51 | ||
56 | #ifdef MYPLUGIN | 52 | OPIE_NS2_PLUGIN( NetNodeInterface_T<IRDANetNode> ) |
57 | |||
58 | extern "C" { | ||
59 | void create_plugin( QList<ANetNode> & PNN ) { | ||
60 | PNN.append( new IRDANetNode() ); | ||
61 | } | ||
62 | |||
63 | #else | ||
64 | |||
65 | OPIE_NS2_PLUGIN( NetNodeInterface<IRDANetNode> ) | ||
66 | |||
67 | #endif | ||
68 | |||
69 | } | ||
diff --git a/noncore/settings/networksettings2/lancard/lancard_NN.cpp b/noncore/settings/networksettings2/lancard/lancard_NN.cpp index fce3d29..520516c 100644 --- a/noncore/settings/networksettings2/lancard/lancard_NN.cpp +++ b/noncore/settings/networksettings2/lancard/lancard_NN.cpp | |||
@@ -1,21 +1,17 @@ | |||
1 | #include "lancard_NN.h" | 1 | #include "lancard_NN.h" |
2 | #include "lancard_NNI.h" | 2 | #include "lancard_NNI.h" |
3 | 3 | ||
4 | #ifndef MYPLUGIN | ||
5 | |||
6 | #include "netnodeinterface.h" | 4 | #include "netnodeinterface.h" |
7 | 5 | ||
8 | #endif | ||
9 | |||
10 | static const char * LanCardNeeds[] = | 6 | static const char * LanCardNeeds[] = |
11 | { 0 | 7 | { 0 |
12 | }; | 8 | }; |
13 | 9 | ||
14 | static const char * LanCardProvides[] = | 10 | static const char * LanCardProvides[] = |
15 | { "device", | 11 | { "device", |
16 | 0 | 12 | 0 |
17 | }; | 13 | }; |
18 | 14 | ||
19 | /** | 15 | /** |
20 | * Constructor, find all of the possible interfaces | 16 | * Constructor, find all of the possible interfaces |
21 | */ | 17 | */ |
@@ -67,26 +63,13 @@ void LanCardNetNode::saveSpecificAttribute( QTextStream & TS) { | |||
67 | TS << "interfacecount=" | 63 | TS << "interfacecount=" |
68 | << InstanceCount | 64 | << InstanceCount |
69 | << endl; | 65 | << endl; |
70 | for( QStringList::Iterator it = NICMACAddresses.begin(); | 66 | for( QStringList::Iterator it = NICMACAddresses.begin(); |
71 | it != NICMACAddresses.end(); | 67 | it != NICMACAddresses.end(); |
72 | ++it ) { | 68 | ++it ) { |
73 | TS << "macaddress=" | 69 | TS << "macaddress=" |
74 | << (*it) | 70 | << (*it) |
75 | << endl; | 71 | << endl; |
76 | } | 72 | } |
77 | } | 73 | } |
78 | 74 | ||
79 | #ifdef MYPLUGIN | 75 | OPIE_NS2_PLUGIN( NetNodeInterface_T<LanCardNetNode> ) |
80 | |||
81 | extern "C" { | ||
82 | void create_plugin( QList<ANetNode> & PNN ) { | ||
83 | PNN.append( new LanCardNetNode() ); | ||
84 | } | ||
85 | |||
86 | #else | ||
87 | |||
88 | OPIE_NS2_PLUGIN( NetNodeInterface<LanCardNetNode> ) | ||
89 | |||
90 | #endif | ||
91 | |||
92 | } | ||
diff --git a/noncore/settings/networksettings2/modem/modem_NN.cpp b/noncore/settings/networksettings2/modem/modem_NN.cpp index c7f6e78..e91b45a 100644 --- a/noncore/settings/networksettings2/modem/modem_NN.cpp +++ b/noncore/settings/networksettings2/modem/modem_NN.cpp | |||
@@ -1,21 +1,17 @@ | |||
1 | #include "modem_NN.h" | 1 | #include "modem_NN.h" |
2 | #include "modem_NNI.h" | 2 | #include "modem_NNI.h" |
3 | 3 | ||
4 | #ifndef MYPLUGIN | ||
5 | |||
6 | #include "netnodeinterface.h" | 4 | #include "netnodeinterface.h" |
7 | 5 | ||
8 | #endif | ||
9 | |||
10 | static const char * ModemNeeds[] = | 6 | static const char * ModemNeeds[] = |
11 | { "line", | 7 | { "line", |
12 | 0 | 8 | 0 |
13 | }; | 9 | }; |
14 | static const char * ModemProvides[] = | 10 | static const char * ModemProvides[] = |
15 | { "modem", | 11 | { "modem", |
16 | 0 | 12 | 0 |
17 | }; | 13 | }; |
18 | 14 | ||
19 | /** | 15 | /** |
20 | * Constructor, find all of the possible interfaces | 16 | * Constructor, find all of the possible interfaces |
21 | */ | 17 | */ |
@@ -45,26 +41,13 @@ const char ** ModemNetNode::needs( void ) { | |||
45 | } | 41 | } |
46 | 42 | ||
47 | const char ** ModemNetNode::provides( void ) { | 43 | const char ** ModemNetNode::provides( void ) { |
48 | return ModemProvides; | 44 | return ModemProvides; |
49 | } | 45 | } |
50 | 46 | ||
51 | void ModemNetNode::setSpecificAttribute( QString & , QString & ) { | 47 | void ModemNetNode::setSpecificAttribute( QString & , QString & ) { |
52 | } | 48 | } |
53 | 49 | ||
54 | void ModemNetNode::saveSpecificAttribute( QTextStream & ) { | 50 | void ModemNetNode::saveSpecificAttribute( QTextStream & ) { |
55 | } | 51 | } |
56 | 52 | ||
57 | #ifdef MYPLUGIN | 53 | OPIE_NS2_PLUGIN( NetNodeInterface_T<ModemNetNode> ) |
58 | |||
59 | extern "C" { | ||
60 | void create_plugin( QList<ANetNode> & PNN ) { | ||
61 | PNN.append( new ModemNetNode() ); | ||
62 | } | ||
63 | |||
64 | #else | ||
65 | |||
66 | OPIE_NS2_PLUGIN( NetNodeInterface<ModemNetNode> ) | ||
67 | |||
68 | #endif | ||
69 | |||
70 | } | ||
diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index 82d0c29..2fa31bd 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp | |||
@@ -1,24 +1,20 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <resources.h> | 2 | #include <resources.h> |
3 | #include <netnode.h> | 3 | #include <netnode.h> |
4 | #include "network_NN.h" | 4 | #include "network_NN.h" |
5 | #include "network_NNI.h" | 5 | #include "network_NNI.h" |
6 | 6 | ||
7 | #ifndef MYPLUGIN | ||
8 | |||
9 | #include "netnodeinterface.h" | 7 | #include "netnodeinterface.h" |
10 | 8 | ||
11 | #endif | ||
12 | |||
13 | static const char * NetworkNeeds[] = | 9 | static const char * NetworkNeeds[] = |
14 | { "device", | 10 | { "device", |
15 | 0 | 11 | 0 |
16 | }; | 12 | }; |
17 | 13 | ||
18 | static const char * NetworkProvides[] = | 14 | static const char * NetworkProvides[] = |
19 | { "connection", | 15 | { "connection", |
20 | 0 | 16 | 0 |
21 | }; | 17 | }; |
22 | 18 | ||
23 | /** | 19 | /** |
24 | * Constructor, find all of the possible interfaces | 20 | * Constructor, find all of the possible interfaces |
@@ -87,26 +83,13 @@ const char ** NetworkNetNode::needs( void ) { | |||
87 | } | 83 | } |
88 | 84 | ||
89 | const char ** NetworkNetNode::provides( void ) { | 85 | const char ** NetworkNetNode::provides( void ) { |
90 | return NetworkProvides; | 86 | return NetworkProvides; |
91 | } | 87 | } |
92 | 88 | ||
93 | void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { | 89 | void NetworkNetNode::setSpecificAttribute( QString & , QString & ) { |
94 | } | 90 | } |
95 | 91 | ||
96 | void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { | 92 | void NetworkNetNode::saveSpecificAttribute( QTextStream & ) { |
97 | } | 93 | } |
98 | 94 | ||
99 | #ifdef MYPLUGIN | 95 | OPIE_NS2_PLUGIN( NetNodeInterface_T<NetworkNetNode> ) |
100 | |||
101 | extern "C" { | ||
102 | void create_plugin( QList<ANetNode> & PNN ) { | ||
103 | PNN.append( new NetworkNetNode() ); | ||
104 | } | ||
105 | |||
106 | #else | ||
107 | |||
108 | OPIE_NS2_PLUGIN( NetNodeInterface<NetworkNetNode> ) | ||
109 | |||
110 | #endif | ||
111 | |||
112 | } | ||
diff --git a/noncore/settings/networksettings2/networksettings.cpp b/noncore/settings/networksettings2/networksettings.cpp index dca6631..9680a96 100644 --- a/noncore/settings/networksettings2/networksettings.cpp +++ b/noncore/settings/networksettings2/networksettings.cpp | |||
@@ -228,36 +228,36 @@ void NetworkSettings::SLOT_EditNode( QListBoxItem * LBI ) { | |||
228 | NodeCollection * LCN = NSResources->findConnection( | 228 | NodeCollection * LCN = NSResources->findConnection( |
229 | NC->name() ); | 229 | NC->name() ); |
230 | if( LCN ) { | 230 | if( LCN ) { |
231 | QMessageBox::warning( | 231 | QMessageBox::warning( |
232 | 0, | 232 | 0, |
233 | tr( "In System Config" ), | 233 | tr( "In System Config" ), |
234 | tr( "Name %1 already exists" ).arg(NC->name()) | 234 | tr( "Name %1 already exists" ).arg(NC->name()) |
235 | ); | 235 | ); |
236 | continue; // restart exec | 236 | continue; // restart exec |
237 | } // else new name | 237 | } // else new name |
238 | // new name -> remove item | 238 | // new name -> remove item |
239 | NSResources->removeConnection( OldName ); | 239 | NSResources->removeConnection( OldName ); |
240 | NSResources->addConnection( NC ); | 240 | NSResources->addConnection( NC, 0 ); |
241 | } // else not changed | 241 | } // else not changed |
242 | 242 | ||
243 | // must add it here since change will trigger event | 243 | // must add it here since change will trigger event |
244 | Profiles_LB->changeItem( NC->devicePixmap(), | 244 | Profiles_LB->changeItem( NC->devicePixmap(), |
245 | NC->name(), | 245 | NC->name(), |
246 | Profiles_LB->index( LBI ) | 246 | Profiles_LB->index( LBI ) |
247 | ); | 247 | ); |
248 | } else { | 248 | } else { |
249 | // new item | 249 | // new item |
250 | int ci = Profiles_LB->count(); | 250 | int ci = Profiles_LB->count(); |
251 | NSResources->addConnection( NC ); | 251 | NSResources->addConnection( NC, 0 ); |
252 | NC->setNumber( NSResources->assignConnectionNumber() ); | 252 | NC->setNumber( NSResources->assignConnectionNumber() ); |
253 | Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); | 253 | Profiles_LB->insertItem( NC->devicePixmap(), NC->name() ); |
254 | Profiles_LB->setSelected( ci, TRUE ); | 254 | Profiles_LB->setSelected( ci, TRUE ); |
255 | } | 255 | } |
256 | updateProfileState( LBI ); | 256 | updateProfileState( LBI ); |
257 | } | 257 | } |
258 | } else { | 258 | } else { |
259 | // cancelled : reset connection | 259 | // cancelled : reset connection |
260 | if( LBI ) { | 260 | if( LBI ) { |
261 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); | 261 | NodeCollection * NC = NSResources->findConnection( LBI->text() ); |
262 | NC->reassign(); | 262 | NC->reassign(); |
263 | } | 263 | } |
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index f8f2d1e..f00e0b3 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp | |||
@@ -132,78 +132,83 @@ ANetNodeInstance * ANetNodeInstance::nextNode( void ) { | |||
132 | // | 132 | // |
133 | // NODECOLLECTION | 133 | // NODECOLLECTION |
134 | // | 134 | // |
135 | // | 135 | // |
136 | 136 | ||
137 | NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { | 137 | NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { |
138 | IsModified = 0; | 138 | IsModified = 0; |
139 | Index = -1; | 139 | Index = -1; |
140 | Name=""; | 140 | Name=""; |
141 | IsNew = 1; | 141 | IsNew = 1; |
142 | CurrentState = Unchecked; | 142 | CurrentState = Unchecked; |
143 | AssignedInterface = 0; | 143 | AssignedInterface = 0; |
144 | Number = -1; | ||
145 | Done = 0; | ||
144 | } | 146 | } |
145 | 147 | ||
146 | NodeCollection::NodeCollection( QTextStream & TS ) : | 148 | NodeCollection::NodeCollection( QTextStream & TS, bool & Dangling ) : |
147 | QList<ANetNodeInstance>() { | 149 | QList<ANetNodeInstance>() { |
148 | long idx; | 150 | long idx; |
149 | bool InError = 0; | ||
150 | QString S, A, N; | 151 | QString S, A, N; |
152 | |||
153 | Number = -1; | ||
154 | Done = 0; | ||
151 | IsModified = 0; | 155 | IsModified = 0; |
152 | Index = -1; | 156 | Index = -1; |
153 | Name=""; | 157 | Name=""; |
154 | IsNew = 0; | 158 | IsNew = 0; |
155 | AssignedInterface = 0; | 159 | AssignedInterface = 0; |
156 | CurrentState = Unchecked; | 160 | CurrentState = Unchecked; |
157 | 161 | ||
162 | Dangling = 0; // by default node collection is ok | ||
163 | |||
158 | do { | 164 | do { |
159 | S = TS.readLine(); | 165 | S = TS.readLine(); |
160 | if( S.isEmpty() ) { | 166 | if( S.isEmpty() ) { |
161 | if( InError ) { | ||
162 | // remove all nodes | ||
163 | clear(); | ||
164 | } | ||
165 | // empty line | 167 | // empty line |
166 | break; | 168 | break; |
167 | } | 169 | } |
168 | 170 | ||
169 | idx = S.find('='); | 171 | idx = S.find('='); |
170 | S.stripWhiteSpace(); | 172 | S.stripWhiteSpace(); |
171 | A = S.left( idx ); | 173 | A = S.left( idx ); |
172 | A.lower(); | 174 | A.lower(); |
173 | N = S.mid( idx+1, S.length() ); | 175 | N = S.mid( idx+1, S.length() ); |
174 | N.stripWhiteSpace(); | 176 | N.stripWhiteSpace(); |
175 | N = deQuote( N ); | 177 | N = deQuote( N ); |
176 | 178 | ||
177 | if( A == "name" ) { | 179 | if( A == "name" ) { |
178 | Name = N; | 180 | Name = N; |
179 | } else if( A == "number" ) { | 181 | } else if( A == "number" ) { |
180 | setNumber( N.toLong() ); | 182 | setNumber( N.toLong() ); |
181 | } else if( A == "node" ) { | 183 | } else if( A == "node" ) { |
182 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); | 184 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); |
183 | Log(( "Find node %s : %p\n", N.latin1(), NNI )); | 185 | Log(( "Find node %s : %p\n", N.latin1(), NNI )); |
184 | if( NNI && ! InError ) { | 186 | if( NNI ) { |
185 | append( NNI ); | 187 | append( NNI ); |
186 | } else { | 188 | } else { |
187 | // could not find a node type -> collection invalid | 189 | // could not find a node type -> collection invalid |
188 | InError = 1; | 190 | Log(( "Node %s missing -> connection dangling\n", |
191 | N.latin1() )); | ||
192 | // create placeholder for this dangling NNI | ||
193 | NNI = new ErrorNNI( N ); | ||
194 | Dangling = 1; | ||
189 | } | 195 | } |
190 | } | 196 | } |
191 | } while( 1 ); | 197 | } while( 1 ); |
192 | 198 | ||
193 | Log(( "Profile number %s : %d nodes\n", | 199 | Log(( "Profile number %s : %d nodes\n", |
194 | Name.latin1(), count() )); | 200 | Name.latin1(), count() )); |
195 | } | 201 | } |
196 | 202 | ||
197 | |||
198 | NodeCollection::~NodeCollection( void ) { | 203 | NodeCollection::~NodeCollection( void ) { |
199 | } | 204 | } |
200 | 205 | ||
201 | const QString & NodeCollection::description( void ) { | 206 | const QString & NodeCollection::description( void ) { |
202 | ANetNodeInstance * NNI = getToplevel(); | 207 | ANetNodeInstance * NNI = getToplevel(); |
203 | return (NNI) ? NNI->runtime()->description() : Name; | 208 | return (NNI) ? NNI->runtime()->description() : Name; |
204 | } | 209 | } |
205 | 210 | ||
206 | void NodeCollection::append( ANetNodeInstance * NNI ) { | 211 | void NodeCollection::append( ANetNodeInstance * NNI ) { |
207 | NNI->setConnection( this ); | 212 | NNI->setConnection( this ); |
208 | QList<ANetNodeInstance>::append( NNI ); | 213 | QList<ANetNodeInstance>::append( NNI ); |
209 | } | 214 | } |
@@ -220,40 +225,42 @@ void NodeCollection::save( QTextStream & TS ) { | |||
220 | TS << "node=" << NNI->name() << endl; | 225 | TS << "node=" << NNI->name() << endl; |
221 | } | 226 | } |
222 | TS << endl; | 227 | TS << endl; |
223 | IsNew = 0; | 228 | IsNew = 0; |
224 | } | 229 | } |
225 | 230 | ||
226 | ANetNodeInstance * NodeCollection::getToplevel( void ) { | 231 | ANetNodeInstance * NodeCollection::getToplevel( void ) { |
227 | ANetNodeInstance * NNI = 0; | 232 | ANetNodeInstance * NNI = 0; |
228 | for( QListIterator<ANetNodeInstance> it(*this); | 233 | for( QListIterator<ANetNodeInstance> it(*this); |
229 | it.current(); | 234 | it.current(); |
230 | ++it ) { | 235 | ++it ) { |
231 | NNI = it.current(); | 236 | NNI = it.current(); |
232 | if( NNI->nodeClass()->isToplevel() ) | 237 | if( NNI->nodeClass()->isToplevel() ) { |
233 | break; | 238 | return NNI; |
239 | } | ||
234 | } | 240 | } |
235 | return NNI; | 241 | return 0; |
236 | } | 242 | } |
237 | 243 | ||
238 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { | 244 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { |
239 | ANetNodeInstance * NNI = 0; | 245 | ANetNodeInstance * NNI = 0; |
240 | for( QListIterator<ANetNodeInstance> it(*this); | 246 | for( QListIterator<ANetNodeInstance> it(*this); |
241 | it.current(); | 247 | it.current(); |
242 | ++it ) { | 248 | ++it ) { |
243 | NNI = it.current(); | 249 | NNI = it.current(); |
244 | if( NNI->name() == S ) | 250 | if( NNI->name() == S ) { |
245 | break; | 251 | return NNI; |
252 | } | ||
246 | } | 253 | } |
247 | return NNI; | 254 | return 0; |
248 | } | 255 | } |
249 | 256 | ||
250 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { | 257 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { |
251 | ANetNodeInstance * NNNI; | 258 | ANetNodeInstance * NNNI; |
252 | 259 | ||
253 | if( ! NNI ) | 260 | if( ! NNI ) |
254 | getToplevel(); | 261 | getToplevel(); |
255 | 262 | ||
256 | for( QListIterator<ANetNodeInstance> it(*this); | 263 | for( QListIterator<ANetNodeInstance> it(*this); |
257 | it.current(); | 264 | it.current(); |
258 | ++it ) { | 265 | ++it ) { |
259 | NNNI = it.current(); | 266 | NNNI = it.current(); |
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h index 4626381..151d546 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.h +++ b/noncore/settings/networksettings2/networksettings2/netnode.h | |||
@@ -310,30 +310,72 @@ public: | |||
310 | virtual void * data( void ) = 0; | 310 | virtual void * data( void ) = 0; |
311 | 311 | ||
312 | protected : | 312 | protected : |
313 | 313 | ||
314 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | 314 | virtual void setSpecificAttribute( QString & , QString & ) = 0; |
315 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | 315 | virtual void saveSpecificAttribute( QTextStream & ) = 0; |
316 | 316 | ||
317 | ANetNode * NodeType; | 317 | ANetNode * NodeType; |
318 | // connection to which this node belongs to | 318 | // connection to which this node belongs to |
319 | NodeCollection * Connection; | 319 | NodeCollection * Connection; |
320 | QString Description; | 320 | QString Description; |
321 | bool IsModified; | 321 | bool IsModified; |
322 | // true if this nodeinstance was just created (and not | ||
323 | // loaded from file | ||
322 | bool IsNew; | 324 | bool IsNew; |
323 | int Done; | 325 | int Done; |
324 | 326 | ||
325 | static long InstanceCounter; | 327 | static long InstanceCounter; |
326 | }; | 328 | }; |
327 | 329 | ||
330 | class ErrorNNI: public ANetNodeInstance { | ||
331 | |||
332 | public: | ||
333 | |||
334 | ErrorNNI( const QString & _Name ) : ANetNodeInstance( 0 ) { | ||
335 | setName( _Name.latin1() ); | ||
336 | } | ||
337 | |||
338 | RuntimeInfo * runtime( void ) { | ||
339 | return 0; | ||
340 | } | ||
341 | |||
342 | // create edit widget under parent | ||
343 | QWidget * edit( QWidget * parent ) { | ||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | // is given data acceptable | ||
348 | QString acceptable( void ) { | ||
349 | return QString(); | ||
350 | } | ||
351 | |||
352 | // get data from GUI and store in node | ||
353 | void commit( void ) { | ||
354 | } | ||
355 | |||
356 | // returns node specific data -> only useful for 'buddy' | ||
357 | void * data( void ) { | ||
358 | return 0; | ||
359 | } | ||
360 | |||
361 | protected : | ||
362 | |||
363 | void setSpecificAttribute( QString & , QString & ) { | ||
364 | } | ||
365 | |||
366 | void saveSpecificAttribute( QTextStream & ) { | ||
367 | } | ||
368 | }; | ||
369 | |||
328 | class RuntimeInfo : public QObject { | 370 | class RuntimeInfo : public QObject { |
329 | 371 | ||
330 | Q_OBJECT | 372 | Q_OBJECT |
331 | 373 | ||
332 | public : | 374 | public : |
333 | 375 | ||
334 | RuntimeInfo( ANetNodeInstance * TheNNI ) | 376 | RuntimeInfo( ANetNodeInstance * TheNNI ) |
335 | { NNI = TheNNI; } | 377 | { NNI = TheNNI; } |
336 | 378 | ||
337 | // | 379 | // |
338 | // | 380 | // |
339 | // methods to be overloaded by connection capable | 381 | // methods to be overloaded by connection capable |
@@ -459,25 +501,25 @@ protected : | |||
459 | Action_t A, | 501 | Action_t A, |
460 | bool Force = 0 ) = 0; | 502 | bool Force = 0 ) = 0; |
461 | 503 | ||
462 | // connection this runtime info belongs to | 504 | // connection this runtime info belongs to |
463 | ANetNodeInstance * NNI; | 505 | ANetNodeInstance * NNI; |
464 | }; | 506 | }; |
465 | 507 | ||
466 | class NodeCollection : public QList<ANetNodeInstance> { | 508 | class NodeCollection : public QList<ANetNodeInstance> { |
467 | 509 | ||
468 | public : | 510 | public : |
469 | 511 | ||
470 | NodeCollection( void ); | 512 | NodeCollection( void ); |
471 | NodeCollection( QTextStream & TS ); | 513 | NodeCollection( QTextStream & TS, bool & Dangling ); |
472 | ~NodeCollection( void ); | 514 | ~NodeCollection( void ); |
473 | 515 | ||
474 | inline int done( void ) | 516 | inline int done( void ) |
475 | { return Done; } | 517 | { return Done; } |
476 | inline void setDone( int D ) | 518 | inline void setDone( int D ) |
477 | { Done = D; } | 519 | { Done = D; } |
478 | 520 | ||
479 | inline int number( void ) | 521 | inline int number( void ) |
480 | { return Number; } | 522 | { return Number; } |
481 | inline void setNumber( int i ) | 523 | inline void setNumber( int i ) |
482 | { Number = i; } | 524 | { Number = i; } |
483 | inline bool isNew( void ) | 525 | inline bool isNew( void ) |
@@ -576,21 +618,21 @@ private : | |||
576 | QCollection::Item item2 ); | 618 | QCollection::Item item2 ); |
577 | 619 | ||
578 | long Number; | 620 | long Number; |
579 | 621 | ||
580 | // state of this connection | 622 | // state of this connection |
581 | State_t CurrentState; | 623 | State_t CurrentState; |
582 | 624 | ||
583 | QString Name; | 625 | QString Name; |
584 | // true if this collection was just created (and not | 626 | // true if this collection was just created (and not |
585 | // loaded from file | 627 | // loaded from file |
586 | bool IsNew; | 628 | bool IsNew; |
587 | // index in listbox | 629 | // index in listbox |
588 | int Index; | 630 | int Index; |
589 | bool IsModified; | 631 | bool IsModified; |
590 | int Done; | 632 | int Done; |
591 | 633 | ||
592 | InterfaceInfo * AssignedInterface; | 634 | InterfaceInfo * AssignedInterface; |
593 | 635 | ||
594 | }; | 636 | }; |
595 | 637 | ||
596 | #endif | 638 | #endif |
diff --git a/noncore/settings/networksettings2/networksettings2/netnodeinterface.h b/noncore/settings/networksettings2/networksettings2/netnodeinterface.h index 34f3bb5..06d1548 100644 --- a/noncore/settings/networksettings2/networksettings2/netnodeinterface.h +++ b/noncore/settings/networksettings2/networksettings2/netnodeinterface.h | |||
@@ -69,26 +69,36 @@ struct NS2PrivateFactory<Opie::Core::NullType> { | |||
69 | }; | 69 | }; |
70 | 70 | ||
71 | template <class Node, class Tail> | 71 | template <class Node, class Tail> |
72 | struct NS2PrivateFactory<Opie::Core::Typelist<Node, Tail> > { | 72 | struct NS2PrivateFactory<Opie::Core::Typelist<Node, Tail> > { |
73 | 73 | ||
74 | inline static void createPlugins( QList<ANetNode> & PNN ) { | 74 | inline static void createPlugins( QList<ANetNode> & PNN ) { |
75 | NS2PrivateFactory<Node>::createPlugins(PNN); | 75 | NS2PrivateFactory<Node>::createPlugins(PNN); |
76 | NS2PrivateFactory<Tail>::createPlugins(PNN); | 76 | NS2PrivateFactory<Tail>::createPlugins(PNN); |
77 | } | 77 | } |
78 | 78 | ||
79 | }; | 79 | }; |
80 | 80 | ||
81 | class NetNodeInterface : public QUnknownInterface { | ||
82 | |||
83 | public : | ||
84 | |||
85 | virtual QRESULT queryInterface( const QUuid& uuid, | ||
86 | QUnknownInterface **iface ) = 0; | ||
87 | |||
88 | virtual void create_plugin( QList<ANetNode> & PNN ) = 0; | ||
89 | }; | ||
90 | |||
81 | template<class Node> | 91 | template<class Node> |
82 | struct NetNodeInterface : public QUnknownInterface { | 92 | struct NetNodeInterface_T : public NetNodeInterface { |
83 | 93 | ||
84 | QRESULT queryInterface(const QUuid& uuid, QUnknownInterface **iface) { | 94 | QRESULT queryInterface(const QUuid& uuid, QUnknownInterface **iface) { |
85 | *iface = 0; | 95 | *iface = 0; |
86 | 96 | ||
87 | if( uuid == IID_QUnknown ) | 97 | if( uuid == IID_QUnknown ) |
88 | *iface = this; | 98 | *iface = this; |
89 | else if( uuid == IID_NetworkSettings2 ) | 99 | else if( uuid == IID_NetworkSettings2 ) |
90 | *iface = this; | 100 | *iface = this; |
91 | else | 101 | else |
92 | return QS_FALSE; | 102 | return QS_FALSE; |
93 | 103 | ||
94 | (*iface)->addRef(); | 104 | (*iface)->addRef(); |
@@ -98,42 +108,42 @@ struct NetNodeInterface : public QUnknownInterface { | |||
98 | } | 108 | } |
99 | 109 | ||
100 | void create_plugin( QList<ANetNode> & PNN ) { | 110 | void create_plugin( QList<ANetNode> & PNN ) { |
101 | 111 | ||
102 | PNN.append( new Node()); | 112 | PNN.append( new Node()); |
103 | 113 | ||
104 | } | 114 | } |
105 | 115 | ||
106 | Q_REFCOUNT | 116 | Q_REFCOUNT |
107 | }; | 117 | }; |
108 | 118 | ||
109 | template<class Node, class Tail> | 119 | template<class Node, class Tail> |
110 | struct NetNodeInterface<Opie::Core::Typelist<Node, Tail> > | 120 | struct NetNodeInterface_T<Opie::Core::Typelist<Node, Tail> > |
111 | : public QUnknownInterface { | 121 | : public NetNodeInterface { |
112 | 122 | ||
113 | QRESULT queryInterface( const QUuid& uuid, | 123 | QRESULT queryInterface( const QUuid& uuid, |
114 | QUnknownInterface **iface) { | 124 | QUnknownInterface **iface) { |
115 | 125 | ||
116 | *iface = 0; | 126 | *iface = 0; |
117 | 127 | ||
118 | if( uuid == IID_QUnknown ) *iface = this; | 128 | if( uuid == IID_QUnknown ) *iface = this; |
119 | else if( uuid == IID_NetworkSettings2 ) *iface = this; | 129 | else if( uuid == IID_NetworkSettings2 ) *iface = this; |
120 | else return QS_FALSE; | 130 | else return QS_FALSE; |
121 | 131 | ||
122 | (*iface)->addRef(); | 132 | (*iface)->addRef(); |
123 | return QS_OK; | 133 | return QS_OK; |
124 | 134 | ||
125 | } | 135 | } |
126 | 136 | ||
127 | void create_plugin( QList<ANetNode> & PNN ) { | 137 | void create_plugin( QList<ANetNode> & PNN ) { |
128 | NS2PrivateFactory<Opie::Core::Typelist<Node,Tail> >::createPlugin( PNN ); | 138 | NS2PrivateFactory<Opie::Core::Typelist<Node,Tail> >::createPlugins( PNN ); |
129 | } | 139 | } |
130 | 140 | ||
131 | Q_REFCOUNT | 141 | Q_REFCOUNT |
132 | 142 | ||
133 | }; | 143 | }; |
134 | 144 | ||
135 | #define OPIE_NS2_PLUGIN( factory ) \ | 145 | #define OPIE_NS2_PLUGIN( factory ) \ |
136 | Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( factory) } | 146 | Q_EXPORT_INTERFACE() { Q_CREATE_INSTANCE( factory) } |
137 | 147 | ||
138 | #endif | 148 | #endif |
139 | 149 | ||
diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp index 79d41ea..3479abb 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.cpp +++ b/noncore/settings/networksettings2/networksettings2/resources.cpp | |||
@@ -16,76 +16,32 @@ | |||
16 | 16 | ||
17 | #include "netnode.h" | 17 | #include "netnode.h" |
18 | #include "resources.h" | 18 | #include "resources.h" |
19 | #include "netnodeinterface.h" | 19 | #include "netnodeinterface.h" |
20 | 20 | ||
21 | #define PLUGINDIR "plugins/networksettings2" | 21 | #define PLUGINDIR "plugins/networksettings2" |
22 | #define ICONDIR "/pics/networksettings2/" | 22 | #define ICONDIR "/pics/networksettings2/" |
23 | 23 | ||
24 | // single resources instance | 24 | // single resources instance |
25 | TheNSResources * _NSResources = 0; | 25 | TheNSResources * _NSResources = 0; |
26 | 26 | ||
27 | TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), | 27 | TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), |
28 | ConnectionsMap() { | 28 | ConnectionsMap(), DanglingConnectionsMap() { |
29 | 29 | ||
30 | _NSResources = this; | 30 | _NSResources = this; |
31 | 31 | ||
32 | detectCurrentUser(); | 32 | detectCurrentUser(); |
33 | 33 | ||
34 | // load available netnodes | 34 | // load available netnodes |
35 | 35 | ||
36 | #ifdef MYPLUGIN | ||
37 | |||
38 | findAvailableNetNodes(QPEApplication::qpeDir() + PLUGINDIR ); | ||
39 | |||
40 | // compile provides and needs lists | ||
41 | { const char ** NeedsRun; | ||
42 | QDictIterator<NetNode_t> OuterIt( AllNodeTypes ); | ||
43 | bool Done; | ||
44 | |||
45 | for ( ; OuterIt.current(); ++OuterIt ) { | ||
46 | // find needs list | ||
47 | ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList; | ||
48 | ANetNode::NetNodeList & NNL = *(NNLP); | ||
49 | |||
50 | // must iterate this way to avoid duplication pointers | ||
51 | for ( QDictIterator<NetNode_t> InnerIt( AllNodeTypes ); | ||
52 | InnerIt.current(); ++InnerIt ) { | ||
53 | if( InnerIt.current() == OuterIt.current() ) | ||
54 | // avoid recursive | ||
55 | continue; | ||
56 | |||
57 | const char ** Provides = InnerIt.current()->NetNode->provides(); | ||
58 | NeedsRun = OuterIt.current()->NetNode->needs(); | ||
59 | |||
60 | for( ; *NeedsRun; NeedsRun ++ ) { | ||
61 | const char ** PRun; | ||
62 | PRun = Provides; | ||
63 | for( ; *PRun; PRun ++ ) { | ||
64 | if( strcmp( *PRun, *NeedsRun ) == 0 ) { | ||
65 | // inner provides what outer needs | ||
66 | NNL.resize( NNL.size() + 1 ); | ||
67 | NNL[NNL.size()-1] = InnerIt.current()->NetNode; | ||
68 | Done = 1; // break from 2 loops | ||
69 | break; | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | OuterIt.current()->NetNode->setAlternatives( NNLP ); | ||
75 | } | ||
76 | } | ||
77 | |||
78 | #else | ||
79 | |||
80 | Plugins = 0; | 36 | Plugins = 0; |
81 | findAvailableNetNodes(); | 37 | findAvailableNetNodes(); |
82 | 38 | ||
83 | // compile provides and needs lists | 39 | // compile provides and needs lists |
84 | { const char ** NeedsRun; | 40 | { const char ** NeedsRun; |
85 | QDictIterator<ANetNode> OuterIt( AllNodeTypes ); | 41 | QDictIterator<ANetNode> OuterIt( AllNodeTypes ); |
86 | bool Done; | 42 | bool Done; |
87 | 43 | ||
88 | for ( ; OuterIt.current(); ++OuterIt ) { | 44 | for ( ; OuterIt.current(); ++OuterIt ) { |
89 | // find needs list | 45 | // find needs list |
90 | ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList; | 46 | ANetNode::NetNodeList * NNLP = new ANetNode::NetNodeList; |
91 | ANetNode::NetNodeList & NNL = *(NNLP); | 47 | ANetNode::NetNodeList & NNL = *(NNLP); |
@@ -110,51 +66,47 @@ TheNSResources::TheNSResources( void ) : NodeTypeNameMap(), | |||
110 | NNL.resize( NNL.size() + 1 ); | 66 | NNL.resize( NNL.size() + 1 ); |
111 | NNL[NNL.size()-1] = InnerIt.current(); | 67 | NNL[NNL.size()-1] = InnerIt.current(); |
112 | Done = 1; // break from 2 loops | 68 | Done = 1; // break from 2 loops |
113 | break; | 69 | break; |
114 | } | 70 | } |
115 | } | 71 | } |
116 | } | 72 | } |
117 | } | 73 | } |
118 | OuterIt.current()->setAlternatives( NNLP ); | 74 | OuterIt.current()->setAlternatives( NNLP ); |
119 | } | 75 | } |
120 | } | 76 | } |
121 | 77 | ||
122 | #endif | ||
123 | |||
124 | // define built in Node types to Description map | 78 | // define built in Node types to Description map |
125 | addNodeType( "device", tr( "Network Device" ), | 79 | addNodeType( "device", tr( "Network Device" ), |
126 | tr( "<p>Devices that can handle IP packets</p>" ) ); | 80 | tr( "<p>Devices that can handle IP packets</p>" ) ); |
127 | addNodeType( "line", tr( "Character device" ), | 81 | addNodeType( "line", tr( "Character device" ), |
128 | tr( "<p>Devices that can handle single bytes</p>" ) ); | 82 | tr( "<p>Devices that can handle single bytes</p>" ) ); |
129 | addNodeType( "connection", tr( "IP Connection" ), | 83 | addNodeType( "connection", tr( "IP Connection" ), |
130 | tr( "<p>Nodes that provide working IP connections</p>" ) ); | 84 | tr( "<p>Nodes that provide working IP connections</p>" ) ); |
131 | addNodeType( "fullsetup", tr( "Connection Profile" ), | 85 | addNodeType( "fullsetup", tr( "Connection Profile" ), |
132 | tr( "<p>Fully configured connection profile</p>" ) ); | 86 | tr( "<p>Fully configured connection profile</p>" ) ); |
133 | addNodeType( "GPRS", tr( "Connection to GPRS device" ), | 87 | addNodeType( "GPRS", tr( "Connection to GPRS device" ), |
134 | tr( "<p>Connection to a GPRS capable device</p>" ) ); | 88 | tr( "<p>Connection to a GPRS capable device</p>" ) ); |
135 | 89 | ||
136 | // get access to the system | 90 | // get access to the system |
137 | TheSystem = new System(); | 91 | TheSystem = new System(); |
138 | 92 | ||
139 | } | 93 | } |
140 | 94 | ||
141 | TheNSResources::~TheNSResources( void ) { | 95 | TheNSResources::~TheNSResources( void ) { |
142 | 96 | ||
143 | #ifndef MYPLUGINS | ||
144 | if( Plugins ) { | 97 | if( Plugins ) { |
145 | delete Plugins; | 98 | delete Plugins; |
146 | delete PluginManager; | 99 | delete PluginManager; |
147 | } | 100 | } |
148 | #endif | ||
149 | delete TheSystem; | 101 | delete TheSystem; |
150 | 102 | ||
151 | } | 103 | } |
152 | 104 | ||
153 | void TheNSResources::addNodeType( const QString & ID, | 105 | void TheNSResources::addNodeType( const QString & ID, |
154 | const QString & Name, | 106 | const QString & Name, |
155 | const QString & Descr ) { | 107 | const QString & Descr ) { |
156 | if( NodeTypeNameMap[ID].isEmpty() ) { | 108 | if( NodeTypeNameMap[ID].isEmpty() ) { |
157 | NodeTypeNameMap.insert( ID, Name ); | 109 | NodeTypeNameMap.insert( ID, Name ); |
158 | NodeTypeDescriptionMap.insert( ID, Descr ); | 110 | NodeTypeDescriptionMap.insert( ID, Descr ); |
159 | } | 111 | } |
160 | } | 112 | } |
@@ -170,188 +122,94 @@ void TheNSResources::addSystemFile( const QString & ID, | |||
170 | 122 | ||
171 | void TheNSResources::busy( bool ) { | 123 | void TheNSResources::busy( bool ) { |
172 | /* | 124 | /* |
173 | if( B ) { | 125 | if( B ) { |
174 | ShowWait->show(); | 126 | ShowWait->show(); |
175 | qApp->process | 127 | qApp->process |
176 | } else { | 128 | } else { |
177 | ShowWait->hide(); | 129 | ShowWait->hide(); |
178 | } | 130 | } |
179 | */ | 131 | */ |
180 | } | 132 | } |
181 | 133 | ||
182 | #ifdef MYPLUGIN | ||
183 | /** | ||
184 | * Load all modules that are found in the path | ||
185 | * @param path a directory that is scaned for any plugins that can be loaded | ||
186 | * and attempts to load them | ||
187 | */ | ||
188 | void TheNSResources::findAvailableNetNodes(const QString &path){ | ||
189 | |||
190 | Log(("Locate plugins in %s\n", path.latin1() )); | ||
191 | QDir d(path); | ||
192 | if(!d.exists()) | ||
193 | return; | ||
194 | |||
195 | QString lang = ::getenv("LANG"); | ||
196 | |||
197 | // Don't want sym links | ||
198 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | ||
199 | const QFileInfoList *list = d.entryInfoList(); | ||
200 | QFileInfoListIterator it( *list ); | ||
201 | QFileInfo *fi; | ||
202 | |||
203 | while ( (fi=it.current()) ) { | ||
204 | |||
205 | if( fi->fileName().contains(".so")){ | ||
206 | /* if loaded install translation */ | ||
207 | if( loadNetNode(path + "/" + fi->fileName()) ) { | ||
208 | Log(( "Loading plugin %s\n", fi->fileName().latin1())); | ||
209 | QTranslator *trans = new QTranslator(qApp); | ||
210 | QString fn = QPEApplication::qpeDir()+ | ||
211 | "/i18n/"+lang+"/"+ | ||
212 | fi->fileName().left( fi->fileName().find(".") )+ | ||
213 | ".qm"; | ||
214 | |||
215 | if( trans->load( fn ) ) | ||
216 | qApp->installTranslator( trans ); | ||
217 | else | ||
218 | delete trans; | ||
219 | } else { | ||
220 | Log(( "Error loading plugin %s\n", fi->fileName().latin1())); | ||
221 | } | ||
222 | } | ||
223 | ++it; | ||
224 | } | ||
225 | } | ||
226 | |||
227 | /** | ||
228 | * Attempt to load a function and resolve a function. | ||
229 | * @param pluginFileName - the name of the file in which to attempt to load | ||
230 | * @param resolveString - function pointer to resolve | ||
231 | * @return true of loading is successful | ||
232 | */ | ||
233 | bool TheNSResources::loadNetNode( | ||
234 | const QString &pluginFileName, const QString &resolveString){ | ||
235 | |||
236 | QLibrary *lib = new QLibrary(pluginFileName); | ||
237 | void * res = lib->resolve(resolveString); | ||
238 | if( ! res ){ | ||
239 | delete lib; | ||
240 | return 0; | ||
241 | } | ||
242 | |||
243 | GetNetNodeListFt_t getNetNodeList = (GetNetNodeListFt_t)res; | ||
244 | |||
245 | // Try to get an object. | ||
246 | QList<ANetNode> PNN; | ||
247 | |||
248 | getNetNodeList( PNN ); | ||
249 | if( PNN.isEmpty() ) { | ||
250 | delete lib; | ||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | ANetNode * NNP; | ||
255 | for( QListIterator<ANetNode> it(PNN); | ||
256 | it.current(); | ||
257 | ++it ) { | ||
258 | NetNode_t * NN; | ||
259 | |||
260 | NNP = it.current(); | ||
261 | NN = new NetNode_t; | ||
262 | NN->NetNode = NNP; | ||
263 | NN->TheLibrary = lib; | ||
264 | NN->NodeCountInLib = PNN.count(); | ||
265 | |||
266 | // store mapping | ||
267 | AllNodeTypes.insert( NN->NetNode->name(), NN ); | ||
268 | } | ||
269 | |||
270 | return 1; | ||
271 | } | ||
272 | |||
273 | #else | ||
274 | |||
275 | void TheNSResources::findAvailableNetNodes( void ){ | 134 | void TheNSResources::findAvailableNetNodes( void ){ |
276 | 135 | ||
277 | Plugins = new OPluginLoader( "networksettings2" ); | 136 | Plugins = new OPluginLoader( "networksettings2" ); |
278 | Plugins->setAutoDelete( true ); | 137 | Plugins->setAutoDelete( true ); |
279 | 138 | ||
280 | PluginManager = new OPluginManager( Plugins ); | 139 | PluginManager = new OPluginManager( Plugins ); |
281 | PluginManager->load(); | 140 | PluginManager->load(); |
282 | 141 | ||
283 | if( Plugins->isInSafeMode() ) { | 142 | if( Plugins->isInSafeMode() ) { |
284 | QMessageBox::information( | 143 | QMessageBox::information( |
285 | 0, | 144 | 0, |
286 | tr( "Today Error"), | 145 | tr( "Today Error"), |
287 | tr( "<qt>The plugin '%1' caused Today to crash." | 146 | tr( "<qt>The plugin '%1' caused Today to crash." |
288 | " It could be that the plugin is not properly" | 147 | " It could be that the plugin is not properly" |
289 | " installed.<br>Today tries to continue loading" | 148 | " installed.<br>Today tries to continue loading" |
290 | " plugins.</qt>" ) | 149 | " plugins.</qt>" ) |
291 | .arg( PluginManager->crashedPlugin().name())); | 150 | .arg( PluginManager->crashedPlugin().name())); |
292 | } | 151 | } |
293 | 152 | ||
294 | // Get All Plugins | 153 | // Get All Plugins |
295 | OPluginLoader::List allplugins = Plugins->filtered(); | 154 | OPluginLoader::List allplugins = Plugins->filtered(); |
155 | QString lang = ::getenv("LANG"); | ||
296 | 156 | ||
297 | for( OPluginLoader::List::Iterator it = allplugins.begin(); | 157 | for( OPluginLoader::List::Iterator it = allplugins.begin(); |
298 | it != allplugins.end(); | 158 | it != allplugins.end(); |
299 | ++it ) { | 159 | ++it ) { |
300 | 160 | ||
301 | // check if this plugin supports the proper interface | 161 | // check if this plugin supports the proper interface |
302 | NetNodeInterface * interface = | 162 | NetNodeInterface * interface = |
303 | Plugins->load<NetNodeInterface>( *it, IID_NetworkSettings2 ); | 163 | Plugins->load<NetNodeInterface>( *it, IID_NetworkSettings2 ); |
304 | 164 | ||
305 | if( ! interface ) { | 165 | if( ! interface ) { |
306 | Log(( "Plugin %s from %s does not support proper interface\n", | 166 | Log(( "Plugin %s from %s does not support proper interface\n", |
307 | it->name().latin1(), it->path().latin1() )); | 167 | (*it).name().latin1(), (*it).path().latin1() )); |
308 | continue; | 168 | continue; |
309 | } | 169 | } |
310 | 170 | ||
311 | // add the nodes in this plugin to the dictionary | 171 | // add the nodes in this plugin to the dictionary |
312 | { QList<ANetNode> PNN; | 172 | { QList<ANetNode> PNN; |
313 | 173 | ||
314 | interface->create_plugin( PNN ); | 174 | interface->create_plugin( PNN ); |
315 | 175 | ||
316 | if( PNN.isEmpty() ) { | 176 | if( PNN.isEmpty() ) { |
317 | Log(( "Plugin %s from %s does offer any nodes\n", | 177 | Log(( "Plugin %s from %s does offer any nodes\n", |
318 | it->name().latin1(), it->path().latin1() )); | 178 | (*it).name().latin1(), (*it).path().latin1() )); |
319 | delete interface; | 179 | delete interface; |
320 | continue; | 180 | continue; |
321 | } | 181 | } |
322 | 182 | ||
323 | // merge this node with global node | 183 | // merge this node with global node |
324 | for( QListIterator<ANetNode> it(PNN); | 184 | for( QListIterator<ANetNode> it(PNN); |
325 | it.current(); | 185 | it.current(); |
326 | ++it ) { | 186 | ++it ) { |
327 | AllNodeTypes.insert( it->current()->name(), it->current() ); | 187 | AllNodeTypes.insert( it.current()->name(), it.current() ); |
328 | } | 188 | } |
329 | } | 189 | } |
330 | 190 | ||
331 | // load the translation | 191 | // load the translation |
332 | QTranslator *trans = new QTranslator(qApp); | 192 | QTranslator *trans = new QTranslator(qApp); |
333 | QString fn = QPEApplication::qpeDir()+ | 193 | QString fn = QPEApplication::qpeDir()+ |
334 | "/i18n/"+lang+"/"+ it->name() + ".qm"; | 194 | "/i18n/"+lang+"/"+ (*it).name() + ".qm"; |
335 | 195 | ||
336 | if( trans->load( fn ) ) | 196 | if( trans->load( fn ) ) |
337 | qApp->installTranslator( trans ); | 197 | qApp->installTranslator( trans ); |
338 | else | 198 | else |
339 | delete trans; | 199 | delete trans; |
340 | } | 200 | } |
341 | 201 | ||
342 | } | 202 | } |
343 | 203 | ||
344 | #endif | ||
345 | |||
346 | // used to find unique connection number | 204 | // used to find unique connection number |
347 | int TheNSResources::assignConnectionNumber( void ) { | 205 | int TheNSResources::assignConnectionNumber( void ) { |
348 | bool found = 1; | 206 | bool found = 1; |
349 | for( int trial = 0; ; trial ++ ) { | 207 | for( int trial = 0; ; trial ++ ) { |
350 | found = 1; | 208 | found = 1; |
351 | for( QDictIterator<NodeCollection> it(ConnectionsMap); | 209 | for( QDictIterator<NodeCollection> it(ConnectionsMap); |
352 | it.current(); | 210 | it.current(); |
353 | ++it ) { | 211 | ++it ) { |
354 | if( it.current()->number() == trial ) { | 212 | if( it.current()->number() == trial ) { |
355 | found = 0; | 213 | found = 0; |
356 | break; | 214 | break; |
357 | } | 215 | } |
@@ -378,52 +236,63 @@ QPixmap TheNSResources::getPixmap( const QString & QS ) { | |||
378 | QString TheNSResources::tr( const char * s ) { | 236 | QString TheNSResources::tr( const char * s ) { |
379 | return qApp->translate( "resource", s ); | 237 | return qApp->translate( "resource", s ); |
380 | } | 238 | } |
381 | 239 | ||
382 | const QString & TheNSResources::netNode2Name( const char * s ) { | 240 | const QString & TheNSResources::netNode2Name( const char * s ) { |
383 | return NodeTypeNameMap[s]; | 241 | return NodeTypeNameMap[s]; |
384 | } | 242 | } |
385 | 243 | ||
386 | const QString & TheNSResources::netNode2Description( const char * s ) { | 244 | const QString & TheNSResources::netNode2Description( const char * s ) { |
387 | return NodeTypeDescriptionMap[s]; | 245 | return NodeTypeDescriptionMap[s]; |
388 | } | 246 | } |
389 | 247 | ||
390 | void TheNSResources::addConnection( NodeCollection * NC ) { | 248 | void TheNSResources::addConnection( NodeCollection * NC, bool Dangling ) { |
391 | ANetNodeInstance * NNI; | 249 | ANetNodeInstance * NNI; |
392 | ConnectionsMap.insert( NC->name(), NC ); | 250 | if( Dangling ) { |
251 | DanglingConnectionsMap.insert( NC->name(), NC ); | ||
252 | } else { | ||
253 | ConnectionsMap.insert( NC->name(), NC ); | ||
254 | } | ||
255 | |||
393 | // add (new) nodes to NodeList | 256 | // add (new) nodes to NodeList |
394 | for( QListIterator<ANetNodeInstance> it(*NC); | 257 | for( QListIterator<ANetNodeInstance> it(*NC); |
395 | it.current(); | 258 | it.current(); |
396 | ++it ) { | 259 | ++it ) { |
397 | NNI = it.current(); | 260 | NNI = it.current(); |
398 | if( findNodeInstance( NNI->name() ) == 0 ) { | 261 | if( findNodeInstance( NNI->name() ) == 0 ) { |
399 | // new item | 262 | // new item |
400 | addNodeInstance( NNI ); | 263 | addNodeInstance( NNI ); |
401 | } | 264 | } |
402 | } | 265 | } |
403 | } | 266 | } |
404 | 267 | ||
405 | void TheNSResources::removeConnection( const QString & N ) { | 268 | void TheNSResources::removeConnection( const QString & N ) { |
406 | NodeCollection * NC = findConnection( N ); | 269 | NodeCollection * NC = findConnection( N ); |
407 | if( ! NC ) | 270 | if( ! NC ) |
408 | return; | 271 | return; |
409 | 272 | ||
410 | // delete netnodes in this connection | 273 | // delete netnodes in this connection |
411 | ANetNodeInstance * NNI; | 274 | ANetNodeInstance * NNI; |
412 | for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) { | 275 | for( NNI = NC->first(); NNI != 0; NNI = NC->next() ) { |
413 | removeNodeInstance( NNI->name() ); | 276 | removeNodeInstance( NNI->name() ); |
414 | } | 277 | } |
415 | ConnectionsMap.remove( N ); | 278 | if( ConnectionsMap.find( N ) ) { |
279 | ConnectionsMap.remove( N ); | ||
280 | } else { | ||
281 | DanglingConnectionsMap.remove( N ); | ||
282 | } | ||
283 | |||
416 | } | 284 | } |
417 | 285 | ||
286 | // dangling connections are filtered out | ||
418 | NodeCollection * TheNSResources::findConnection( const QString & S ) { | 287 | NodeCollection * TheNSResources::findConnection( const QString & S ) { |
419 | return ConnectionsMap[ S ]; | 288 | return ConnectionsMap[ S ]; |
420 | } | 289 | } |
421 | 290 | ||
422 | NodeCollection * TheNSResources::getConnection( int nr ) { | 291 | NodeCollection * TheNSResources::getConnection( int nr ) { |
423 | for( QDictIterator<NodeCollection> it(ConnectionsMap); | 292 | for( QDictIterator<NodeCollection> it(ConnectionsMap); |
424 | it.current(); | 293 | it.current(); |
425 | ++it ) { | 294 | ++it ) { |
426 | if( it.current()->number() == nr ) { | 295 | if( it.current()->number() == nr ) { |
427 | return it.current(); | 296 | return it.current(); |
428 | } | 297 | } |
429 | } | 298 | } |
diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h index 421a433..b27cda1 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.h +++ b/noncore/settings/networksettings2/networksettings2/resources.h | |||
@@ -29,155 +29,125 @@ public : | |||
29 | CurrentQPEUser() : UserName(), HomeDir(), EnvList() {} | 29 | CurrentQPEUser() : UserName(), HomeDir(), EnvList() {} |
30 | 30 | ||
31 | inline bool known( void ) | 31 | inline bool known( void ) |
32 | { return ! HomeDir.isEmpty() && ! UserName.isEmpty(); } | 32 | { return ! HomeDir.isEmpty() && ! UserName.isEmpty(); } |
33 | 33 | ||
34 | QString UserName; | 34 | QString UserName; |
35 | QString HomeDir; | 35 | QString HomeDir; |
36 | int Uid; | 36 | int Uid; |
37 | int Gid; | 37 | int Gid; |
38 | QArray<char *> EnvList; | 38 | QArray<char *> EnvList; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | #ifdef MYPLUGIN | ||
42 | |||
43 | typedef struct NetNode_S { | ||
44 | ANetNode * NetNode; | ||
45 | QLibrary * TheLibrary; | ||
46 | long NodeCountInLib; | ||
47 | } NetNode_t; | ||
48 | typedef QDict<NetNode_t> Name2NetNode_t; | ||
49 | |||
50 | #else | ||
51 | |||
52 | typedef QDict<ANetNode> Name2NetNode_t; | 41 | typedef QDict<ANetNode> Name2NetNode_t; |
53 | |||
54 | #endif | ||
55 | |||
56 | typedef QDict<ANetNodeInstance > Name2Instance_t; | 42 | typedef QDict<ANetNodeInstance > Name2Instance_t; |
57 | typedef QDict<NodeCollection> Name2Connection_t; | 43 | typedef QDict<NodeCollection> Name2Connection_t; |
58 | typedef QDict<SystemFile> Name2SystemFile_t; | 44 | typedef QDict<SystemFile> Name2SystemFile_t; |
59 | 45 | ||
60 | class TheNSResources { | 46 | class TheNSResources { |
61 | 47 | ||
62 | public : | 48 | public : |
63 | 49 | ||
64 | TheNSResources( void ); | 50 | TheNSResources( void ); |
65 | ~TheNSResources( ); | 51 | ~TheNSResources( ); |
66 | 52 | ||
67 | // give busy feedback | 53 | // give busy feedback |
68 | void busy( bool B ); | 54 | void busy( bool B ); |
69 | 55 | ||
70 | System & system() | 56 | System & system() |
71 | { return *TheSystem; } | 57 | { return *TheSystem; } |
72 | 58 | ||
73 | int assignConnectionNumber(void); | 59 | int assignConnectionNumber(void); |
74 | QPixmap getPixmap( const QString & Name ); | 60 | QPixmap getPixmap( const QString & Name ); |
75 | 61 | ||
76 | Name2NetNode_t & netNodes( void ) | 62 | Name2NetNode_t & netNodes( void ) |
77 | { return AllNodeTypes; } | 63 | { return AllNodeTypes; } |
78 | bool netNodeExists( const QString & X ) | 64 | bool netNodeExists( const QString & X ) |
79 | { return AllNodeTypes.find(X)!=0; } | 65 | { return AllNodeTypes.find(X)!=0; } |
80 | #ifdef MYPLUGIN | ||
81 | ANetNode * findNetNode( const QString & N ) | ||
82 | { NetNode_t * NNT = AllNodeTypes.find(N); | ||
83 | return (NNT) ? NNT->NetNode : 0; | ||
84 | } | ||
85 | #else | ||
86 | ANetNode * findNetNode( const QString & N ) | 66 | ANetNode * findNetNode( const QString & N ) |
87 | { return AllNodeTypes.find(N); | 67 | { return AllNodeTypes.find(N); |
88 | } | 68 | } |
89 | #endif | ||
90 | // define new plugin (=node) | 69 | // define new plugin (=node) |
91 | void addNodeType( const QString & ID, | 70 | void addNodeType( const QString & ID, |
92 | const QString & LongName, | 71 | const QString & LongName, |
93 | const QString & Description ); | 72 | const QString & Description ); |
94 | 73 | ||
95 | Name2SystemFile_t & systemFiles( void ) | 74 | Name2SystemFile_t & systemFiles( void ) |
96 | { return SystemFiles; } | 75 | { return SystemFiles; } |
97 | void addSystemFile( const QString & ID, | 76 | void addSystemFile( const QString & ID, |
98 | const QString & P, | 77 | const QString & P, |
99 | bool KDI ); | 78 | bool KDI ); |
100 | 79 | ||
101 | ANetNodeInstance * createNodeInstance( const QString & S ) | 80 | ANetNodeInstance * createNodeInstance( const QString & S ) |
102 | { ANetNodeInstance * NNI = 0; | 81 | { ANetNode * NN = findNetNode( S ); |
103 | printf( "Find node type %s\n", S.latin1() ); | 82 | |
104 | #ifdef MYPLUGIN | 83 | Log(( "Find node type %s : %p\n", S.latin1(), NN )); |
105 | NetNode_t * NNT = AllNodeTypes[S]; | 84 | |
106 | if( ! NNT ) { | 85 | if( NN == 0 ) |
107 | return 0; | 86 | // type of this instance not found |
108 | } | ||
109 | NNI = NNT->NetNode->createInstance(); | ||
110 | #else | ||
111 | ANetNode * NNT = AllNodeTypes[S]; | ||
112 | if( ! NNT ) { | ||
113 | return 0; | 87 | return 0; |
114 | } | 88 | |
115 | NNI = NNT->createInstance(); | 89 | ANetNodeInstance * NNI = NN->createInstance(); |
116 | #endif | ||
117 | NNI->initialize(); | 90 | NNI->initialize(); |
118 | return NNI; | 91 | return NNI; |
119 | } | 92 | } |
120 | 93 | ||
121 | Name2Instance_t & netNodeInstances( void ) | 94 | Name2Instance_t & netNodeInstances( void ) |
122 | { return AllNodes; } | 95 | { return AllNodes; } |
123 | void addNodeInstance( ANetNodeInstance * I ) | 96 | void addNodeInstance( ANetNodeInstance * I ) |
124 | { AllNodes.insert( I->name(), I ); } | 97 | { AllNodes.insert( I->name(), I ); } |
125 | void removeNodeInstance( const QString & N ) | 98 | void removeNodeInstance( const QString & N ) |
126 | { AllNodes.remove( N );} | 99 | { AllNodes.remove( N );} |
127 | ANetNodeInstance * findNodeInstance( const QString & S ) | 100 | ANetNodeInstance * findNodeInstance( const QString & S ) |
128 | { return AllNodes[S]; } | 101 | { return AllNodes[S]; } |
129 | 102 | ||
130 | const QString & netNode2Name( const char * Type ); | 103 | const QString & netNode2Name( const char * Type ); |
131 | const QString & netNode2Description( const char * Type ); | 104 | const QString & netNode2Description( const char * Type ); |
132 | 105 | ||
133 | void addConnection( NodeCollection * NC ); | 106 | void addConnection( NodeCollection * NC, bool Dangling ); |
134 | void removeConnection( const QString & N ); | 107 | void removeConnection( const QString & N ); |
135 | NodeCollection * findConnection( const QString & N ); | 108 | NodeCollection * findConnection( const QString & N ); |
136 | NodeCollection * getConnection( int nr ); | 109 | NodeCollection * getConnection( int nr ); |
137 | Name2Connection_t & connections( void ) | 110 | Name2Connection_t & connections( void ) |
138 | { return ConnectionsMap; } | 111 | { return ConnectionsMap; } |
112 | Name2Connection_t & danglingConnections( void ) | ||
113 | { return ConnectionsMap; } | ||
139 | 114 | ||
140 | inline bool userKnown( void ) | 115 | inline bool userKnown( void ) |
141 | { return CurrentUser.known(); } | 116 | { return CurrentUser.known(); } |
142 | CurrentQPEUser & currentUser( void ) | 117 | CurrentQPEUser & currentUser( void ) |
143 | { return CurrentUser; } | 118 | { return CurrentUser; } |
144 | 119 | ||
145 | private : | 120 | private : |
146 | 121 | ||
147 | void detectCurrentUser( void ); | 122 | void detectCurrentUser( void ); |
148 | QString tr( const char * path ); | 123 | QString tr( const char * path ); |
149 | 124 | ||
150 | #ifdef MYPLUGIN | ||
151 | void findAvailableNetNodes( const QString &path ); | ||
152 | bool loadNetNode( | ||
153 | const QString &pluginFileName, | ||
154 | const QString &resolveString = "create_plugin"); | ||
155 | #else | ||
156 | void findAvailableNetNodes( void ); | 125 | void findAvailableNetNodes( void ); |
157 | #endif | ||
158 | 126 | ||
159 | QMap< QString, QString> NodeTypeNameMap; | 127 | QMap< QString, QString> NodeTypeNameMap; |
160 | QMap< QString, QString> NodeTypeDescriptionMap; | 128 | QMap< QString, QString> NodeTypeDescriptionMap; |
129 | // list of connections that are valid | ||
161 | Name2Connection_t ConnectionsMap; | 130 | Name2Connection_t ConnectionsMap; |
131 | // list of connection configurations that are not valid | ||
132 | // e.g. because plugins are missing | ||
133 | Name2Connection_t DanglingConnectionsMap; | ||
162 | System * TheSystem; | 134 | System * TheSystem; |
163 | Name2SystemFile_t SystemFiles; | 135 | Name2SystemFile_t SystemFiles; |
164 | 136 | ||
165 | // all node type classes | 137 | // all node type classes |
166 | Name2NetNode_t AllNodeTypes; | 138 | Name2NetNode_t AllNodeTypes; |
167 | 139 | ||
168 | // all nodes | 140 | // all nodes |
169 | Name2Instance_t AllNodes; | 141 | Name2Instance_t AllNodes; |
170 | 142 | ||
171 | CurrentQPEUser CurrentUser; | 143 | CurrentQPEUser CurrentUser; |
172 | 144 | ||
173 | #ifndef MYPLUGIN | ||
174 | Opie::Core::OPluginLoader * Plugins; | 145 | Opie::Core::OPluginLoader * Plugins; |
175 | Opie::Core::OPluginManager * PluginManager; | 146 | Opie::Core::OPluginManager * PluginManager; |
176 | #endif | ||
177 | 147 | ||
178 | }; | 148 | }; |
179 | 149 | ||
180 | extern TheNSResources * _NSResources; | 150 | extern TheNSResources * _NSResources; |
181 | #define NSResources _NSResources | 151 | #define NSResources _NSResources |
182 | 152 | ||
183 | #endif | 153 | #endif |
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index 698a941..d76353a 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp | |||
@@ -107,89 +107,91 @@ void NetworkSettingsData::loadSettings( void ) { | |||
107 | 107 | ||
108 | if ( S.isEmpty() || S[0] != '[' ) | 108 | if ( S.isEmpty() || S[0] != '[' ) |
109 | continue; | 109 | continue; |
110 | 110 | ||
111 | S = S.mid( 1, S.length()-2 ); | 111 | S = S.mid( 1, S.length()-2 ); |
112 | 112 | ||
113 | if( ! NSResources ) { | 113 | if( ! NSResources ) { |
114 | continue; | 114 | continue; |
115 | } | 115 | } |
116 | 116 | ||
117 | if( S == "connection" ) { | 117 | if( S == "connection" ) { |
118 | // load connections -> collections of nodes | 118 | // load connections -> collections of nodes |
119 | NodeCollection * NC = new NodeCollection( TS ); | 119 | bool Dangling; |
120 | NSResources->addConnection( NC ); | 120 | NodeCollection * NC = new NodeCollection( TS, Dangling ); |
121 | NSResources->addConnection( NC, Dangling ); | ||
121 | } else { | 122 | } else { |
122 | ANetNode * NN = 0; | 123 | ANetNode * NN = 0; |
123 | ANetNodeInstance* NNI = 0; | 124 | ANetNodeInstance* NNI = 0; |
124 | if( S.startsWith( "nodetype " ) ) { | 125 | if( S.startsWith( "nodetype " ) ) { |
125 | S = S.mid( 9, S.length()-9 ); | 126 | S = S.mid( 9, S.length()-9 ); |
126 | S = deQuote(S); | 127 | S = deQuote(S); |
127 | // try to find netnode | 128 | // try to find netnode |
128 | NN = NSResources->findNetNode( S ); | 129 | NN = NSResources->findNetNode( S ); |
129 | } else { | 130 | } else { |
130 | // try to find instance | 131 | // try to find instance |
131 | NNI = NSResources->createNodeInstance( S ); | 132 | NNI = NSResources->createNodeInstance( S ); |
132 | } | 133 | } |
133 | 134 | ||
134 | if( NN == 0 && NNI == 0 ) { | 135 | if( NN == 0 && NNI == 0 ) { |
135 | LeftOvers.append( Line ); | 136 | LeftOvers.append( Line ); |
136 | } | 137 | do { |
138 | Line = TS.readLine(); | ||
139 | // store even delimiter | ||
140 | LeftOvers.append( Line ); | ||
141 | } while ( ! Line.isEmpty() ); | ||
142 | |||
143 | //next section | ||
144 | continue; | ||
145 | } | ||
137 | 146 | ||
147 | // read entries of this section | ||
138 | do { | 148 | do { |
139 | S = Line = TS.readLine(); | 149 | S = Line = TS.readLine(); |
140 | 150 | ||
141 | if( NN || NNI ) { | 151 | if( S.isEmpty() ) { |
142 | if( S.isEmpty() ) { | 152 | // empty line |
143 | // empty line | 153 | break; |
144 | break; | 154 | } |
145 | } | 155 | idx = S.find( '=' ); |
146 | idx = S.find( '=' ); | 156 | if( idx > 0 ) { |
147 | if( idx > 0 ) { | 157 | Attr = S.left( idx ); |
148 | Attr = S.left( idx ); | 158 | Value = S.mid( idx+1, S.length() ); |
149 | Value = S.mid( idx+1, S.length() ); | 159 | } else { |
150 | } else { | 160 | Value=""; |
151 | Value=""; | 161 | Attr = S; |
152 | Attr = S; | 162 | } |
153 | } | ||
154 | 163 | ||
155 | Value.stripWhiteSpace(); | 164 | Value.stripWhiteSpace(); |
156 | Attr.stripWhiteSpace(); | 165 | Attr.stripWhiteSpace(); |
157 | Attr.lower(); | 166 | Attr.lower(); |
158 | // dequote Attr | 167 | // dequote Attr |
159 | Value = deQuote(Value); | 168 | Value = deQuote(Value); |
160 | 169 | ||
161 | if( NN ) { | 170 | if( NN ) { |
162 | // set the attribute | 171 | // set the attribute |
163 | NN->setAttribute( Attr, Value ); | 172 | NN->setAttribute( Attr, Value ); |
164 | } else { | ||
165 | // set the attribute | ||
166 | NNI->setAttribute( Attr, Value ); | ||
167 | } | ||
168 | } else { | 173 | } else { |
169 | LeftOvers.append( Line ); | 174 | // set the attribute |
170 | // add empty line too as delimiter | 175 | NNI->setAttribute( Attr, Value ); |
171 | if( S.isEmpty() ) { | ||
172 | // empty line | ||
173 | break; | ||
174 | } | ||
175 | } | 176 | } |
176 | } while( 1 ); | 177 | } while( 1 ); |
177 | 178 | ||
178 | if( NNI ) { | 179 | if( NNI ) { |
179 | // loading from file -> exists | 180 | // loading from file -> exists |
180 | Log( ( "NodeInstance %s : %p\n", NNI->name(), NNI )); | 181 | Log( ( "NodeInstance %s : %p\n", NNI->name(), NNI )); |
181 | NNI->setNew( FALSE ); | 182 | NNI->setNew( FALSE ); |
182 | NSResources->addNodeInstance( NNI ); | 183 | NSResources->addNodeInstance( NNI ); |
183 | } | 184 | } |
185 | |||
184 | if( NN ) { | 186 | if( NN ) { |
185 | Log( ( "Node %s : %p\n", NN->name(), NN ) ); | 187 | Log( ( "Node %s : %p\n", NN->name(), NN ) ); |
186 | } | 188 | } |
187 | } | 189 | } |
188 | } | 190 | } |
189 | 191 | ||
190 | } while( 0 ); | 192 | } while( 0 ); |
191 | 193 | ||
192 | } | 194 | } |
193 | 195 | ||
194 | QString NetworkSettingsData::saveSettings( void ) { | 196 | QString NetworkSettingsData::saveSettings( void ) { |
195 | QString ErrS = ""; | 197 | QString ErrS = ""; |
@@ -202,64 +204,79 @@ QString NetworkSettingsData::saveSettings( void ) { | |||
202 | 204 | ||
203 | Log( ( "Saving settings to %s\n", CfgFile.latin1() )); | 205 | Log( ( "Saving settings to %s\n", CfgFile.latin1() )); |
204 | if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { | 206 | if( ! F.open( IO_WriteOnly | IO_Truncate ) ) { |
205 | ErrS = qApp->translate( "NetworkSettings", | 207 | ErrS = qApp->translate( "NetworkSettings", |
206 | "<p>Could not save setup to \"%1\" !</p>" ). | 208 | "<p>Could not save setup to \"%1\" !</p>" ). |
207 | arg(CfgFile); | 209 | arg(CfgFile); |
208 | // problem | 210 | // problem |
209 | return ErrS; | 211 | return ErrS; |
210 | } | 212 | } |
211 | 213 | ||
212 | QTextStream TS( &F ); | 214 | QTextStream TS( &F ); |
213 | 215 | ||
214 | // save leftovers | ||
215 | for ( QStringList::Iterator it = LeftOvers.begin(); | ||
216 | it != LeftOvers.end(); ++it ) { | ||
217 | TS << (*it) << endl; | ||
218 | } | ||
219 | |||
220 | // save global configs | 216 | // save global configs |
221 | for( QDictIterator<NetNode_t> it( NSResources->netNodes() ); | 217 | for( QDictIterator<ANetNode> it( NSResources->netNodes() ); |
222 | it.current(); | 218 | it.current(); |
223 | ++it ) { | 219 | ++it ) { |
224 | TS << "[nodetype " | 220 | TS << "[nodetype " |
225 | << quote( QString( it.current()->NetNode->name() ) ) | 221 | << quote( QString( it.current()->name() ) ) |
226 | << "]" | 222 | << "]" |
227 | << endl; | 223 | << endl; |
228 | 224 | ||
229 | it.current()->NetNode->saveAttributes( TS ); | 225 | it.current()->saveAttributes( TS ); |
230 | TS << endl; | 226 | TS << endl; |
231 | } | 227 | } |
232 | 228 | ||
229 | // save leftovers | ||
230 | for ( QStringList::Iterator it = LeftOvers.begin(); | ||
231 | it != LeftOvers.end(); ++it ) { | ||
232 | TS << (*it) << endl; | ||
233 | } | ||
234 | |||
235 | // save all netnode instances | ||
236 | { ANetNodeInstance * NNI; | ||
237 | for( QDictIterator<ANetNodeInstance> nit( | ||
238 | NSResources->netNodeInstances()); | ||
239 | nit.current(); | ||
240 | ++nit ) { | ||
241 | // header | ||
242 | NNI = nit.current(); | ||
243 | TS << '[' | ||
244 | << QString(NNI->nodeClass()->name()) | ||
245 | << ']' | ||
246 | << endl; | ||
247 | NNI->saveAttributes( TS ); | ||
248 | TS << endl; | ||
249 | } | ||
250 | } | ||
251 | |||
252 | // good connections | ||
233 | { Name2Connection_t & M = NSResources->connections(); | 253 | { Name2Connection_t & M = NSResources->connections(); |
234 | ANetNodeInstance * NNI; | ||
235 | 254 | ||
236 | // for all connections | 255 | // for all connections |
237 | for( QDictIterator<NodeCollection> it(M); | 256 | for( QDictIterator<NodeCollection> it(M); |
238 | it.current(); | 257 | it.current(); |
239 | ++it ) { | 258 | ++it ) { |
240 | // all nodes in those connections | 259 | TS << "[connection]" << endl; |
241 | for( QListIterator<ANetNodeInstance> nit(*(it.current())); | 260 | it.current()->save(TS); |
242 | nit.current(); | 261 | } |
243 | ++nit ) { | 262 | } |
244 | // header | ||
245 | NNI = nit.current(); | ||
246 | TS << '[' | ||
247 | << QString(NNI->nodeClass()->name()) | ||
248 | << ']' | ||
249 | << endl; | ||
250 | NNI->saveAttributes( TS ); | ||
251 | TS << endl; | ||
252 | } | ||
253 | 263 | ||
264 | // save dangling connections | ||
265 | { Name2Connection_t & M = NSResources->danglingConnections(); | ||
266 | |||
267 | // for all connections | ||
268 | for( QDictIterator<NodeCollection> it(M); | ||
269 | it.current(); | ||
270 | ++it ) { | ||
254 | TS << "[connection]" << endl; | 271 | TS << "[connection]" << endl; |
255 | it.current()->save(TS); | 272 | it.current()->save(TS); |
256 | } | 273 | } |
257 | } | 274 | } |
258 | 275 | ||
259 | QDir D("."); | 276 | QDir D("."); |
260 | D.rename( CfgFile + ".bup", CfgFile ); | 277 | D.rename( CfgFile + ".bup", CfgFile ); |
261 | 278 | ||
262 | // | 279 | // |
263 | // proper files AND system files regenerated | 280 | // proper files AND system files regenerated |
264 | // | 281 | // |
265 | 282 | ||
@@ -280,32 +297,33 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
280 | NodeCollection * NC; | 297 | NodeCollection * NC; |
281 | ANetNodeInstance * NNI; | 298 | ANetNodeInstance * NNI; |
282 | ANetNodeInstance * FirstWithData; | 299 | ANetNodeInstance * FirstWithData; |
283 | RuntimeInfo * CurDev; | 300 | RuntimeInfo * CurDev; |
284 | ANetNode * NN, * CurDevNN = 0; | 301 | ANetNode * NN, * CurDevNN = 0; |
285 | long NoOfDevs; | 302 | long NoOfDevs; |
286 | long DevCtStart; | 303 | long DevCtStart; |
287 | bool needToGenerate; | 304 | bool needToGenerate; |
288 | 305 | ||
289 | // regenerate system files | 306 | // regenerate system files |
290 | Log( ( "Generating settings from %s\n", CfgFile.latin1() )); | 307 | Log( ( "Generating settings from %s\n", CfgFile.latin1() )); |
291 | 308 | ||
292 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); | 309 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); |
293 | nnit.current(); | 310 | nnit.current(); |
294 | ++nnit ) { | 311 | ++nnit ) { |
295 | { QStringList SL; | 312 | bool FirstItem = 1; |
296 | bool FirstItem = 1; | 313 | bool Generated = 0; |
297 | bool Generated = 0; | ||
298 | 314 | ||
299 | CurDevNN = nnit.current()->NetNode; | 315 | CurDevNN = nnit.current(); |
316 | |||
317 | { QStringList SL; | ||
300 | SL = CurDevNN->properFiles(); | 318 | SL = CurDevNN->properFiles(); |
301 | 319 | ||
302 | for ( QStringList::Iterator it = SL.begin(); | 320 | for ( QStringList::Iterator it = SL.begin(); |
303 | it != SL.end(); | 321 | it != SL.end(); |
304 | ++it ) { | 322 | ++it ) { |
305 | 323 | ||
306 | Generated = 0; | 324 | Generated = 0; |
307 | FirstItem = 1; | 325 | FirstItem = 1; |
308 | // iterate over NNI's of this class | 326 | // iterate over NNI's of this class |
309 | for( QDictIterator<ANetNodeInstance> nniit( | 327 | for( QDictIterator<ANetNodeInstance> nniit( |
310 | NSResources->netNodeInstances() ); | 328 | NSResources->netNodeInstances() ); |
311 | nniit.current(); | 329 | nniit.current(); |
@@ -386,54 +404,54 @@ QString NetworkSettingsData::generateSettings( void ) { | |||
386 | 404 | ||
387 | // | 405 | // |
388 | // generate all registered files | 406 | // generate all registered files |
389 | // | 407 | // |
390 | for( QDictIterator<SystemFile> sfit(SFM); | 408 | for( QDictIterator<SystemFile> sfit(SFM); |
391 | sfit.current(); | 409 | sfit.current(); |
392 | ++sfit ) { | 410 | ++sfit ) { |
393 | SystemFile * SF; | 411 | SystemFile * SF; |
394 | 412 | ||
395 | SF = sfit.current(); | 413 | SF = sfit.current(); |
396 | 414 | ||
397 | // reset all | 415 | // reset all |
398 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); | 416 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); |
399 | nnit.current(); | 417 | nnit.current(); |
400 | ++nnit ) { | 418 | ++nnit ) { |
401 | nnit.current()->NetNode->setDone(0); | 419 | nnit.current()->setDone(0); |
402 | } | 420 | } |
403 | 421 | ||
404 | for( QDictIterator<ANetNodeInstance> nniit( | 422 | for( QDictIterator<ANetNodeInstance> nniit( |
405 | NSResources->netNodeInstances() ); | 423 | NSResources->netNodeInstances() ); |
406 | nniit.current(); | 424 | nniit.current(); |
407 | ++nniit ) { | 425 | ++nniit ) { |
408 | nniit.current()->setDone(0); | 426 | nniit.current()->setDone(0); |
409 | } | 427 | } |
410 | 428 | ||
411 | for( QDictIterator<NodeCollection> ncit(M); | 429 | for( QDictIterator<NodeCollection> ncit(M); |
412 | ncit.current(); | 430 | ncit.current(); |
413 | ++ncit ) { | 431 | ++ncit ) { |
414 | ncit.current()->setDone(0); | 432 | ncit.current()->setDone(0); |
415 | } | 433 | } |
416 | 434 | ||
417 | Log( ( "Generating system file %s\n", SF->name().latin1() )); | 435 | Log( ( "Generating system file %s\n", SF->name().latin1() )); |
418 | 436 | ||
419 | needToGenerate = 0; | 437 | needToGenerate = 0; |
420 | 438 | ||
421 | // are there netnodes that have instances and need | 439 | // are there netnodes that have instances and need |
422 | // to write data in this system file ? | 440 | // to write data in this system file ? |
423 | for( QDictIterator<NetNode_t> nnit( NSResources->netNodes() ); | 441 | for( QDictIterator<ANetNode> nnit( NSResources->netNodes() ); |
424 | ! needToGenerate && nnit.current(); | 442 | ! needToGenerate && nnit.current(); |
425 | ++nnit ) { | 443 | ++nnit ) { |
426 | 444 | ||
427 | NN = nnit.current()->NetNode; | 445 | NN = nnit.current(); |
428 | 446 | ||
429 | if( NN->hasDataForFile( *SF ) ) { | 447 | if( NN->hasDataForFile( *SF ) ) { |
430 | // netnode can have data | 448 | // netnode can have data |
431 | 449 | ||
432 | // are there instances of this node ? | 450 | // are there instances of this node ? |
433 | for( QDictIterator<ANetNodeInstance> nniit( | 451 | for( QDictIterator<ANetNodeInstance> nniit( |
434 | NSResources->netNodeInstances() ); | 452 | NSResources->netNodeInstances() ); |
435 | ! needToGenerate && nniit.current(); | 453 | ! needToGenerate && nniit.current(); |
436 | ++nniit ) { | 454 | ++nniit ) { |
437 | if( nniit.current()->nodeClass() == NN ) { | 455 | if( nniit.current()->nodeClass() == NN ) { |
438 | // yes | 456 | // yes |
439 | Log(("Node %s has data\n", | 457 | Log(("Node %s has data\n", |
diff --git a/noncore/settings/networksettings2/ppp/ppp_NN.cpp b/noncore/settings/networksettings2/ppp/ppp_NN.cpp index bd13ab9..8c15e9c 100644 --- a/noncore/settings/networksettings2/ppp/ppp_NN.cpp +++ b/noncore/settings/networksettings2/ppp/ppp_NN.cpp | |||
@@ -1,24 +1,20 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include <resources.h> | 2 | #include <resources.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include "ppp_NN.h" | 4 | #include "ppp_NN.h" |
5 | #include "ppp_NNI.h" | 5 | #include "ppp_NNI.h" |
6 | 6 | ||
7 | #ifndef MYPLUGIN | ||
8 | |||
9 | #include "netnodeinterface.h" | 7 | #include "netnodeinterface.h" |
10 | 8 | ||
11 | #endif | ||
12 | |||
13 | QStringList * PPPNetNode::ProperFiles = 0; | 9 | QStringList * PPPNetNode::ProperFiles = 0; |
14 | 10 | ||
15 | static const char * PPPNeeds[] = | 11 | static const char * PPPNeeds[] = |
16 | { "modem", | 12 | { "modem", |
17 | 0 | 13 | 0 |
18 | }; | 14 | }; |
19 | 15 | ||
20 | static const char * PPPProvides[] = | 16 | static const char * PPPProvides[] = |
21 | { "connection", | 17 | { "connection", |
22 | 0 | 18 | 0 |
23 | }; | 19 | }; |
24 | 20 | ||
@@ -75,26 +71,13 @@ bool PPPNetNode::hasDataForFile( SystemFile & S ) { | |||
75 | 71 | ||
76 | QString PPPNetNode::genNic( long NicNr ) { | 72 | QString PPPNetNode::genNic( long NicNr ) { |
77 | QString S; | 73 | QString S; |
78 | return S.sprintf( "ppp%ld", NicNr ); | 74 | return S.sprintf( "ppp%ld", NicNr ); |
79 | } | 75 | } |
80 | 76 | ||
81 | void PPPNetNode::setSpecificAttribute( QString & , QString & ) { | 77 | void PPPNetNode::setSpecificAttribute( QString & , QString & ) { |
82 | } | 78 | } |
83 | 79 | ||
84 | void PPPNetNode::saveSpecificAttribute( QTextStream & ) { | 80 | void PPPNetNode::saveSpecificAttribute( QTextStream & ) { |
85 | } | 81 | } |
86 | 82 | ||
87 | #ifdef MYPLUGIN | 83 | OPIE_NS2_PLUGIN( NetNodeInterface_T<PPPNetNode> ) |
88 | |||
89 | extern "C" { | ||
90 | void create_plugin( QList<ANetNode> & PNN ) { | ||
91 | PNN.append( new PPPNetNode() ); | ||
92 | } | ||
93 | |||
94 | #else | ||
95 | |||
96 | OPIE_NS2_PLUGIN( NetNodeInterface<PPPNetNode> ) | ||
97 | |||
98 | #endif | ||
99 | |||
100 | } | ||
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp index 6028ea5..1e6912e 100644 --- a/noncore/settings/networksettings2/profile/profile_NN.cpp +++ b/noncore/settings/networksettings2/profile/profile_NN.cpp | |||
@@ -1,22 +1,18 @@ | |||
1 | #include <resources.h> | 1 | #include <resources.h> |
2 | #include "profile_NN.h" | 2 | #include "profile_NN.h" |
3 | #include "profile_NNI.h" | 3 | #include "profile_NNI.h" |
4 | 4 | ||
5 | #ifndef MYPLUGIN | ||
6 | |||
7 | #include "netnodeinterface.h" | 5 | #include "netnodeinterface.h" |
8 | 6 | ||
9 | #endif | ||
10 | |||
11 | static const char * ProfileNeeds[] = | 7 | static const char * ProfileNeeds[] = |
12 | { "connection", | 8 | { "connection", |
13 | 0 | 9 | 0 |
14 | }; | 10 | }; |
15 | static const char * ProfileProvides[] = | 11 | static const char * ProfileProvides[] = |
16 | { "fullsetup", | 12 | { "fullsetup", |
17 | 0 | 13 | 0 |
18 | }; | 14 | }; |
19 | 15 | ||
20 | /** | 16 | /** |
21 | * Constructor, find all of the possible interfaces | 17 | * Constructor, find all of the possible interfaces |
22 | */ | 18 | */ |
@@ -50,26 +46,13 @@ const char ** ProfileNetNode::needs( void ) { | |||
50 | } | 46 | } |
51 | 47 | ||
52 | const char ** ProfileNetNode::provides( void ) { | 48 | const char ** ProfileNetNode::provides( void ) { |
53 | return ProfileProvides; | 49 | return ProfileProvides; |
54 | } | 50 | } |
55 | 51 | ||
56 | void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { | 52 | void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { |
57 | } | 53 | } |
58 | 54 | ||
59 | void ProfileNetNode::saveSpecificAttribute( QTextStream & ) { | 55 | void ProfileNetNode::saveSpecificAttribute( QTextStream & ) { |
60 | } | 56 | } |
61 | 57 | ||
62 | #ifdef MYPLUGIN | 58 | OPIE_NS2_PLUGIN( NetNodeInterface_T<ProfileNetNode> ) |
63 | |||
64 | extern "C" { | ||
65 | void create_plugin( QList<ANetNode> & PNN ) { | ||
66 | PNN.append( new ProfileNetNode() ); | ||
67 | } | ||
68 | |||
69 | #else | ||
70 | |||
71 | OPIE_NS2_PLUGIN( NetNodeInterface<ProfileNetNode> ) | ||
72 | |||
73 | #endif | ||
74 | |||
75 | } | ||
diff --git a/noncore/settings/networksettings2/usb/usb_NN.cpp b/noncore/settings/networksettings2/usb/usb_NN.cpp index 9c07b82..6d90ae0 100644 --- a/noncore/settings/networksettings2/usb/usb_NN.cpp +++ b/noncore/settings/networksettings2/usb/usb_NN.cpp | |||
@@ -1,22 +1,18 @@ | |||
1 | #include <resources.h> | 1 | #include <resources.h> |
2 | #include "usb_NN.h" | 2 | #include "usb_NN.h" |
3 | #include "usb_NNI.h" | 3 | #include "usb_NNI.h" |
4 | 4 | ||
5 | #ifndef MYPLUGIN | ||
6 | |||
7 | #include "netnodeinterface.h" | 5 | #include "netnodeinterface.h" |
8 | 6 | ||
9 | #endif | ||
10 | |||
11 | static const char * USBNeeds[] = | 7 | static const char * USBNeeds[] = |
12 | { 0 | 8 | { 0 |
13 | }; | 9 | }; |
14 | 10 | ||
15 | static const char * USBProvides[] = | 11 | static const char * USBProvides[] = |
16 | { "device", | 12 | { "device", |
17 | 0 | 13 | 0 |
18 | }; | 14 | }; |
19 | 15 | ||
20 | /** | 16 | /** |
21 | * Constructor, find all of the possible interfaces | 17 | * Constructor, find all of the possible interfaces |
22 | */ | 18 | */ |
@@ -52,26 +48,13 @@ const char ** USBNetNode::provides( void ) { | |||
52 | } | 48 | } |
53 | 49 | ||
54 | QString USBNetNode::genNic( long ) { | 50 | QString USBNetNode::genNic( long ) { |
55 | return QString( "usbf" ); | 51 | return QString( "usbf" ); |
56 | } | 52 | } |
57 | 53 | ||
58 | void USBNetNode::setSpecificAttribute( QString & , QString & ) { | 54 | void USBNetNode::setSpecificAttribute( QString & , QString & ) { |
59 | } | 55 | } |
60 | 56 | ||
61 | void USBNetNode::saveSpecificAttribute( QTextStream & ) { | 57 | void USBNetNode::saveSpecificAttribute( QTextStream & ) { |
62 | } | 58 | } |
63 | 59 | ||
64 | #ifdef MYPLUGIN | 60 | OPIE_NS2_PLUGIN( NetNodeInterface_T<USBNetNode> ) |
65 | |||
66 | extern "C" { | ||
67 | void create_plugin( QList<ANetNode> & PNN ) { | ||
68 | PNN.append( new USBNetNode() ); | ||
69 | } | ||
70 | |||
71 | #else | ||
72 | |||
73 | OPIE_NS2_PLUGIN( NetNodeInterface<USBNetNode> ) | ||
74 | |||
75 | #endif | ||
76 | |||
77 | } | ||
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp index 0a46642..eb439c1 100644 --- a/noncore/settings/networksettings2/usb/usbrun.cpp +++ b/noncore/settings/networksettings2/usb/usbrun.cpp | |||
@@ -1,22 +1,24 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | #include <qfileinfo.h> | 2 | #include <qfileinfo.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <resources.h> | 4 | #include <resources.h> |
5 | #include "usbrun.h" | 5 | #include "usbrun.h" |
6 | 6 | ||
7 | State_t USBRun::detectState( void ) { | 7 | State_t USBRun::detectState( void ) { |
8 | |||
8 | // unavailable : no card found | 9 | // unavailable : no card found |
9 | // available : card found and assigned to us or free | 10 | // available : card found and assigned to us or free |
10 | // up : card found and assigned to us and up | 11 | // up : card found and assigned to us and up |
12 | |||
11 | NodeCollection * NC = nodeCollection(); | 13 | NodeCollection * NC = nodeCollection(); |
12 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); | 14 | QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); |
13 | System & Sys = NSResources->system(); | 15 | System & Sys = NSResources->system(); |
14 | InterfaceInfo * Run; | 16 | InterfaceInfo * Run; |
15 | QFile F( S ); | 17 | QFile F( S ); |
16 | Log(("Detecting for %s\n", NC->name().latin1() )); | 18 | Log(("Detecting for %s\n", NC->name().latin1() )); |
17 | 19 | ||
18 | if( F.open( IO_ReadOnly ) ) { | 20 | if( F.open( IO_ReadOnly ) ) { |
19 | // could open file -> read interface and assign | 21 | // could open file -> read interface and assign |
20 | QString X; | 22 | QString X; |
21 | QTextStream TS(&F); | 23 | QTextStream TS(&F); |
22 | X = TS.readLine(); | 24 | X = TS.readLine(); |
@@ -55,44 +57,37 @@ State_t USBRun::detectState( void ) { | |||
55 | 57 | ||
56 | Log(("%s %d %d=%d %d\n", | 58 | Log(("%s %d %d=%d %d\n", |
57 | Run->Name.latin1(), | 59 | Run->Name.latin1(), |
58 | handlesInterface( Run->Name ), | 60 | handlesInterface( Run->Name ), |
59 | Run->CardType, ARPHRD_ETHER, | 61 | Run->CardType, ARPHRD_ETHER, |
60 | ! Run->IsUp )); | 62 | ! Run->IsUp )); |
61 | 63 | ||
62 | if( handlesInterface( Run->Name ) && | 64 | if( handlesInterface( Run->Name ) && |
63 | Run->CardType == ARPHRD_ETHER && | 65 | Run->CardType == ARPHRD_ETHER && |
64 | ! Run->IsUp | 66 | ! Run->IsUp |
65 | ) { | 67 | ) { |
66 | // proper type, and Not UP -> free | 68 | // proper type, and Not UP -> free |
67 | return Off; | 69 | // usb cables are currently always available when requested |
70 | // until we can detect if we are plugged in | ||
71 | return Available; | ||
68 | } | 72 | } |
69 | } | 73 | } |
70 | 74 | ||
71 | return Unavailable; | 75 | return Unavailable; |
72 | } | 76 | } |
73 | 77 | ||
74 | QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) { | 78 | QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) { |
75 | 79 | ||
76 | // nothing needs to be done to 'activate' or 'deactivate' | 80 | // nothing needs to be done to 'activate' or 'deactivate' |
77 | // a cable | 81 | // a cable |
78 | |||
79 | // perhaps (later) we can figure out if the device is IN the | ||
80 | // cradle | ||
81 | if( A == Activate ) { | ||
82 | NC->setCurrentState( Available ); | ||
83 | } else if ( A == Deactivate ) { | ||
84 | NC->setCurrentState( Unavailable ); | ||
85 | } | ||
86 | |||
87 | return QString(); | 82 | return QString(); |
88 | } | 83 | } |
89 | 84 | ||
90 | // get interface that is free or assigned to us | 85 | // get interface that is free or assigned to us |
91 | InterfaceInfo * USBRun::getInterface( void ) { | 86 | InterfaceInfo * USBRun::getInterface( void ) { |
92 | 87 | ||
93 | System & S = NSResources->system(); | 88 | System & S = NSResources->system(); |
94 | InterfaceInfo * best = 0, * Run; | 89 | InterfaceInfo * best = 0, * Run; |
95 | QRegExp R( "usb[0-9abcdef]" ); | 90 | QRegExp R( "usb[0-9abcdef]" ); |
96 | 91 | ||
97 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); | 92 | for( QDictIterator<InterfaceInfo> It(S.interfaces()); |
98 | It.current(); | 93 | It.current(); |
diff --git a/noncore/settings/networksettings2/vpn/vpn_NN.cpp b/noncore/settings/networksettings2/vpn/vpn_NN.cpp index 6dd5332..96e9df2 100644 --- a/noncore/settings/networksettings2/vpn/vpn_NN.cpp +++ b/noncore/settings/networksettings2/vpn/vpn_NN.cpp | |||
@@ -1,21 +1,17 @@ | |||
1 | #include "vpn_NN.h" | 1 | #include "vpn_NN.h" |
2 | #include "vpn_NNI.h" | 2 | #include "vpn_NNI.h" |
3 | 3 | ||
4 | #ifndef MYPLUGIN | ||
5 | |||
6 | #include "netnodeinterface.h" | 4 | #include "netnodeinterface.h" |
7 | 5 | ||
8 | #endif | ||
9 | |||
10 | static const char * VPNNeeds[] = | 6 | static const char * VPNNeeds[] = |
11 | { 0 | 7 | { 0 |
12 | }; | 8 | }; |
13 | 9 | ||
14 | static const char * VPNProvides[] = | 10 | static const char * VPNProvides[] = |
15 | { "connection", | 11 | { "connection", |
16 | 0 | 12 | 0 |
17 | }; | 13 | }; |
18 | /** | 14 | /** |
19 | * Constructor, find all of the possible interfaces | 15 | * Constructor, find all of the possible interfaces |
20 | */ | 16 | */ |
21 | VPNNetNode::VPNNetNode() : ANetNode(tr("VPN Connection")) { | 17 | VPNNetNode::VPNNetNode() : ANetNode(tr("VPN Connection")) { |
@@ -44,26 +40,13 @@ const char ** VPNNetNode::needs( void ) { | |||
44 | } | 40 | } |
45 | 41 | ||
46 | const char ** VPNNetNode::provides( void ) { | 42 | const char ** VPNNetNode::provides( void ) { |
47 | return VPNProvides; | 43 | return VPNProvides; |
48 | } | 44 | } |
49 | 45 | ||
50 | void VPNNetNode::setSpecificAttribute( QString & , QString & ) { | 46 | void VPNNetNode::setSpecificAttribute( QString & , QString & ) { |
51 | } | 47 | } |
52 | 48 | ||
53 | void VPNNetNode::saveSpecificAttribute( QTextStream & ) { | 49 | void VPNNetNode::saveSpecificAttribute( QTextStream & ) { |
54 | } | 50 | } |
55 | 51 | ||
56 | #ifdef MYPLUGIN | 52 | OPIE_NS2_PLUGIN( NetNodeInterface_T<VPNNetNode> ) |
57 | |||
58 | extern "C" { | ||
59 | void create_plugin( QList<ANetNode> & PNN ) { | ||
60 | PNN.append( new VPNNetNode() ); | ||
61 | } | ||
62 | |||
63 | #else | ||
64 | |||
65 | OPIE_NS2_PLUGIN( NetNodeInterface<VPNNetNode> ) | ||
66 | |||
67 | #endif | ||
68 | |||
69 | } | ||
diff --git a/noncore/settings/networksettings2/wlan/wlan_NN.cpp b/noncore/settings/networksettings2/wlan/wlan_NN.cpp index c56da06..f7745be 100644 --- a/noncore/settings/networksettings2/wlan/wlan_NN.cpp +++ b/noncore/settings/networksettings2/wlan/wlan_NN.cpp | |||
@@ -1,22 +1,18 @@ | |||
1 | #include <resources.h> | 1 | #include <resources.h> |
2 | #include "wlan_NN.h" | 2 | #include "wlan_NN.h" |
3 | #include "wlan_NNI.h" | 3 | #include "wlan_NNI.h" |
4 | 4 | ||
5 | #ifndef MYPLUGIN | ||
6 | |||
7 | #include "netnodeinterface.h" | 5 | #include "netnodeinterface.h" |
8 | 6 | ||
9 | #endif | ||
10 | |||
11 | static const char * WLanNeeds[] = | 7 | static const char * WLanNeeds[] = |
12 | { 0 | 8 | { 0 |
13 | }; | 9 | }; |
14 | 10 | ||
15 | static const char * WLanProvides[] = | 11 | static const char * WLanProvides[] = |
16 | { "device", | 12 | { "device", |
17 | 0 | 13 | 0 |
18 | }; | 14 | }; |
19 | 15 | ||
20 | /** | 16 | /** |
21 | * Constructor, find all of the possible interfaces | 17 | * Constructor, find all of the possible interfaces |
22 | */ | 18 | */ |
@@ -60,26 +56,13 @@ QString WLanNetNode::genNic( long nr ) { | |||
60 | void WLanNetNode::setSpecificAttribute( QString & A, QString & V ) { | 56 | void WLanNetNode::setSpecificAttribute( QString & A, QString & V ) { |
61 | if( A == "interfacecount" ) { | 57 | if( A == "interfacecount" ) { |
62 | InstanceCount = V.toLong(); | 58 | InstanceCount = V.toLong(); |
63 | } | 59 | } |
64 | } | 60 | } |
65 | 61 | ||
66 | void WLanNetNode::saveSpecificAttribute( QTextStream & TS ) { | 62 | void WLanNetNode::saveSpecificAttribute( QTextStream & TS ) { |
67 | TS << "interfacecount=" | 63 | TS << "interfacecount=" |
68 | << InstanceCount | 64 | << InstanceCount |
69 | << endl; | 65 | << endl; |
70 | } | 66 | } |
71 | 67 | ||
72 | #ifdef MYPLUGIN | 68 | OPIE_NS2_PLUGIN( NetNodeInterface_T<WLanNetNode> ) |
73 | |||
74 | extern "C" { | ||
75 | void create_plugin( QList<ANetNode> & PNN ) { | ||
76 | PNN.append( new WLanNetNode() ); | ||
77 | } | ||
78 | |||
79 | #else | ||
80 | |||
81 | OPIE_NS2_PLUGIN( NetNodeInterface<WLanNetNode> ) | ||
82 | |||
83 | #endif | ||
84 | |||
85 | } | ||