summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/nsdata.cpp
authorwimpie <wimpie>2005-01-11 15:35:46 (UTC)
committer wimpie <wimpie>2005-01-11 15:35:46 (UTC)
commit4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9 (patch) (side-by-side diff)
tree0e8adcc616a1d20b637aad3de568dcb45af05f71 /noncore/settings/networksettings2/nsdata.cpp
parent32e8aa951218c0bd6118ee04bb22ef83b3b7ec2e (diff)
downloadopie-4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9.zip
opie-4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9.tar.gz
opie-4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9.tar.bz2
vpn should now work IF only the vpn plugin would do something.
shortened logical interface names (busybox only supports 10 characters and then ONLY if you recompile it with mappings enabled) Other small fixes
Diffstat (limited to 'noncore/settings/networksettings2/nsdata.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp66
1 files changed, 55 insertions, 11 deletions
diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp
index d76353a..39031ed 100644
--- a/noncore/settings/networksettings2/nsdata.cpp
+++ b/noncore/settings/networksettings2/nsdata.cpp
@@ -58,12 +58,14 @@ NetworkSettingsData::NetworkSettingsData( void ) {
interfacename.latin1(), profilenr ));
NC = NSResources->getConnection( profilenr );
if( NC ) {
NC->assignInterface(
NSResources->system().findInterface( interfacename ) );
+ Log(( "Assign interface %p\n",
+ NC->assignedInterface() ));
} else {
Log(( "Profile nr %d no longer defined\n",
profilenr ));
}
}
}
@@ -640,29 +642,31 @@ QString NetworkSettingsData::generateSettings( void ) {
// end of file
SF->close();
}
return S;
}
-QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interface ) {
+QList<NodeCollection> NetworkSettingsData::collectPossible(
+ const QString & Interface ) {
// collect connections that can work on top of this interface
NodeCollection * NC;
QList<NodeCollection> PossibleConnections;
Name2Connection_t & M = NSResources->connections();
// for all connections
for( QDictIterator<NodeCollection> it(M);
it.current();
++it ) {
NC = it.current();
// check if this profile handles the requested interface
if( NC->handlesInterface( Interface ) && // if different Intf.
- NC->state() != Disabled && // if not enabled
+ NC->state() != Disabled && // if enabled
NC->state() != IsUp // if already used
) {
- Log( ( "Append %s for %s\n", NC->name().latin1(), Interface));
+ Log( ( "Append %s for %s\n",
+ NC->name().latin1(), Interface.latin1() ));
PossibleConnections.append( NC );
}
}
return PossibleConnections;
}
@@ -670,21 +674,21 @@ QList<NodeCollection> NetworkSettingsData::collectPossible( const char * Interfa
/*
Called by the system to see if interface can be brought UP
if allowed, echo Interface-allowed else Interface-disallowed
*/
-bool NetworkSettingsData::canStart( const char * Interface ) {
+bool NetworkSettingsData::canStart( const QString & Interface ) {
// load situation
NodeCollection * NC = 0;
QList<NodeCollection> PossibleConnections;
PossibleConnections = collectPossible( Interface );
Log( ( "for %s : Possiblilies %d\n",
- Interface, PossibleConnections.count() ));
+ Interface.latin1(), PossibleConnections.count() ));
switch( PossibleConnections.count() ) {
case 0 : // no connections
break;
case 1 : // one connection
NC = PossibleConnections.first();
break;
@@ -703,31 +707,31 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
break;
case Off :
// try to UP the device
{ QString S= NC->setState( Activate );
if( ! S.isEmpty() ) {
// could not bring device Online -> try other alters
- Log(( "%s-c%d-disallowed : %s\n",
- Interface, NC->number(), S.latin1() ));
+ Log(( "disallow %ld for %s : %s\n",
+ NC->number(), Interface.latin1(), S.latin1() ));
break;
}
// interface assigned
}
// FT
case Available :
case IsUp : // also called for 'ifdown'
// device is ready -> done
- Log(( "%s-c%d-allowed\n", Interface, NC->number() ));
- printf( "%s-c%d-allowed\n", Interface, NC->number() );
+ Log(( "allow %ld for %s\n", NC->number(), Interface.latin1()));
+ printf( "A%ld%s\n", NC->number(), Interface.latin1() );
return 0;
}
}
// if we come here no alternatives are possible
- Log(( "%s-cnn-disallowed\n", Interface ));
- printf( "%s-cnn-disallowed\n", Interface );
+ Log(( "disallow %s\n", Interface.latin1()));
+ printf( "D-%s\n", Interface.latin1() );
return 0;
}
bool NetworkSettingsData::isModified( void ) {
if( ForceModified )
return 1;
@@ -738,6 +742,46 @@ bool NetworkSettingsData::isModified( void ) {
if( it.current()->isModified() ) {
return 1;
}
}
return 0;
}
+
+bool NetworkSettingsData::couldBeTriggered( const QString & Interface ) {
+ // load situation
+ QList<NodeCollection> PossibleTriggered;
+
+ PossibleTriggered = collectTriggered( Interface );
+
+ Log( ( "for %s : Possiblilies %d\n",
+ Interface.latin1(), PossibleTriggered.count() ));
+
+ return ( PossibleTriggered.count() ) ? 1 : 0;
+}
+
+QList<NodeCollection> NetworkSettingsData::collectTriggered(
+ const QString & Interface ) {
+
+ // collect connections that could be triggered by this interface
+ NodeCollection * NC;
+ QList<NodeCollection> PossibleTriggered;
+
+ // for all connections
+ Name2Connection_t & M = NSResources->connections();
+
+ for( QDictIterator<NodeCollection> it(M);
+ it.current();
+ ++it ) {
+ NC = it.current();
+ // check if this profile handles the requested interface
+ if( NC->triggeredBy( Interface ) && // if different Intf.
+ NC->state() != Disabled && // if enabled
+ NC->state() != IsUp // if already used
+ ) {
+ Log( ( "Append %s for %s\n",
+ NC->name().latin1(), Interface.latin1() ));
+ PossibleTriggered.append( NC );
+ }
+ }
+ return PossibleTriggered;
+}
+