summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/profile
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/profile') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control4
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.cpp13
-rw-r--r--noncore/settings/networksettings2/profile/profile_NN.h2
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.cpp13
-rw-r--r--noncore/settings/networksettings2/profile/profile_NNI.h4
-rw-r--r--noncore/settings/networksettings2/profile/profiledata.h5
-rw-r--r--noncore/settings/networksettings2/profile/profileedit.cpp10
-rw-r--r--noncore/settings/networksettings2/profile/profileedit.h8
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.cpp72
-rw-r--r--noncore/settings/networksettings2/profile/profilerun.h24
10 files changed, 60 insertions, 95 deletions
diff --git a/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control b/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control
index c76f9b8..40c8b48 100644
--- a/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control
+++ b/noncore/settings/networksettings2/profile/opie-networksettings2plugin-bluetooth.control
@@ -1,9 +1,9 @@
1Package: opie-networksettingsplugin2-profile 1Package: opie-networksettings2plugin-profile
2Files: plugins/networksettings2/libprofile.so* 2Files: plugins/networksettings2/libprofile.so*
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Maintainer: Wim Delvaux <wimpie@handhelds.org> 5Maintainer: Wim Delvaux <wimpie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Depends: opie-networksettings2, libopiecore2, libopienet2 7Depends: opie-networksettings2, libopiecore2, libopienet2
8Description: Network settings profile plugin. 8Description: Network settings usage profile plugin.
9Version: $QPE_VERSION$EXTRAVERSION 9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/networksettings2/profile/profile_NN.cpp b/noncore/settings/networksettings2/profile/profile_NN.cpp
index 945b48d..b7d8aa0 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NN.cpp
@@ -1,3 +1,4 @@
1#include <resources.h>
1#include "profile_NN.h" 2#include "profile_NN.h"
2#include "profile_NNI.h" 3#include "profile_NNI.h"
3 4
@@ -5,11 +6,19 @@ static const char * ProfileNeeds[] =
5 { "connection", 6 { "connection",
6 0 7 0
7 }; 8 };
9static const char * ProfileProvides[] =
10 { "fullsetup",
11 0
12 };
8 13
9/** 14/**
10 * Constructor, find all of the possible interfaces 15 * Constructor, find all of the possible interfaces
11 */ 16 */
12ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) { 17ProfileNetNode::ProfileNetNode() : ANetNode( tr("Regular connection profile")) {
18
19 NSResources->addSystemFile(
20 "interfaces", "/etc/network/interfaces", 1 );
21
13} 22}
14 23
15/** 24/**
@@ -34,8 +43,8 @@ const char ** ProfileNetNode::needs( void ) {
34 return ProfileNeeds; 43 return ProfileNeeds;
35} 44}
36 45
37const char * ProfileNetNode::provides( void ) { 46const char ** ProfileNetNode::provides( void ) {
38 return "fullsetup"; 47 return ProfileProvides;
39} 48}
40 49
41void ProfileNetNode::setSpecificAttribute( QString & , QString & ) { 50void ProfileNetNode::setSpecificAttribute( QString & , QString & ) {
diff --git a/noncore/settings/networksettings2/profile/profile_NN.h b/noncore/settings/networksettings2/profile/profile_NN.h
index 1f1ee2c..f1648f9 100644
--- a/noncore/settings/networksettings2/profile/profile_NN.h
+++ b/noncore/settings/networksettings2/profile/profile_NN.h
@@ -20,7 +20,7 @@ public:
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 virtual ANetNodeInstance * createInstance( void ); 21 virtual ANetNodeInstance * createInstance( void );
22 virtual const char ** needs( void ); 22 virtual const char ** needs( void );
23 virtual const char * provides( void ); 23 virtual const char ** provides( void );
24 24
25private: 25private:
26 26
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.cpp b/noncore/settings/networksettings2/profile/profile_NNI.cpp
index f0f0b97..a1e1254 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.cpp
+++ b/noncore/settings/networksettings2/profile/profile_NNI.cpp
@@ -1,3 +1,4 @@
1#include <opie2/odebug.h>
1#include "profileedit.h" 2#include "profileedit.h"
2#include "profile_NNI.h" 3#include "profile_NNI.h"
3#include "profile_NN.h" 4#include "profile_NN.h"
@@ -50,25 +51,23 @@ void AProfile::commit( void ) {
50 setModified( 1 ); 51 setModified( 1 );
51} 52}
52 53
53short AProfile::generateFileEmbedded( const QString & ID, 54short AProfile::generateFileEmbedded( SystemFile & SF,
54 const QString & Path,
55 QTextStream & TS,
56 long DevNr ) { 55 long DevNr ) {
57 56
58 short rvl, rvd; 57 short rvl, rvd;
59 58
60 rvl = 1; 59 rvl = 1;
61 60
62 if( ID == "interfaces" ) { 61 if( SF.name() == "interfaces" ) {
63 Log(("Generate Profile for %s\n", ID.latin1() )); 62 Log(("Generate Profile for %s\n", SF.name().latin1() ));
64 if( Data.TriggerVPN ) { 63 if( Data.TriggerVPN ) {
65 // this profile triggers VPN -> insert trigger 64 // this profile triggers VPN -> insert trigger
66 TS << " up networksettings2 --triggervpn" 65 SF << " up networksettings2 --triggervpn"
67 << endl; 66 << endl;
68 rvl = 0; 67 rvl = 0;
69 } 68 }
70 } 69 }
71 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); 70 rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr );
72 return (rvd == 2 || rvl == 2 ) ? 2 : 71 return (rvd == 2 || rvl == 2 ) ? 2 :
73 (rvd == 0 || rvl == 0 ) ? 0 : 1; 72 (rvd == 0 || rvl == 0 ) ? 0 : 1;
74} 73}
diff --git a/noncore/settings/networksettings2/profile/profile_NNI.h b/noncore/settings/networksettings2/profile/profile_NNI.h
index 957f4af..ccd746c 100644
--- a/noncore/settings/networksettings2/profile/profile_NNI.h
+++ b/noncore/settings/networksettings2/profile/profile_NNI.h
@@ -26,9 +26,7 @@ public :
26 virtual void * data( void ) 26 virtual void * data( void )
27 { return (void *)&Data; } 27 { return (void *)&Data; }
28 28
29 virtual short generateFileEmbedded( const QString & ID, 29 virtual short generateFileEmbedded( SystemFile & TS,
30 const QString & Path,
31 QTextStream & TS,
32 long DevNr ); 30 long DevNr );
33 31
34 const QString & description( void ) 32 const QString & description( void )
diff --git a/noncore/settings/networksettings2/profile/profiledata.h b/noncore/settings/networksettings2/profile/profiledata.h
index 246d50c..c9577e5 100644
--- a/noncore/settings/networksettings2/profile/profiledata.h
+++ b/noncore/settings/networksettings2/profile/profiledata.h
@@ -2,7 +2,8 @@
2#define PROFILE_DATA_H 2#define PROFILE_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5typedef struct ProfileData { 5class ProfileData {
6public :
6 QString Description; 7 QString Description;
7 // start up automatically 8 // start up automatically
8 bool Automatic; 9 bool Automatic;
@@ -11,6 +12,6 @@ typedef struct ProfileData {
11 // Do not bring this connection up 12 // Do not bring this connection up
12 bool Disabled; 13 bool Disabled;
13 bool TriggerVPN; 14 bool TriggerVPN;
14} ProfileData_t; 15} ;
15 16
16#endif 17#endif
diff --git a/noncore/settings/networksettings2/profile/profileedit.cpp b/noncore/settings/networksettings2/profile/profileedit.cpp
index 87e503e..88aab15 100644
--- a/noncore/settings/networksettings2/profile/profileedit.cpp
+++ b/noncore/settings/networksettings2/profile/profileedit.cpp
@@ -5,7 +5,7 @@
5#include <qcheckbox.h> 5#include <qcheckbox.h>
6 6
7#include <GUIUtils.h> 7#include <GUIUtils.h>
8#include <asdevice.h> 8#include <netnode.h>
9#include <resources.h> 9#include <resources.h>
10 10
11#include "profileedit.h" 11#include "profileedit.h"
@@ -16,7 +16,7 @@ ProfileEdit::ProfileEdit( QWidget * Parent, ANetNodeInstance * TNNI ) :
16 16
17 NNI = TNNI; 17 NNI = TNNI;
18 Dev = NNI->runtime()->device(); 18 Dev = NNI->runtime()->device();
19 if( ( II = Dev->assignedInterface() ) ) { 19 if( ( II = NNI->connection()->assignedInterface() ) ) {
20 20
21 Refresh_CB->setEnabled( TRUE ); 21 Refresh_CB->setEnabled( TRUE );
22 Snd_GB->setEnabled( TRUE ); 22 Snd_GB->setEnabled( TRUE );
@@ -55,7 +55,7 @@ QString ProfileEdit::acceptable( void ) {
55 return QString(); 55 return QString();
56} 56}
57 57
58void ProfileEdit::showData( ProfileData_t & Data ) { 58void ProfileEdit::showData( ProfileData & Data ) {
59 Description_LE->setText( Data.Description ); 59 Description_LE->setText( Data.Description );
60 Automatic_CB->setChecked( Data.Automatic ); 60 Automatic_CB->setChecked( Data.Automatic );
61 TriggersVPN_CB->setChecked( Data.TriggerVPN ); 61 TriggersVPN_CB->setChecked( Data.TriggerVPN );
@@ -64,7 +64,7 @@ void ProfileEdit::showData( ProfileData_t & Data ) {
64} 64}
65 65
66 66
67bool ProfileEdit::commit( ProfileData_t & Data ) { 67bool ProfileEdit::commit( ProfileData & Data ) {
68 bool SM = 0; 68 bool SM = 0;
69 TXTM( Data.Description, Description_LE, SM ); 69 TXTM( Data.Description, Description_LE, SM );
70 70
@@ -77,7 +77,7 @@ bool ProfileEdit::commit( ProfileData_t & Data ) {
77} 77}
78 78
79void ProfileEdit::SLOT_Refresh( void ) { 79void ProfileEdit::SLOT_Refresh( void ) {
80 InterfaceInfo * II = Dev->assignedInterface(); 80 InterfaceInfo * II = NNI->connection()->assignedInterface();
81 NSResources->system().refreshStatistics( *II ); 81 NSResources->system().refreshStatistics( *II );
82 RcvBytes_LBL->setText( II->RcvBytes ); 82 RcvBytes_LBL->setText( II->RcvBytes );
83 SndBytes_LBL->setText( II->SndBytes ); 83 SndBytes_LBL->setText( II->SndBytes );
diff --git a/noncore/settings/networksettings2/profile/profileedit.h b/noncore/settings/networksettings2/profile/profileedit.h
index b186b58..9cde845 100644
--- a/noncore/settings/networksettings2/profile/profileedit.h
+++ b/noncore/settings/networksettings2/profile/profileedit.h
@@ -3,7 +3,7 @@
3 3
4#include <qtimer.h> 4#include <qtimer.h>
5class ANetNodeInstance; 5class ANetNodeInstance;
6class AsDevice; 6class RuntimeInfo;
7 7
8class ProfileEdit : public ProfileGUI { 8class ProfileEdit : public ProfileGUI {
9 9
@@ -13,8 +13,8 @@ public :
13 13
14 ProfileEdit( QWidget * parent, ANetNodeInstance * NNI ); 14 ProfileEdit( QWidget * parent, ANetNodeInstance * NNI );
15 QString acceptable( void ); 15 QString acceptable( void );
16 bool commit( ProfileData_t & Data ); 16 bool commit( ProfileData & Data );
17 void showData( ProfileData_t & Data ); 17 void showData( ProfileData & Data );
18 18
19public slots : 19public slots :
20 20
@@ -25,5 +25,5 @@ private :
25 25
26 QTimer RefreshTimer; 26 QTimer RefreshTimer;
27 ANetNodeInstance * NNI; 27 ANetNodeInstance * NNI;
28 AsDevice * Dev; 28 RuntimeInfo * Dev;
29}; 29};
diff --git a/noncore/settings/networksettings2/profile/profilerun.cpp b/noncore/settings/networksettings2/profile/profilerun.cpp
index 1a5b15b..ab57a00 100644
--- a/noncore/settings/networksettings2/profile/profilerun.cpp
+++ b/noncore/settings/networksettings2/profile/profilerun.cpp
@@ -2,66 +2,26 @@
2 2
3#include "profilerun.h" 3#include "profilerun.h"
4 4
5void ProfileRun::detectState( NodeCollection * NC ) { 5State_t ProfileRun::detectState( void ) {
6 if( Data->Disabled ) { 6 if( Data->Disabled ) {
7 Log(( "%s disabled\n", NC->name().latin1() )); 7 return Disabled;
8 NC->setCurrentState( Disabled ); 8 }
9 } else { 9 return Unknown;
10 Log(( "%s not disabled\n", NC->name().latin1() ));
11 // find next item in connection
12 // convert to runtime and ask to detect the state
13 netNode()->nextNode()->runtime()->detectState( NC );
14 }
15} 10}
16 11
17bool ProfileRun::setState( NodeCollection * NC, Action_t A, bool F ) { 12QString ProfileRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
18 ANetNodeInstance * NNNI; 13 owarn << "Profile " << Data->Disabled << oendl;
19 14 if( A == Disable ) {
20 NNNI = netNode()->nextNode(); 15 if( ! Data->Disabled ) {
21 switch ( A ) {
22 case Enable :
23 if( NC->currentState() == Disabled ) {
24 Data->Disabled = 0;
25 NC->setCurrentState( Off ); // at least
26 // ... but request deeper
27 NNNI->runtime()->detectState(NC);
28 }
29 return 1;
30 case Disable :
31 switch( NC->currentState() ) {
32 case IsUp :
33 case Available :
34 // bring Deactivate (will bring down)
35 if( ! NNNI->runtime()->setState(NC, Deactivate) )
36 return 0;
37 default :
38 break;
39 }
40 Data->Disabled = 1; 16 Data->Disabled = 1;
41 NC->setCurrentState( Disabled ); 17 NC->setModified( 1 );
42 return 1; 18 }
43 default : 19 } else if( A == Enable ) {
44 break; 20 if( Data->Disabled ) {
45 } 21 Data->Disabled = 0;
46 return NNNI->runtime()->setState(NC, A, F ); 22 NC->setModified( 1 );
47} 23 }
48
49bool ProfileRun::canSetState( State_t Curr, Action_t A ) {
50 RuntimeInfo * RI;
51 switch ( A ) {
52 case Enable :
53 case Disable :
54 // always possible
55 return 1;
56 default :
57 break;
58 } 24 }
59 RI = netNode()->nextNode()->runtime();
60 return ( Curr != Disabled ) ?
61 RI->canSetState(Curr, A) : 0;
62}
63 25
64bool ProfileRun::handlesInterface( const QString & S ) { 26 return QString();
65 // donno -> pass deeper
66 return netNode()->nextNode()->runtime()->handlesInterface(S);
67} 27}
diff --git a/noncore/settings/networksettings2/profile/profilerun.h b/noncore/settings/networksettings2/profile/profilerun.h
index 400b56c..2d48b15 100644
--- a/noncore/settings/networksettings2/profile/profilerun.h
+++ b/noncore/settings/networksettings2/profile/profilerun.h
@@ -1,32 +1,30 @@
1#ifndef PROFILERUN_H 1#ifndef PROFILERUN_H
2#define PROFILERUN_H 2#define PROFILERUN_H
3 3
4#include <asfullsetup.h> 4#include <netnode.h>
5#include "profiledata.h" 5#include "profiledata.h"
6 6
7class ProfileRun : public AsFullSetup { 7class ProfileRun : public RuntimeInfo {
8 8
9public : 9public :
10 10
11 ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) : 11 ProfileRun( ANetNodeInstance * NNI, ProfileData & D ) :
12 AsFullSetup( NNI ) 12 RuntimeInfo( NNI )
13 { Data = &D; } 13 { Data = &D; }
14 14
15 void detectState( NodeCollection * NC ); 15 virtual RuntimeInfo * fullSetup( void )
16 bool setState( NodeCollection * NC, Action_t A, bool ); 16 { return this; }
17 bool canSetState( State_t Curr, Action_t A );
18
19 bool handlesInterface( const QString & I );
20
21 virtual const QString & description( void ) 17 virtual const QString & description( void )
22 { return Data->Description; } 18 { return Data->Description; }
23
24 virtual AsFullSetup * asFullSetup( void )
25 { return (AsFullSetup *)this; }
26
27 virtual bool triggersVPN( void ) 19 virtual bool triggersVPN( void )
28 { return Data->TriggerVPN; } 20 { return Data->TriggerVPN; }
29 21
22 State_t detectState( void );
23
24protected :
25
26 QString setMyState( NodeCollection * , Action_t, bool );
27
30private : 28private :
31 29
32 ProfileData * Data; 30 ProfileData * Data;