summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/cable
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/cable') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.cpp9
-rw-r--r--noncore/settings/networksettings2/cable/cable_NN.h2
-rw-r--r--noncore/settings/networksettings2/cable/cable_NNI.cpp14
-rw-r--r--noncore/settings/networksettings2/cable/cable_NNI.h6
-rw-r--r--noncore/settings/networksettings2/cable/cabledata.h7
-rw-r--r--noncore/settings/networksettings2/cable/cableedit.cpp4
-rw-r--r--noncore/settings/networksettings2/cable/cableedit.h4
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.cpp18
-rw-r--r--noncore/settings/networksettings2/cable/cablerun.h18
-rw-r--r--noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control2
10 files changed, 40 insertions, 44 deletions
diff --git a/noncore/settings/networksettings2/cable/cable_NN.cpp b/noncore/settings/networksettings2/cable/cable_NN.cpp
index 38568df..dc4205c 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NN.cpp
@@ -2,12 +2,17 @@
2#include "cable_NNI.h" 2#include "cable_NNI.h"
3 3
4static const char * CableNeeds[] = 4static const char * CableNeeds[] =
5 { 0 5 { 0
6 }; 6 };
7 7
8static const char * CableProvides[] =
9 { "line",
10 0
11 };
12
8/** 13/**
9 * Constructor, find all of the possible interfaces 14 * Constructor, find all of the possible interfaces
10 */ 15 */
11CableNetNode::CableNetNode() : ANetNode(tr("Cable Connection")) { 16CableNetNode::CableNetNode() : ANetNode(tr("Cable Connection")) {
12} 17}
13 18
@@ -29,14 +34,14 @@ ANetNodeInstance * CableNetNode::createInstance( void ) {
29} 34}
30 35
31const char ** CableNetNode::needs( void ) { 36const char ** CableNetNode::needs( void ) {
32 return CableNeeds; 37 return CableNeeds;
33} 38}
34 39
35const char * CableNetNode::provides( void ) { 40const char ** CableNetNode::provides( void ) {
36 return "line"; 41 return CableProvides;
37} 42}
38 43
39void CableNetNode::setSpecificAttribute( QString & , QString & ) { 44void CableNetNode::setSpecificAttribute( QString & , QString & ) {
40} 45}
41 46
42void CableNetNode::saveSpecificAttribute( QTextStream & ) { 47void CableNetNode::saveSpecificAttribute( QTextStream & ) {
diff --git a/noncore/settings/networksettings2/cable/cable_NN.h b/noncore/settings/networksettings2/cable/cable_NN.h
index 5cc2b2d..8d649cc 100644
--- a/noncore/settings/networksettings2/cable/cable_NN.h
+++ b/noncore/settings/networksettings2/cable/cable_NN.h
@@ -17,13 +17,13 @@ public:
17 virtual const QString pixmapName() 17 virtual const QString pixmapName()
18 { return "Devices/cable"; } 18 { return "Devices/cable"; }
19 19
20 virtual const QString nodeDescription() ; 20 virtual const QString nodeDescription() ;
21 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
27 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 27 virtual void setSpecificAttribute( QString & Attr, QString & Value );
28 virtual void saveSpecificAttribute( QTextStream & TS ); 28 virtual void saveSpecificAttribute( QTextStream & TS );
29}; 29};
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.cpp b/noncore/settings/networksettings2/cable/cable_NNI.cpp
index 4bd9421..12a00a2 100644
--- a/noncore/settings/networksettings2/cable/cable_NNI.cpp
+++ b/noncore/settings/networksettings2/cable/cable_NNI.cpp
@@ -46,31 +46,29 @@ void ACable::saveSpecificAttribute( QTextStream & TS ) {
46 TS << "hardwarecontrol=" << 46 TS << "hardwarecontrol=" <<
47 ((Data.HardwareControl) ? "yes" : "no") << endl; 47 ((Data.HardwareControl) ? "yes" : "no") << endl;
48 TS << "softwarecontrol=" << 48 TS << "softwarecontrol=" <<
49 ((Data.SoftwareControl) ? "yes" : "no") << endl; 49 ((Data.SoftwareControl) ? "yes" : "no") << endl;
50} 50}
51 51
52short ACable::generateFileEmbedded( const QString & ID, 52short ACable::generateFileEmbedded( SystemFile & SF,
53 const QString & Path,
54 QTextStream & TS,
55 long DevNr ) { 53 long DevNr ) {
56 short rvl, rvd; 54 short rvl, rvd;
57 55
58 rvl = 1; 56 rvl = 1;
59 if( ID == "peers" ) { 57 if( SF.name() == "peers" ) {
60 TS << Data.Device 58 SF << Data.Device
61 << endl; 59 << endl;
62 TS << Data.Speed 60 SF << Data.Speed
63 << endl; 61 << endl;
64 TS << "lock " 62 SF << "lock "
65 << Data.LockFile 63 << Data.LockFile
66 << endl; 64 << endl;
67 rvl = 0; 65 rvl = 0;
68 } 66 }
69 67
70 rvd = ANetNodeInstance::generateFileEmbedded( ID, Path, TS, DevNr ); 68 rvd = ANetNodeInstance::generateFileEmbedded( SF, DevNr );
71 return (rvd == 2 || rvl == 2 ) ? 2 : 69 return (rvd == 2 || rvl == 2 ) ? 2 :
72 (rvd == 0 || rvl == 0 ) ? 0 : 1; 70 (rvd == 0 || rvl == 0 ) ? 0 : 1;
73} 71}
74 72
75QWidget * ACable::edit( QWidget * parent ) { 73QWidget * ACable::edit( QWidget * parent ) {
76 GUI = new CableEdit( parent ); 74 GUI = new CableEdit( parent );
diff --git a/noncore/settings/networksettings2/cable/cable_NNI.h b/noncore/settings/networksettings2/cable/cable_NNI.h
index d06cbbe..18a52de 100644
--- a/noncore/settings/networksettings2/cable/cable_NNI.h
+++ b/noncore/settings/networksettings2/cable/cable_NNI.h
@@ -23,24 +23,22 @@ public :
23 QString acceptable( void ); 23 QString acceptable( void );
24 void commit( void ); 24 void commit( void );
25 25
26 virtual void * data( void ) 26 virtual void * data( void )
27 { return (void *)&Data; } 27 { return (void *)&Data; }
28 28
29 short generateFileEmbedded( const QString & ID, 29 short generateFileEmbedded( SystemFile & Sf,
30 const QString & Path,
31 QTextStream & TS,
32 long DevNr ); 30 long DevNr );
33protected : 31protected :
34 32
35 virtual void setSpecificAttribute( QString & Attr, QString & Value ); 33 virtual void setSpecificAttribute( QString & Attr, QString & Value );
36 virtual void saveSpecificAttribute( QTextStream & TS ); 34 virtual void saveSpecificAttribute( QTextStream & TS );
37 35
38private : 36private :
39 37
40 CableEdit * GUI; 38 CableEdit * GUI;
41 CableData_t Data; 39 CableData Data;
42 CableRun * RT; 40 CableRun * RT;
43 41
44}; 42};
45 43
46#endif 44#endif
diff --git a/noncore/settings/networksettings2/cable/cabledata.h b/noncore/settings/networksettings2/cable/cabledata.h
index c449d96..ea81f8d 100644
--- a/noncore/settings/networksettings2/cable/cabledata.h
+++ b/noncore/settings/networksettings2/cable/cabledata.h
@@ -1,18 +1,21 @@
1#ifndef CABLE_DATA_H 1#ifndef CABLE_DATA_H
2#define CABLE_DATA_H 2#define CABLE_DATA_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5 5
6typedef struct CableData { 6class CableData {
7
8public :
9
7 QString Device; 10 QString Device;
8 QString LockFile; 11 QString LockFile;
9 long Speed; 12 long Speed;
10 short Parity; 13 short Parity;
11 short DataBits; 14 short DataBits;
12 short StopBits; 15 short StopBits;
13 bool HardwareControl; 16 bool HardwareControl;
14 bool SoftwareControl; 17 bool SoftwareControl;
15 18
16} CableData_t; 19};
17 20
18#endif 21#endif
diff --git a/noncore/settings/networksettings2/cable/cableedit.cpp b/noncore/settings/networksettings2/cable/cableedit.cpp
index 6e1a13b..4e57845 100644
--- a/noncore/settings/networksettings2/cable/cableedit.cpp
+++ b/noncore/settings/networksettings2/cable/cableedit.cpp
@@ -14,13 +14,13 @@ static long SpeedTable[] = {
14 3500000, 4000000, -1 14 3500000, 4000000, -1
15}; 15};
16 16
17CableEdit::CableEdit( QWidget * Parent ) : CableGUI( Parent ) { 17CableEdit::CableEdit( QWidget * Parent ) : CableGUI( Parent ) {
18} 18}
19 19
20void CableEdit::showData( CableData_t & D ) { 20void CableEdit::showData( CableData & D ) {
21 DeviceFile_LE->setText( D.Device ); 21 DeviceFile_LE->setText( D.Device );
22 LockFile_LE->setText( D.LockFile ); 22 LockFile_LE->setText( D.LockFile );
23 for( long * Run = SpeedTable; *Run != -1; *Run ++ ) { 23 for( long * Run = SpeedTable; *Run != -1; *Run ++ ) {
24 if( *Run == D.Speed ) { 24 if( *Run == D.Speed ) {
25 Speed_CB->setCurrentItem( 25 Speed_CB->setCurrentItem(
26 ((long)(Run)-(long)(SpeedTable))/sizeof(long) ); 26 ((long)(Run)-(long)(SpeedTable))/sizeof(long) );
@@ -37,13 +37,13 @@ void CableEdit::showData( CableData_t & D ) {
37QString CableEdit::acceptable( void ) { 37QString CableEdit::acceptable( void ) {
38 if( DeviceFile_LE->text().isEmpty() ) 38 if( DeviceFile_LE->text().isEmpty() )
39 return tr("Device filename needed"); 39 return tr("Device filename needed");
40 return QString(); 40 return QString();
41} 41}
42 42
43bool CableEdit::commit( CableData_t & D ) { 43bool CableEdit::commit( CableData & D ) {
44 bool SM = 0; 44 bool SM = 0;
45 45
46 TXTM( D.Device, DeviceFile_LE, SM ); 46 TXTM( D.Device, DeviceFile_LE, SM );
47 TXTM( D.LockFile, LockFile_LE, SM ); 47 TXTM( D.LockFile, LockFile_LE, SM );
48 48
49 for( long * Run = SpeedTable; *Run != -1; *Run ++ ) { 49 for( long * Run = SpeedTable; *Run != -1; *Run ++ ) {
diff --git a/noncore/settings/networksettings2/cable/cableedit.h b/noncore/settings/networksettings2/cable/cableedit.h
index ffacc61..ad1e832 100644
--- a/noncore/settings/networksettings2/cable/cableedit.h
+++ b/noncore/settings/networksettings2/cable/cableedit.h
@@ -4,9 +4,9 @@
4class CableEdit : public CableGUI { 4class CableEdit : public CableGUI {
5 5
6public : 6public :
7 7
8 CableEdit( QWidget * parent ); 8 CableEdit( QWidget * parent );
9 QString acceptable( void ); 9 QString acceptable( void );
10 bool commit( CableData_t & D ); 10 bool commit( CableData & D );
11 void showData( CableData_t & D ); 11 void showData( CableData & D );
12}; 12};
diff --git a/noncore/settings/networksettings2/cable/cablerun.cpp b/noncore/settings/networksettings2/cable/cablerun.cpp
index 85660f6..7a8deb9 100644
--- a/noncore/settings/networksettings2/cable/cablerun.cpp
+++ b/noncore/settings/networksettings2/cable/cablerun.cpp
@@ -1,30 +1,22 @@
1#include <fcntl.h> 1#include <fcntl.h>
2#include <unistd.h> 2#include <unistd.h>
3#include "cablerun.h" 3#include "cablerun.h"
4 4
5void CableRun::detectState( NodeCollection * NC ) { 5State_t CableRun::detectState( void ) {
6 6
7 int fd = open( Data->Device.latin1(), O_RDWR ); 7 int fd = open( Data->Device.latin1(), O_RDWR );
8 8
9 if( fd < 0 ) { 9 if( fd < 0 ) {
10 NC->setCurrentState( Unavailable ); 10 return Unavailable;
11 } 11 }
12 close( fd ); 12 close( fd );
13 NC->setCurrentState( Available ); 13 return Available;
14} 14}
15 15
16bool CableRun::setState( NodeCollection * NC, Action_t A, bool ) { 16QString CableRun::setMyState( NodeCollection *, Action_t , bool ) {
17 if( A == Activate ) { 17 return QString();
18 detectState(NC);
19 return (NC->currentState() == Available);
20 }
21 return 1;
22}
23
24bool CableRun::canSetState( State_t , Action_t ) {
25 return 1;
26} 18}
27 19
28QString CableRun::deviceFile( void ) { 20QString CableRun::deviceFile( void ) {
29 return Data->Device; 21 return Data->Device;
30} 22}
diff --git a/noncore/settings/networksettings2/cable/cablerun.h b/noncore/settings/networksettings2/cable/cablerun.h
index 20608f6..41aea01 100644
--- a/noncore/settings/networksettings2/cable/cablerun.h
+++ b/noncore/settings/networksettings2/cable/cablerun.h
@@ -1,26 +1,26 @@
1#include <asline.h> 1#include <netnode.h>
2#include "cabledata.h" 2#include "cabledata.h"
3 3
4class CableRun : public AsLine { 4class CableRun : public RuntimeInfo {
5 5
6public : 6public :
7 7
8 CableRun( ANetNodeInstance * NNI, 8 CableRun( ANetNodeInstance * NNI,
9 CableData_t & D ) : AsLine( NNI ) 9 CableData & D ) : RuntimeInfo( NNI )
10 { Data = &D; } 10 { Data = &D; }
11 11
12 virtual AsLine * asLine( void ) 12 virtual RuntimeInfo * line( void )
13 { return (AsLine *)this; } 13 { return this; }
14 14
15 virtual QString deviceFile( void ); 15 virtual QString deviceFile( void );
16 16
17 State_t detectState( void );
18
17protected : 19protected :
18 20
19 void detectState( NodeCollection * NC ); 21 QString setMyState( NodeCollection * , Action_t, bool );
20 bool setState( NodeCollection * NC, Action_t A, bool Force );
21 bool canSetState( State_t Curr, Action_t A );
22 22
23private : 23private :
24 24
25 CableData_t * Data; 25 CableData * Data;
26}; 26};
diff --git a/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control b/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control
index 79520e2..dd08279 100644
--- a/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control
+++ b/noncore/settings/networksettings2/cable/opie-networksettings2plugin-cable.control
@@ -1,7 +1,7 @@
1Package: opie-networksettingsplugin2-bluetooth 1Package: opie-networksettings2plugin-cable
2Files: plugins/networksettings2/libcable.so* 2Files: plugins/networksettings2/libcable.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