summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/main.cpp12
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.cpp2
-rw-r--r--noncore/settings/networksettings2/opie-networksettings2.control2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDevice.h4
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDriver.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTIcons.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTInquiry.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTPeer.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTSDPService.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTUUID.h2
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp14
13 files changed, 25 insertions, 25 deletions
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp
index 8487e3e..973b4b7 100644
--- a/noncore/settings/networksettings2/main.cpp
+++ b/noncore/settings/networksettings2/main.cpp
@@ -1,175 +1,163 @@
1#include "nsdata.h" 1#include "nsdata.h"
2#include "activateprofile.h" 2#include "activateprofile.h"
3#include "activatevpn.h" 3#include "activatevpn.h"
4#include "networksettings.h" 4#include "networksettings.h"
5 5
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
8 8
9#include <opie2/oapplicationfactory.h> 9#include <opie2/oapplicationfactory.h>
10using namespace Opie::Core; 10using namespace Opie::Core;
11 11
12#ifdef GONE 12#ifdef GONE
13 13
14OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> ) 14OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> )
15 15
16#else 16#else
17 17
18// just standard GUI 18// just standard GUI
19#define ACT_GUI 0 19#define ACT_GUI 0
20// used by interfaces to request for allow of up/down 20// used by interfaces to request for allow of up/down
21#define ACT_REQUEST 1 21#define ACT_REQUEST 1
22// regenerate config files 22// regenerate config files
23#define ACT_REGEN 2 23#define ACT_REGEN 2
24// used by interfaces to request user prompt 24// used by interfaces to request user prompt
25#define ACT_PROMPT 3 25#define ACT_PROMPT 3
26// used by interfaces to trigger VPN 26// used by interfaces to trigger VPN
27#define ACT_VPN 4 27#define ACT_VPN 4
28// activate opietooth 28// activate opietooth
29#define ACT_OT 5 29#define ACT_OT 5
30 30
31// include Opietooth GUI 31// include Opietooth GUI
32#include <opietooth2/Opietooth.h> 32#include <opietooth2/Opietooth.h>
33using namespace Opietooth2; 33using namespace Opietooth2;
34 34
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qframe.h> 37#include <qframe.h>
38#include <qlabel.h> 38#include <qlabel.h>
39 39
40int main( int argc, char * argv[] ) { 40int main( int argc, char * argv[] ) {
41 int rv = 0; 41 int rv = 0;
42 int Action = ACT_GUI; 42 int Action = ACT_GUI;
43 // could be overruled by -qws 43 // could be overruled by -qws
44 QApplication::Type GuiType = QApplication::GuiClient; 44 QApplication::Type GuiType = QApplication::GuiClient;
45 45
46#ifdef _WS_QWS_
47 QPEApplication * TheApp; 46 QPEApplication * TheApp;
48#else
49 QApplication * TheApp;
50#endif
51 47
52 for ( int i = 1; i < argc; i ++ ) { 48 for ( int i = 1; i < argc; i ++ ) {
53 int rmv; 49 int rmv;
54 rmv = 0; 50 rmv = 0;
55 if( strcmp( argv[i], "--regen" ) == 0 ) { 51 if( strcmp( argv[i], "--regen" ) == 0 ) {
56 Action = ACT_REGEN; 52 Action = ACT_REGEN;
57 GuiType = QApplication::Tty; 53 GuiType = QApplication::Tty;
58 rmv = 1; 54 rmv = 1;
59 } else if( strcmp( argv[i], "--prompt" ) == 0 ) { 55 } else if( strcmp( argv[i], "--prompt" ) == 0 ) {
60 Action = ACT_PROMPT; 56 Action = ACT_PROMPT;
61 rmv = 1; 57 rmv = 1;
62 } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) { 58 } else if( strcmp( argv[i], "--triggervpn" ) == 0 ) {
63 Action = ACT_VPN; 59 Action = ACT_VPN;
64 rmv = 1; 60 rmv = 1;
65 } else if( strcmp( argv[i], "--opietooth" ) == 0 ) { 61 } else if( strcmp( argv[i], "--opietooth" ) == 0 ) {
66 Action = ACT_OT; 62 Action = ACT_OT;
67 rmv = 1; 63 rmv = 1;
68 } 64 }
69 if( rmv ) { 65 if( rmv ) {
70 memmove( argv+i, argv+i+rmv, 66 memmove( argv+i, argv+i+rmv,
71 sizeof( char * ) * (argc-i-rmv) ); 67 sizeof( char * ) * (argc-i-rmv) );
72 i --; 68 i --;
73 argc -= rmv; 69 argc -= rmv;
74 } 70 }
75 } 71 }
76 72
77 if( strstr( argv[0], "-request" ) ) { 73 if( strstr( argv[0], "-request" ) ) {
78 // called from system to request something 74 // called from system to request something
79 GuiType = QApplication::Tty; 75 GuiType = QApplication::Tty;
80 Action = ACT_REQUEST; 76 Action = ACT_REQUEST;
81 Log(("Request : %s\n", argv[1] )); 77 Log(("Request : %s\n", argv[1] ));
82 } else if( strstr( argv[0], "-opietooth" ) ) { 78 } else if( strstr( argv[0], "-opietooth" ) ) {
83 Action = ACT_OT; 79 Action = ACT_OT;
84 } 80 }
85 81
86 // Start Qt 82 // Start Qt
87#ifdef _WS_QWS_
88 // because QPEApplication does not handle GuiType well 83 // because QPEApplication does not handle GuiType well
89 if( GuiType == QApplication::Tty ) { 84 if( GuiType == QApplication::Tty ) {
90 // this cast is NOT correct but we do not use 85 // this cast is NOT correct but we do not use
91 // TheApp anymore ... 86 // TheApp anymore ...
92 TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType ); 87 TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType );
93 } else { 88 } else {
94 TheApp = new QPEApplication( argc, argv, GuiType ); 89 TheApp = new QPEApplication( argc, argv, GuiType );
95 } 90 }
96#else
97 TheApp = new QApplication( argc, argv, GuiType );
98#endif
99 91
100 // init qt with app widget 92 // init qt with app widget
101 93
102 switch( Action ) { 94 switch( Action ) {
103 case ACT_REQUEST : 95 case ACT_REQUEST :
104 { NetworkSettingsData NS; 96 { NetworkSettingsData NS;
105 if( NS.canStart( argv[1] ) ) { 97 if( NS.canStart( argv[1] ) ) {
106 QStringList S; 98 QStringList S;
107 S << QPEApplication::qpeDir() + "/bin/networksettings2"; 99 S << QPEApplication::qpeDir() + "/bin/networksettings2";
108 S << "networksettings2"; 100 S << "networksettings2";
109 S << "--prompt"; 101 S << "--prompt";
110 S << argv[1]; 102 S << argv[1];
111 NSResources->system().execAsUser( S ); 103 NSResources->system().execAsUser( S );
112 Log(("FAILED %s-cNN-allowed\n", argv[1] )); 104 Log(("FAILED %s-cNN-allowed\n", argv[1] ));
113 // if we come here , failed 105 // if we come here , failed
114 printf( "%s-cNN-disallowed", argv[1] ); 106 printf( "%s-cNN-disallowed", argv[1] );
115 } 107 }
116 } 108 }
117 break; 109 break;
118 case ACT_REGEN : 110 case ACT_REGEN :
119 { NetworkSettingsData NS; 111 { NetworkSettingsData NS;
120 QString S= NS.generateSettings(); 112 QString S= NS.generateSettings();
121 // regen returns 0 if OK 113 // regen returns 0 if OK
122 rv = ( S.isEmpty() ) ? 0 : 1; 114 rv = ( S.isEmpty() ) ? 0 : 1;
123 } 115 }
124 break; 116 break;
125 case ACT_PROMPT : 117 case ACT_PROMPT :
126 { ActivateProfile AP(argv[1]); 118 { ActivateProfile AP(argv[1]);
127 if( AP.exec() == QDialog::Accepted ) { 119 if( AP.exec() == QDialog::Accepted ) {
128 Log(("%s-c%ld-allowed\n", 120 Log(("%s-c%ld-allowed\n",
129 argv[1], AP.selectedProfile() )); 121 argv[1], AP.selectedProfile() ));
130 printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); 122 printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() );
131 } else { 123 } else {
132 Log(("%s-c%NN-disallowed\n", argv[1] )); 124 Log(("%s-c%NN-disallowed\n", argv[1] ));
133 printf( "%s-cNN-disallowed", argv[1] ); 125 printf( "%s-cNN-disallowed", argv[1] );
134 } 126 }
135 } 127 }
136 break; 128 break;
137 case ACT_VPN : 129 case ACT_VPN :
138 { ActivateVPN AVPN; 130 { ActivateVPN AVPN;
139 AVPN.exec(); 131 AVPN.exec();
140 } 132 }
141 break; 133 break;
142 case ACT_GUI : 134 case ACT_GUI :
143 case ACT_OT : 135 case ACT_OT :
144 { QWidget * W; 136 { QWidget * W;
145 137
146 if( Action == ACT_OT ) { 138 if( Action == ACT_OT ) {
147 W = new OTMain( 0 ); 139 W = new OTMain( 0 );
148 } else { 140 } else {
149 W = new NetworkSettings(0); 141 W = new NetworkSettings(0);
150 } 142 }
151 TheApp->setMainWidget( W ); 143 TheApp->setMainWidget( W );
152 144
153 W->show(); 145 W->show();
154#ifdef _WS_QWS_
155 W->showMaximized(); 146 W->showMaximized();
156#else
157 W->resize( W->sizeHint() );
158#endif
159 rv = TheApp->exec(); 147 rv = TheApp->exec();
160 148
161 delete W; 149 delete W;
162 } 150 }
163 break; 151 break;
164 } 152 }
165 153
166 LogClose(); 154 LogClose();
167 155
168 return rv; 156 return rv;
169} 157}
170 158
171#endif 159#endif
172 160
173 161
174// main.cpp 162// main.cpp
175 163
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
index 82fd43a..8deef94 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
@@ -1,235 +1,235 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qfileinfo.h> 3#include <qfileinfo.h>
4#include <qmessagebox.h> 4#include <qmessagebox.h>
5#include <qfile.h> 5#include <qfile.h>
6#include <qtextstream.h> 6#include <qtextstream.h>
7 7
8#include "resources.h" 8#include "resources.h"
9#include "systemfile.h" 9#include "systemfile.h"
10 10
11#define TEMPLATEDIR "networktemplates/" 11#define TEMPLATEDIR "NS2templates/"
12QString TemplDir; 12QString TemplDir;
13 13
14SystemFile::SystemFile( const QString & N, 14SystemFile::SystemFile( const QString & N,
15 const QString & P, 15 const QString & P,
16 bool KDI ){ 16 bool KDI ){
17 Name = N; 17 Name = N;
18 Path = P; 18 Path = P;
19 InAppend = 0; 19 InAppend = 0;
20 F = 0; 20 F = 0;
21 // get template info 21 // get template info
22 { QString S; 22 { QString S;
23 QFileInfo FI; 23 QFileInfo FI;
24 24
25 // find location of templates 25 // find location of templates
26 TemplDir = QPEApplication::qpeDir() + "etc/" + TEMPLATEDIR; 26 TemplDir = QPEApplication::qpeDir() + "etc/" + TEMPLATEDIR;
27 FI.setFile( TemplDir ); 27 FI.setFile( TemplDir );
28 if( ! FI.isDir() ) { 28 if( ! FI.isDir() ) {
29 // try current dir 29 // try current dir
30 TemplDir = "./" TEMPLATEDIR; 30 TemplDir = "./" TEMPLATEDIR;
31 FI.setFile( TemplDir ); 31 FI.setFile( TemplDir );
32 if( ! FI.isDir() ) { 32 if( ! FI.isDir() ) {
33 hasPreSection = 33 hasPreSection =
34 hasPostSection = 34 hasPostSection =
35 hasPreNodeSection = 35 hasPreNodeSection =
36 hasPostNodeSection = 36 hasPostNodeSection =
37 hasPreDeviceSection = 37 hasPreDeviceSection =
38 hasPostDeviceSection = 0; 38 hasPostDeviceSection = 0;
39 return; 39 return;
40 } 40 }
41 } 41 }
42 42
43 // have found location 43 // have found location
44 S = TemplDir + Name + "/presection"; 44 S = TemplDir + Name + "/presection";
45 FI.setFile( S ); 45 FI.setFile( S );
46 hasPreSection = ( FI.exists() && FI.isReadable() ); 46 hasPreSection = ( FI.exists() && FI.isReadable() );
47 S = TemplDir + Name + "/postsection"; 47 S = TemplDir + Name + "/postsection";
48 FI.setFile( S ); 48 FI.setFile( S );
49 hasPostSection = ( FI.exists() && FI.isReadable() ); 49 hasPostSection = ( FI.exists() && FI.isReadable() );
50 S = TemplDir + Name + "/prenodesection"; 50 S = TemplDir + Name + "/prenodesection";
51 FI.setFile( S ); 51 FI.setFile( S );
52 hasPreNodeSection = ( FI.exists() && FI.isReadable() ); 52 hasPreNodeSection = ( FI.exists() && FI.isReadable() );
53 S = TemplDir + Name + "/postnodesection"; 53 S = TemplDir + Name + "/postnodesection";
54 FI.setFile( S ); 54 FI.setFile( S );
55 hasPostNodeSection = ( FI.exists() && FI.isReadable() ); 55 hasPostNodeSection = ( FI.exists() && FI.isReadable() );
56 S = TemplDir + Name + "/predevicesection"; 56 S = TemplDir + Name + "/predevicesection";
57 FI.setFile( S ); 57 FI.setFile( S );
58 hasPreDeviceSection = ( FI.exists() && FI.isReadable() ); 58 hasPreDeviceSection = ( FI.exists() && FI.isReadable() );
59 S = TemplDir + Name + "/postdevicesection"; 59 S = TemplDir + Name + "/postdevicesection";
60 FI.setFile( S ); 60 FI.setFile( S );
61 hasPostDeviceSection = ( FI.exists() && FI.isReadable() ); 61 hasPostDeviceSection = ( FI.exists() && FI.isReadable() );
62 } 62 }
63 63
64 KnowsDeviceInstances = KDI; 64 KnowsDeviceInstances = KDI;
65} 65}
66 66
67SystemFile::SystemFile( const QString & N, bool KDI ){ 67SystemFile::SystemFile( const QString & N, bool KDI ){
68 Name = N; 68 Name = N;
69 Path = ""; 69 Path = "";
70 InAppend = 0; 70 InAppend = 0;
71 F =0; 71 F =0;
72 KnowsDeviceInstances = KDI; 72 KnowsDeviceInstances = KDI;
73 hasPreSection = 73 hasPreSection =
74 hasPostSection = 74 hasPostSection =
75 hasPreNodeSection = 75 hasPreNodeSection =
76 hasPostNodeSection = 76 hasPostNodeSection =
77 hasPreDeviceSection = 77 hasPreDeviceSection =
78 hasPostDeviceSection = 0; 78 hasPostDeviceSection = 0;
79} 79}
80 80
81SystemFile::~SystemFile( void ) { 81SystemFile::~SystemFile( void ) {
82 close(); 82 close();
83} 83}
84 84
85bool SystemFile::open( void ) { 85bool SystemFile::open( void ) {
86 QString Prefix = getenv( "NS2OUTPUTTO" ); 86 QString Prefix = getenv( "NS2OUTPUTTO" );
87 87
88 if( Prefix != "stderr" /* && Name != "interfaces" */ ) { 88 if( Prefix != "stderr" /* && Name != "interfaces" */ ) {
89 // generate files where the need to be 89 // generate files where the need to be
90 if( F ) { 90 if( F ) {
91 F->close(); 91 F->close();
92 delete F; 92 delete F;
93 } 93 }
94 94
95 F = new QFile( Prefix + Path + ((InAppend)?"":"bup") ); 95 F = new QFile( Prefix + Path + ((InAppend)?"":"bup") );
96 Log(( "Open systemfile %s\n", F->name().latin1() )); 96 Log(( "Open systemfile %s\n", F->name().latin1() ));
97 if( ! F->open( ((InAppend)?IO_Append : 0 ) | IO_WriteOnly ) ) { 97 if( ! F->open( ((InAppend)?IO_Append : 0 ) | IO_WriteOnly ) ) {
98 return 0; 98 return 0;
99 } 99 }
100 } else { 100 } else {
101 if( ! F ) { 101 if( ! F ) {
102 owarn << "!!!!!!!!!!!!!!!!!! " << oendl; 102 owarn << "!!!!!!!!!!!!!!!!!! " << oendl;
103 owarn << "!!!! TESTMODE !!!!" << oendl; 103 owarn << "!!!! TESTMODE !!!!" << oendl;
104 owarn << "!!!!!!!!!!!!!!!!!! " << oendl; 104 owarn << "!!!!!!!!!!!!!!!!!! " << oendl;
105 owarn << "!!!!" << oendl; 105 owarn << "!!!!" << oendl;
106 owarn << "!!!! GENERATE " << Path << oendl; 106 owarn << "!!!! GENERATE " << Path << oendl;
107 if( InAppend ) { 107 if( InAppend ) {
108 owarn << "!!!! In APPEND mode" << oendl; 108 owarn << "!!!! In APPEND mode" << oendl;
109 } 109 }
110 owarn << "!!!!" << oendl; 110 owarn << "!!!!" << oendl;
111 owarn << "!!!!!!!!!!!!!!!!!!" << oendl; 111 owarn << "!!!!!!!!!!!!!!!!!!" << oendl;
112 112
113 F = new QFile(); 113 F = new QFile();
114 F->open( IO_WriteOnly, stderr ); 114 F->open( IO_WriteOnly, stderr );
115 } 115 }
116 } 116 }
117 setDevice( F ); 117 setDevice( F );
118 return 1; 118 return 1;
119} 119}
120 120
121bool SystemFile::close( void ) { 121bool SystemFile::close( void ) {
122 if( ! F || ! F->isOpen() ) { 122 if( ! F || ! F->isOpen() ) {
123 return 1 ; 123 return 1 ;
124 } 124 }
125 125
126 QString Prefix = getenv( "NS2OUTPUTTO" ); 126 QString Prefix = getenv( "NS2OUTPUTTO" );
127 127
128 if( Prefix == "stderr" ) { 128 if( Prefix == "stderr" ) {
129 return 1; 129 return 1;
130 } 130 }
131 131
132 QString OldP = Prefix + Path + "bup"; 132 QString OldP = Prefix + Path + "bup";
133 133
134 F->close(); 134 F->close();
135 delete F; 135 delete F;
136 F = 0; 136 F = 0;
137 137
138 if( ! InAppend ) { 138 if( ! InAppend ) {
139 owarn << "Rename " << OldP << " to " << Path << oendl; 139 owarn << "Rename " << OldP << " to " << Path << oendl;
140 return ( rename( OldP.latin1(), Path.latin1() ) >= 0 ); 140 return ( rename( OldP.latin1(), Path.latin1() ) >= 0 );
141 } 141 }
142 return 1; 142 return 1;
143} 143}
144 144
145bool SystemFile::preSection( void ) { 145bool SystemFile::preSection( void ) {
146 if( hasPreSection ) { 146 if( hasPreSection ) {
147 QFile Fl( TemplDir + Name + "/presection" ); 147 QFile Fl( TemplDir + Name + "/presection" );
148 if( ! Fl.open( IO_ReadOnly ) ) 148 if( ! Fl.open( IO_ReadOnly ) )
149 return 0; // error 149 return 0; // error
150 // copy file to this file 150 // copy file to this file
151 F->writeBlock( Fl.readAll() ); 151 F->writeBlock( Fl.readAll() );
152 } 152 }
153 return 1; 153 return 1;
154} 154}
155 155
156bool SystemFile::postSection( void ) { 156bool SystemFile::postSection( void ) {
157 if( hasPostSection ) { 157 if( hasPostSection ) {
158 QFile Fl( TemplDir + Name + "/postsection" ); 158 QFile Fl( TemplDir + Name + "/postsection" );
159 if( ! Fl.open( IO_ReadOnly ) ) 159 if( ! Fl.open( IO_ReadOnly ) )
160 return 0; // error 160 return 0; // error
161 // copy file to this file 161 // copy file to this file
162 F->writeBlock( Fl.readAll() ); 162 F->writeBlock( Fl.readAll() );
163 } 163 }
164 return 1; 164 return 1;
165} 165}
166 166
167bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { 167bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) {
168 if( hasPreNodeSection ) { 168 if( hasPreNodeSection ) {
169 QFile Fl( TemplDir + Name + "/prenodesection" ); 169 QFile Fl( TemplDir + Name + "/prenodesection" );
170 if( ! Fl.open( IO_ReadOnly ) ) 170 if( ! Fl.open( IO_ReadOnly ) )
171 return 0; // error 171 return 0; // error
172 QTextStream TX( &Fl ); 172 QTextStream TX( &Fl );
173 QString Out; 173 QString Out;
174 QString S = TX.readLine(); 174 QString S = TX.readLine();
175 while( ! TX.eof() ) { 175 while( ! TX.eof() ) {
176 Out = S. 176 Out = S.
177 arg(NNI->nodeClass()->name()); 177 arg(NNI->nodeClass()->name());
178 (*this) << Out << endl; 178 (*this) << Out << endl;
179 S = TX.readLine(); 179 S = TX.readLine();
180 } 180 }
181 } 181 }
182 return 1; 182 return 1;
183} 183}
184 184
185bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) { 185bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) {
186 if( hasPostNodeSection ) { 186 if( hasPostNodeSection ) {
187 QFile Fl( TemplDir + Name + "/postnodesection" ); 187 QFile Fl( TemplDir + Name + "/postnodesection" );
188 if( ! Fl.open( IO_ReadOnly ) ) 188 if( ! Fl.open( IO_ReadOnly ) )
189 return 0; // error 189 return 0; // error
190 QTextStream TX( &Fl ); 190 QTextStream TX( &Fl );
191 QString Out; 191 QString Out;
192 QString S = TX.readLine(); 192 QString S = TX.readLine();
193 while( ! TX.eof() ) { 193 while( ! TX.eof() ) {
194 Out = S. 194 Out = S.
195 arg(NNI->name()); 195 arg(NNI->name());
196 (*this) << Out << endl; 196 (*this) << Out << endl;
197 S = TX.readLine(); 197 S = TX.readLine();
198 } 198 }
199 } 199 }
200 return 1; 200 return 1;
201} 201}
202 202
203bool SystemFile::preDeviceSection( ANetNode * NN ) { 203bool SystemFile::preDeviceSection( ANetNode * NN ) {
204 if( hasPreDeviceSection ) { 204 if( hasPreDeviceSection ) {
205 QFile Fl( TemplDir + Name + "/predevicesection" ); 205 QFile Fl( TemplDir + Name + "/predevicesection" );
206 if( ! Fl.open( IO_ReadOnly ) ) 206 if( ! Fl.open( IO_ReadOnly ) )
207 return 0; // error 207 return 0; // error
208 QTextStream TX( &Fl ); 208 QTextStream TX( &Fl );
209 QString Out; 209 QString Out;
210 QString S = TX.readLine(); 210 QString S = TX.readLine();
211 while( ! TX.eof() ) { 211 while( ! TX.eof() ) {
212 Out = S.arg(NN->name()); 212 Out = S.arg(NN->name());
213 (*this) << Out << endl; 213 (*this) << Out << endl;
214 S = TX.readLine(); 214 S = TX.readLine();
215 } 215 }
216 } 216 }
217 return 1; 217 return 1;
218} 218}
219 219
220bool SystemFile::postDeviceSection( ANetNode * NN ) { 220bool SystemFile::postDeviceSection( ANetNode * NN ) {
221 if( hasPostDeviceSection ) { 221 if( hasPostDeviceSection ) {
222 QFile Fl( TemplDir + Name + "/postdevicesection" ); 222 QFile Fl( TemplDir + Name + "/postdevicesection" );
223 if( ! Fl.open( IO_ReadOnly ) ) 223 if( ! Fl.open( IO_ReadOnly ) )
224 return 0; // error 224 return 0; // error
225 QTextStream TX( &Fl ); 225 QTextStream TX( &Fl );
226 QString Out; 226 QString Out;
227 QString S = TX.readLine(); 227 QString S = TX.readLine();
228 while( ! TX.eof() ) { 228 while( ! TX.eof() ) {
229 Out = S.arg(NN->name()); 229 Out = S.arg(NN->name());
230 (*this) << Out << endl; 230 (*this) << Out << endl;
231 S = TX.readLine(); 231 S = TX.readLine();
232 } 232 }
233 } 233 }
234 return 1; 234 return 1;
235} 235}
diff --git a/noncore/settings/networksettings2/opie-networksettings2.control b/noncore/settings/networksettings2/opie-networksettings2.control
index 874833c..a79a740 100644
--- a/noncore/settings/networksettings2/opie-networksettings2.control
+++ b/noncore/settings/networksettings2/opie-networksettings2.control
@@ -1,10 +1,10 @@
1Package: opie-networksettings2 1Package: opie-networksettings2
2Files: bin/networksettings2 apps/Settings/networksettings2.desktop pics/networksettings2/*.png lib/libnetworksettings2.so* pics/networksettings2/Devices/*.png etc/NS2templates/* etc/NS2templates/*/* 2Files: bin/networksettings2 apps/Settings/networksettings2.desktop pics/networksettings2/*.png lib/libnetworksettings2.so* pics/networksettings2/Devices/*.png etc/NS2templates/* etc/NS2templates/*/* bin/NS2SetMac.sh
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: task-opie-minimal, libopietooth2 7Depends: task-opie-minimal, libopietooth2
8Description: Network settings. 8Description: Network settings.
9Replaces: opie-networksetup 9Replaces: opie-networksetup
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/networksettings2/opietooth2/OTDevice.h b/noncore/settings/networksettings2/opietooth2/OTDevice.h
index c2abb09..cf1c4b6 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDevice.h
+++ b/noncore/settings/networksettings2/opietooth2/OTDevice.h
@@ -1,116 +1,116 @@
1#ifndef OTDEVICE_H 1#ifndef OTDEVICE_H
2#define OTDEVICE_H 2#define OTDEVICE_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qstring.h> 5#include <qstring.h>
6 6
7#include <bluezlib.h> 7#include <bluezlib.h>
8 8
9#include <OTGateway.h> 9#include <OTGateway.h>
10 10
11// define if you want to use the process hciattach for detection 11// define if you want to use the process hciattach for detection
12// #define USEHCIPROC 12// #define USEHCIPROC
13 13
14class QTimerEvent; 14class QTimerEvent;
15 15
16namespace Opie { 16namespace Opie {
17 namespace Core { 17 namespace Core {
18 class OProcess; 18 class OProcess;
19 } 19 };
20} 20};
21 21
22namespace Opietooth2 { 22namespace Opietooth2 {
23 23
24 /** 24 /**
25 * Device takes care of attaching serial 25 * Device takes care of attaching serial
26 * devices to the blueZ stack. 26 * devices to the blueZ stack.
27 * After attaching it hciconfig ups it 27 * After attaching it hciconfig ups it
28 */ 28 */
29 class OTDevice : public QObject { 29 class OTDevice : public QObject {
30 30
31 Q_OBJECT 31 Q_OBJECT
32 32
33 public: 33 public:
34 34
35 /** 35 /**
36 * Brings up the device. 36 * Brings up the device.
37 * will detech which device is needed 37 * will detech which device is needed
38 * Usage example: new Device(/dev/ttySB0, csr) 38 * Usage example: new Device(/dev/ttySB0, csr)
39 * 39 *
40 */ 40 */
41 OTDevice( OTGateway * _OT ); 41 OTDevice( OTGateway * _OT );
42 42
43 /** 43 /**
44 * unloads the device 44 * unloads the device
45 */ 45 */
46 ~OTDevice(); 46 ~OTDevice();
47 47
48 inline OTGateway * gateway() const 48 inline OTGateway * gateway() const
49 { return OT; } 49 { return OT; }
50 50
51 inline bool needsAttach( void ) const 51 inline bool needsAttach( void ) const
52 { return NeedsAttach; } 52 { return NeedsAttach; }
53 53
54 inline int deviceNr() const 54 inline int deviceNr() const
55 { return m_deviceNr; } 55 { return m_deviceNr; }
56 56
57 /** 57 /**
58 * attach the device 58 * attach the device
59 * @return bool which is TRUE if command started sucessfully 59 * @return bool which is TRUE if command started sucessfully
60 */ 60 */
61 bool attach(); 61 bool attach();
62 62
63 /** 63 /**
64 * detach the device 64 * detach the device
65 * @return bool which is TRUE if command started sucessfully 65 * @return bool which is TRUE if command started sucessfully
66 */ 66 */
67 bool detach(); 67 bool detach();
68 68
69 /** 69 /**
70 * Is the device loaded? 70 * Is the device loaded?
71 * @return bool, if the device is loaded 71 * @return bool, if the device is loaded
72 */ 72 */
73 bool isAttached()const; 73 bool isAttached()const;
74 74
75 // check current state of attachment 75 // check current state of attachment
76 bool checkAttach(); 76 bool checkAttach();
77 77
78 // returns pattern that points to the proper 78 // returns pattern that points to the proper
79 // RFCOMM device file. Put %1 where device nr should be put 79 // RFCOMM device file. Put %1 where device nr should be put
80 // e.g. : /dev/bluetooth/rfcomm/%1 or /def/rfcomm%1 80 // e.g. : /dev/bluetooth/rfcomm/%1 or /def/rfcomm%1
81 QString getRFCommDevicePattern(); 81 QString getRFCommDevicePattern();
82 82
83 signals: 83 signals:
84 84
85 /** 85 /**
86 * Signals if the attach/detach of the device produced 86 * Signals if the attach/detach of the device produced
87 * errors 87 * errors
88 * @param Mesg contains an error message 88 * @param Mesg contains an error message
89 */ 89 */
90 void error( const QString & mesg ); 90 void error( const QString & mesg );
91 void isEnabled( int devnr, bool ); 91 void isEnabled( int devnr, bool );
92 92
93 private slots: 93 private slots:
94 94
95 void slotStdOut(Opie::Core::OProcess*, char*, int ); 95 void slotStdOut(Opie::Core::OProcess*, char*, int );
96 void slotStdErr(Opie::Core::OProcess*, char*, int ); 96 void slotStdErr(Opie::Core::OProcess*, char*, int );
97 97
98 private: 98 private:
99 99
100 void detectDeviceType( QString & Device, 100 void detectDeviceType( QString & Device,
101 QString & Mode, 101 QString & Mode,
102 unsigned long & Speed ); 102 unsigned long & Speed );
103 pid_t getPidOfHCIAttach( void ); 103 pid_t getPidOfHCIAttach( void );
104 104
105 Opie::Core::OProcess* m_hciattach; // ptr to hciattach proces 105 Opie::Core::OProcess* m_hciattach; // ptr to hciattach proces
106 106
107 int m_deviceNr; // x as in hci(x) 107 int m_deviceNr; // x as in hci(x)
108 pid_t m_hciattachPid; // pid of hciattach program 108 pid_t m_hciattachPid; // pid of hciattach program
109 109
110 // backpointer 110 // backpointer
111 OTGateway * OT; 111 OTGateway * OT;
112 bool NeedsAttach; 112 bool NeedsAttach;
113 }; 113 };
114}; 114};
115 115
116#endif 116#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h b/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h
index 8395f37..50f28fc 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h
+++ b/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h
@@ -1,108 +1,108 @@
1//-*-c++-*- 1//-*-c++-*-
2/*************************************************************************** 2/***************************************************************************
3 * Copyright (C) 2003 by Fred Schaettgen * 3 * Copyright (C) 2003 by Fred Schaettgen *
4 * kdebluetooth@0xF.de * 4 * kdebluetooth@0xF.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or * 8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. * 9 * (at your option) any later version. *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12#ifndef OTDEVICEADDRESS_H 12#ifndef OTDEVICEADDRESS_H
13#define OTDEVICEADDRESS_H 13#define OTDEVICEADDRESS_H
14 14
15#include <qstring.h> 15#include <qstring.h>
16#include <bluezlib.h> 16#include <bluezlib.h>
17 17
18namespace Opietooth2 { 18namespace Opietooth2 {
19 19
20/** Represents a Bluetooth device address. 20/** Represents a Bluetooth device address.
21 * This class allows easy conversion of Bluetooth addresses 21 * This class allows easy conversion of Bluetooth addresses
22 * from and to strings. It also works with the bdaddr_t type 22 * from and to strings. It also works with the bdaddr_t type
23 * used by BlueZ. 23 * used by BlueZ.
24 * The class offers a comparsion and less-than operator, so 24 * The class offers a comparsion and less-than operator, so
25 * that it can be used a key in an STL map or similar. 25 * that it can be used a key in an STL map or similar.
26 * The string conversion functions of BlueZ are used internally, 26 * The string conversion functions of BlueZ are used internally,
27 * so the string format is the same than for BlueZ's ba2str(). 27 * so the string format is the same than for BlueZ's ba2str().
28 */ 28 */
29class OTDeviceAddress { 29class OTDeviceAddress {
30 30
31public: 31public:
32 32
33 /** Default constructor. 33 /** Default constructor.
34 The resulting address is equal to DeviceAddress::invalid. 34 The resulting address is equal to DeviceAddress::invalid.
35 */ 35 */
36 OTDeviceAddress(); 36 OTDeviceAddress();
37 37
38 /** Initialize the object with a BlueZ bdaddr_t. 38 /** Initialize the object with a BlueZ bdaddr_t.
39 @param bdaddr address 39 @param bdaddr address
40 @param networkbyteorder if true, bdaddr is assumed to be in 40 @param networkbyteorder if true, bdaddr is assumed to be in
41 network byte order and converted to host byte order first. 41 network byte order and converted to host byte order first.
42 */ 42 */
43 explicit OTDeviceAddress( const bdaddr_t& bdaddr, 43 explicit OTDeviceAddress( const bdaddr_t& bdaddr,
44 bool networkbyteorder = false 44 bool networkbyteorder = false
45 ); 45 );
46 46
47 /** Initializes the object with an address given as a string. 47 /** Initializes the object with an address given as a string.
48 The string must be in a format which is understood by the 48 The string must be in a format which is understood by the
49 BlueZ str2ba function, like 00:61:58:4C:E6:AD. Case doesn't matter. 49 BlueZ str2ba function, like 00:61:58:4C:E6:AD. Case doesn't matter.
50 @param s address string 50 @param s address string
51 */ 51 */
52 explicit OTDeviceAddress(const QString& s); 52 explicit OTDeviceAddress(const QString& s);
53 53
54 /** convert the address to a string. 54 /** convert the address to a string.
55 @return address string 55 @return address string
56 */ 56 */
57 QString toString() const; 57 QString toString() const;
58 58
59 /** Converts the DeviceAddress into a BlueZ bdaddr_t. 59 /** Converts the DeviceAddress into a BlueZ bdaddr_t.
60 @param networkbyteorder if true, the address is returned 60 @param networkbyteorder if true, the address is returned
61 in network byte order. 61 in network byte order.
62 @return the address as bdaddr_t 62 @return the address as bdaddr_t
63 */ 63 */
64 inline const bdaddr_t & getBDAddr( void ) const 64 inline const bdaddr_t & getBDAddr( void ) const
65 { return BDaddr; } 65 { return BDaddr; }
66 bdaddr_t getBDAddrInNetworkByteOrder() const; 66 bdaddr_t getBDAddrInNetworkByteOrder() const;
67 void setBDAddr( const bdaddr_t& bdaddr, 67 void setBDAddr( const bdaddr_t& bdaddr,
68 bool networkbyteorder = false 68 bool networkbyteorder = false
69 ); 69 );
70 70
71 /** Less-than-operator. 71 /** Less-than-operator.
72 Mainly there to use DeviceAddress inside STL containers, 72 Mainly there to use DeviceAddress inside STL containers,
73 like STL sets or as a key in a STL map. 73 like STL sets or as a key in a STL map.
74 @param b the DeviceAddress to compare to (right hand side) 74 @param b the DeviceAddress to compare to (right hand side)
75 @return true if this < b, false otherwise. 75 @return true if this < b, false otherwise.
76 */ 76 */
77 bool operator<(const OTDeviceAddress& b) const; 77 bool operator<(const OTDeviceAddress& b) const;
78 78
79 /** Equality operator. 79 /** Equality operator.
80 Tests two device addresses for equality. 80 Tests two device addresses for equality.
81 @param b the DeviceAddress to compare to (right hand side) 81 @param b the DeviceAddress to compare to (right hand side)
82 @return true if this and b have the same address or 82 @return true if this and b have the same address or
83 if both are invalid, false otherwise 83 if both are invalid, false otherwise
84 */ 84 */
85 bool operator==(const OTDeviceAddress& b) const; 85 bool operator==(const OTDeviceAddress& b) const;
86 86
87 inline bool operator!=(const OTDeviceAddress& b) const 87 inline bool operator!=(const OTDeviceAddress& b) const
88 { return ! ( *this == b ); } 88 { return ! ( *this == b ); }
89 89
90 /** The address 00:00:00:FF:FF:FF */ 90 /** The address 00:00:00:FF:FF:FF */
91 static const OTDeviceAddress local; 91 static const OTDeviceAddress local;
92 92
93 /** The address 00:00:00:00:00:00 */ 93 /** The address 00:00:00:00:00:00 */
94 static const OTDeviceAddress any; 94 static const OTDeviceAddress any;
95 95
96 /** An address tagged as invalid */ 96 /** An address tagged as invalid */
97 static const OTDeviceAddress invalid; 97 static const OTDeviceAddress invalid;
98 98
99protected: 99protected:
100 100
101 bdaddr_t BDaddr; 101 bdaddr_t BDaddr;
102 bool IsValid; 102 bool IsValid;
103 103
104}; 104};
105 105
106} 106};
107 107
108#endif 108#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriver.h b/noncore/settings/networksettings2/opietooth2/OTDriver.h
index b54ffdf..f249cf7 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDriver.h
+++ b/noncore/settings/networksettings2/opietooth2/OTDriver.h
@@ -1,232 +1,232 @@
1/*************************************************************************** 1/***************************************************************************
2 * Copyright (C) 2003 by Mattia Merzi * 2 * Copyright (C) 2003 by Mattia Merzi *
3 * ottobit@ferrara.linux.it * 3 * ottobit@ferrara.linux.it *
4 * * 4 * *
5 * This program is free software; you can redistribute it and/or modify * 5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by * 6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or * 7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. * 8 * (at your option) any later version. *
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11#ifndef OTDRIVER_H 11#ifndef OTDRIVER_H
12#define OTDRIVER_H 12#define OTDRIVER_H
13 13
14/* 14/*
15 * This class handles the connection with the BlueZ libraries, implements 15 * This class handles the connection with the BlueZ libraries, implements
16 * most of the bluetooth-related functions and owns the KBTDevice class 16 * most of the bluetooth-related functions and owns the KBTDevice class
17 * that is a single local bluetooth device representation. 17 * that is a single local bluetooth device representation.
18 * It is used as a Singleton pattern thru the getDefaultConnector() method. 18 * It is used as a Singleton pattern thru the getDefaultConnector() method.
19 * 19 *
20 */ 20 */
21#include <qobject.h> 21#include <qobject.h>
22#include <opie2/odebug.h> 22#include <opie2/odebug.h>
23#include <bluezlib.h> 23#include <bluezlib.h>
24 24
25#include <OTDeviceAddress.h> 25#include <OTDeviceAddress.h>
26 26
27namespace Opietooth2 { 27namespace Opietooth2 {
28 28
29class OTGateway; 29class OTGateway;
30class OTHCISocket; 30class OTHCISocket;
31class OTDeviceAddress; 31class OTDeviceAddress;
32class OTPeer; 32class OTPeer;
33 33
34/* 34/*
35 * This is the representation of a 35 * This is the representation of a
36 * Bluetooth device for the local 36 * Bluetooth device for the local
37 * machine. 37 * machine.
38 */ 38 */
39class OTDriver : public QObject { 39class OTDriver : public QObject {
40 40
41 Q_OBJECT 41 Q_OBJECT
42 42
43public: 43public:
44 44
45 OTDriver( OTGateway * Ot, struct hci_dev_info* di); 45 OTDriver( OTGateway * Ot, struct hci_dev_info* di);
46 ~OTDriver(); 46 ~OTDriver();
47 47
48 inline OTGateway * gateway() const 48 inline OTGateway * gateway() const
49 { return OT; } 49 { return OT; }
50 50
51 /* 51 /*
52 * Initializes the device using the passed hci_dev_info 52 * Initializes the device using the passed hci_dev_info
53 * struct, contining the basic information in order to 53 * struct, contining the basic information in order to
54 * talk with the pyisical device. 54 * talk with the pyisical device.
55 */ 55 */
56 void init(struct hci_dev_info* di); 56 void init(struct hci_dev_info* di);
57 57
58 /* 58 /*
59 * Open the device and obtains a file descriptor to id 59 * Open the device and obtains a file descriptor to id
60 * return if open 60 * return if open
61 */ 61 */
62 bool open(); 62 bool open();
63 63
64 OTHCISocket * openSocket(); 64 OTHCISocket * openSocket();
65 65
66 void closeSocket(); 66 void closeSocket();
67 67
68 /* 68 /*
69 * Return true if the device is opened. 69 * Return true if the device is opened.
70 */ 70 */
71 int isOpen() 71 int isOpen()
72 { return Fd != -1; }; 72 { return Fd != -1; };
73 73
74 /* 74 /*
75 * Calls the ioctl(HCIDEVRESET) in order to 75 * Calls the ioctl(HCIDEVRESET) in order to
76 * reset the device. 76 * reset the device.
77 */ 77 */
78 int reset(); 78 int reset();
79 79
80 // set Up if true and not yet up 80 // set Up if true and not yet up
81 void setUp( bool Mode ); 81 void setUp( bool Mode );
82 82
83 /* 83 /*
84 * Turn the device up and the reinitializes the device. 84 * Turn the device up and the reinitializes the device.
85 * If the device is already up, nothing is done. 85 * If the device is already up, nothing is done.
86 */ 86 */
87 void bringUp(); 87 void bringUp();
88 88
89 /* 89 /*
90 * Turn the device down and the reinitializes the device. 90 * Turn the device down and the reinitializes the device.
91 * If the device is already down, nothing is done. 91 * If the device is already down, nothing is done.
92 */ 92 */
93 void bringDown(); 93 void bringDown();
94 94
95 // is the device UP now 95 // is the device UP now
96 bool isUp() const 96 bool isUp() const
97 { return IsUp; } 97 { return IsUp; }
98 98
99 // get current state 99 // get current state
100 // return 1 if UP, 0 if DOWN, -1 if ERROR 100 // return 1 if UP, 0 if DOWN, -1 if ERROR
101 int currentState(); 101 int currentState();
102 102
103 /* 103 /*
104 * Returns the name of the device. If the device is 104 * Returns the name of the device. If the device is
105 * down, the device id is returned. 105 * down, the device id is returned.
106 */ 106 */
107 QString name(); 107 QString name();
108 108
109 int devId() const 109 int devId() const
110 { return Dev_id; }; 110 { return Dev_id; };
111 111
112 /* 112 /*
113 * Returns the string representation of the device id, 113 * Returns the string representation of the device id,
114 * with the same format of the hciconfig tool. 114 * with the same format of the hciconfig tool.
115 */ 115 */
116 QString devname() 116 QString devname()
117 { return Dev; }; 117 { return Dev; };
118 118
119 /* 119 /*
120 * Returns the file descriptor for the local 120 * Returns the file descriptor for the local
121 * connection to this device 121 * connection to this device
122 */ 122 */
123 int fd() const 123 int fd() const
124 { return Fd; }; 124 { return Fd; };
125 void setfd(int _fd) 125 void setfd(int _fd)
126 { Fd = _fd; }; 126 { Fd = _fd; };
127 127
128 void setType(int _type) 128 void setType(int _type)
129 { Type = _type; }; 129 { Type = _type; };
130 int type() const 130 int type() const
131 { return Type; }; 131 { return Type; };
132 QString strType(); 132 QString strType();
133 133
134 int iscan() const 134 int iscan() const
135 { return Iscan; } 135 { return Iscan; }
136 void setIScan(int _iscan) 136 void setIScan(int _iscan)
137 { Iscan = _iscan; } 137 { Iscan = _iscan; }
138 138
139 int pscan() const 139 int pscan() const
140 { return Pscan; } 140 { return Pscan; }
141 void setPScan(int _pscan) 141 void setPScan(int _pscan)
142 { Pscan = _pscan; } 142 { Pscan = _pscan; }
143 143
144 int authentication() const 144 int authentication() const
145 { return Auth; } 145 { return Auth; }
146 void setAuthentication(int _auth) 146 void setAuthentication(int _auth)
147 { Auth = _auth; } 147 { Auth = _auth; }
148 148
149 int encryption() const 149 int encryption() const
150 { return Encrypt; } 150 { return Encrypt; }
151 void setEncryption(int _encrypt) 151 void setEncryption(int _encrypt)
152 { Encrypt = _encrypt; } 152 { Encrypt = _encrypt; }
153 153
154 void setDevId(int _dev_id) 154 void setDevId(int _dev_id)
155 { Dev_id = _dev_id; }; 155 { Dev_id = _dev_id; };
156 void setDev(char* _dev) 156 void setDev(char* _dev)
157 { Dev = _dev; }; 157 { Dev = _dev; };
158 158
159 void setFlags( unsigned long flags); 159 void setFlags( unsigned long flags);
160 160
161 const OTDeviceAddress & address() 161 const OTDeviceAddress & address()
162 { return Address; } 162 { return Address; }
163 163
164 void setFeatures( unsigned char * _f); 164 void setFeatures( unsigned char * _f);
165 QString features() 165 QString features()
166 { return Features; } 166 { return Features; }
167 167
168 void setManufacturer(int compid); 168 void setManufacturer(int compid);
169 QString manufacturer() 169 QString manufacturer()
170 { return Manufacturer; } 170 { return Manufacturer; }
171 171
172 QString revision(); 172 QString revision();
173 173
174 void setScanMode(bool iscan, bool pscan); 174 void setScanMode(bool iscan, bool pscan);
175 void setClass(unsigned long cls); 175 void setClass(unsigned long cls);
176 176
177 void changeDevName(const char* name); 177 void changeDevName(const char* name);
178 void changeEncryption(bool _encryption); 178 void changeEncryption(bool _encryption);
179 void changeAuthentication(bool _auth); 179 void changeAuthentication(bool _auth);
180 180
181 void getClass( QString & service, 181 void getClass( QString & service,
182 QString & device ); 182 QString & device );
183 void changeClass( unsigned char service, 183 void changeClass( unsigned char service,
184 unsigned char major, 184 unsigned char major,
185 unsigned char minor); 185 unsigned char minor);
186 186
187 QString getPeerName( const OTDeviceAddress & PAddr ); 187 QString getPeerName( const OTDeviceAddress & PAddr );
188 188
189 // address must be connected to this driver 189 // address must be connected to this driver
190 long getLinkQuality( const OTDeviceAddress & Address ); 190 long getLinkQuality( const OTDeviceAddress & Address );
191 191
192signals : 192signals :
193 193
194 void error( const QString & ); 194 void error( const QString & );
195 void stateChange( OTDriver * , bool ); 195 void stateChange( OTDriver * , bool );
196 void driverDisappeared( OTDriver * ); 196 void driverDisappeared( OTDriver * );
197 197
198private slots : 198private slots :
199 199
200 /* 200 /*
201 * Reinitializes the device, obtaining a fresh 201 * Reinitializes the device, obtaining a fresh
202 * hci_dev_info structure. 202 * hci_dev_info structure.
203 */ 203 */
204 void reinit(); 204 void reinit();
205 void SLOT_CloseFd(); 205 void SLOT_CloseFd();
206 206
207private: 207private:
208 208
209 QString getRevEricsson(); 209 QString getRevEricsson();
210 QString getRevCsr(unsigned short rev); 210 QString getRevCsr(unsigned short rev);
211 211
212 QString Name; 212 QString Name;
213 QString Dev; 213 QString Dev;
214 QString Revision; 214 QString Revision;
215 QString Manufacturer; 215 QString Manufacturer;
216 OTDeviceAddress Address; 216 OTDeviceAddress Address;
217 QString Features; 217 QString Features;
218 QTimer * AutoClose; 218 QTimer * AutoClose;
219 219
220 int Dev_id,Fd,Type; 220 int Dev_id,Fd,Type;
221 bool IsUp; 221 bool IsUp;
222 int Iscan,Pscan,Auth,Encrypt; 222 int Iscan,Pscan,Auth,Encrypt;
223 223
224 // socket bound to this device 224 // socket bound to this device
225 OTHCISocket * Socket; 225 OTHCISocket * Socket;
226 226
227 // backpointer to opietooth system 227 // backpointer to opietooth system
228 OTGateway * OT; 228 OTGateway * OT;
229}; 229};
230 230
231} 231};
232#endif 232#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTIcons.h b/noncore/settings/networksettings2/opietooth2/OTIcons.h
index ee10831..966ed24 100644
--- a/noncore/settings/networksettings2/opietooth2/OTIcons.h
+++ b/noncore/settings/networksettings2/opietooth2/OTIcons.h
@@ -1,54 +1,54 @@
1#ifndef OTICONLOADER_H 1#ifndef OTICONLOADER_H
2#define OTICONLOADER_H 2#define OTICONLOADER_H
3 3
4#include <OTUUID.h> 4#include <OTUUID.h>
5#include <qpixmap.h> 5#include <qpixmap.h>
6#include <qmap.h> 6#include <qmap.h>
7 7
8namespace Opietooth2 { 8namespace Opietooth2 {
9 9
10class OTIcons { 10class OTIcons {
11 11
12public: 12public:
13 13
14 OTIcons(); 14 OTIcons();
15 ~OTIcons(); 15 ~OTIcons();
16 16
17 /** 17 /**
18 * Returns an icon depending on device class 18 * Returns an icon depending on device class
19 * @param deviceClass the device class name 19 * @param deviceClass the device class name
20 * @return the pixmap 20 * @return the pixmap
21 */ 21 */
22 QPixmap deviceIcon( const QString & ); 22 QPixmap deviceIcon( const QString & );
23 23
24 /** 24 /**
25 * Returns an icon depending on service id 25 * Returns an icon depending on service id
26 * @param serviceClass the service id 26 * @param serviceClass the service id
27 * @return the pixmap 27 * @return the pixmap
28 * @return true if found 28 * @return true if found
29 */ 29 */
30 QPixmap serviceIcon( int, bool & ); 30 QPixmap serviceIcon( int, bool & );
31 31
32 // returns all UUID that represent channels with modem function 32 // returns all UUID that represent channels with modem function
33 const UUIDVector & modems() 33 const UUIDVector & modems()
34 { return Modems; } 34 { return Modems; }
35 35
36 // returns all UUID that represent channels with network 36 // returns all UUID that represent channels with network
37 const UUIDVector & network() 37 const UUIDVector & network()
38 { return Networks; } 38 { return Networks; }
39 39
40 // set Sub to find icons in .../Icons dir 40 // set Sub to find icons in .../Icons dir
41 QPixmap loadPixmap( const QString &, bool Sub = 0 ); 41 QPixmap loadPixmap( const QString &, bool Sub = 0 );
42 42
43private: 43private:
44 44
45 // first ist id, second is icon name 45 // first ist id, second is icon name
46 QMap<QString,QString> deviceIcons; 46 QMap<QString,QString> deviceIcons;
47 QMap<int,QString> serviceIcons; 47 QMap<int,QString> serviceIcons;
48 UUIDVector Modems; 48 UUIDVector Modems;
49 UUIDVector Networks; 49 UUIDVector Networks;
50 50
51}; 51};
52} 52};
53 53
54#endif 54#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTInquiry.h b/noncore/settings/networksettings2/opietooth2/OTInquiry.h
index f7bdeec..2682499 100644
--- a/noncore/settings/networksettings2/opietooth2/OTInquiry.h
+++ b/noncore/settings/networksettings2/opietooth2/OTInquiry.h
@@ -1,178 +1,178 @@
1//-*-c++-*- 1//-*-c++-*-
2/*************************************************************************** 2/***************************************************************************
3 * Copyright (C) 2003 by Fred Schaettgen * 3 * Copyright (C) 2003 by Fred Schaettgen *
4 * kdebluetooth@schaettgen.de * 4 * kdebluetooth@schaettgen.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or * 8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. * 9 * (at your option) any later version. *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12#ifndef OTINQUIRY_H 12#ifndef OTINQUIRY_H
13#define OTINQUIRY_H 13#define OTINQUIRY_H
14 14
15#include <qstring.h> 15#include <qstring.h>
16#include <qobject.h> 16#include <qobject.h>
17 17
18#include <qguardedptr.h> 18#include <qguardedptr.h>
19#include <qtimer.h> 19#include <qtimer.h>
20 20
21#include <OTPeer.h> 21#include <OTPeer.h>
22 22
23// #include <set> 23// #include <set>
24// #include <deque> 24// #include <deque>
25 25
26namespace Opietooth2 { 26namespace Opietooth2 {
27 27
28class QSocket; 28class QSocket;
29class QDateTime; 29class QDateTime;
30 30
31class OTDriver; 31class OTDriver;
32class OTHCISocket; 32class OTHCISocket;
33 33
34/** Scans for nearby bluetooth devices. 34/** Scans for nearby bluetooth devices.
35 * This class provides an asynchronous interface to the 35 * This class provides an asynchronous interface to the
36 * inquriy HCI command. To scan for other devices, connect 36 * inquriy HCI command. To scan for other devices, connect
37 * to the signals neighbourFound() and finished() and call 37 * to the signals neighbourFound() and finished() and call
38 * inquiry(). Inquiry results are signalled as soon as they arrive, 38 * inquiry(). Inquiry results are signalled as soon as they arrive,
39 * so the information can be displayed before the whole inquiry 39 * so the information can be displayed before the whole inquiry
40 * process is finished. 40 * process is finished.
41 * Still no connections should be set up before 41 * Still no connections should be set up before
42 * the finished() signal was sent (hmm, is this always true..?) 42 * the finished() signal was sent (hmm, is this always true..?)
43 */ 43 */
44 44
45class OTInquiry : public QObject { 45class OTInquiry : public QObject {
46 46
47 Q_OBJECT 47 Q_OBJECT
48 48
49public: 49public:
50 50
51 /** Constructor. 51 /** Constructor.
52 @param owner The owning parent object 52 @param owner The owning parent object
53 */ 53 */
54 OTInquiry( OTDriver* Drv ); 54 OTInquiry( OTDriver* Drv );
55 55
56 /** Destructor. */ 56 /** Destructor. */
57 virtual ~OTInquiry(); 57 virtual ~OTInquiry();
58 58
59 // General/Unlimited Inquiry Access Code 59 // General/Unlimited Inquiry Access Code
60 static const int GIAC = 0x9E8B33; 60 static const int GIAC = 0x9E8B33;
61 61
62 // Limited Dedicated Inquiry Access Code 62 // Limited Dedicated Inquiry Access Code
63 static const int LIAC = 0x9E8B00; 63 static const int LIAC = 0x9E8B00;
64 64
65 /** Starts the inquiry. 65 /** Starts the inquiry.
66 if you start inquiry several times without calling clear(), 66 if you start inquiry several times without calling clear(),
67 you will receive each result only once. 67 you will receive each result only once.
68 @param timeout duration of the inquiry in seconds. 68 @param timeout duration of the inquiry in seconds.
69 It will be rounded to the next multiple of 1.28 sec, 69 It will be rounded to the next multiple of 1.28 sec,
70 with a maximum of 61.44 sec. 70 with a maximum of 61.44 sec.
71 @param lap 71 @param lap
72 */ 72 */
73 bool inquire( double timeout = 8.0, 73 bool inquire( double timeout = 8.0,
74 int numResponses = 0, 74 int numResponses = 0,
75 int lap = GIAC); 75 int lap = GIAC);
76 76
77 void stopInquiring( ); 77 void stopInquiring( );
78 78
79 /** Enters periodic inquiry mode. 79 /** Enters periodic inquiry mode.
80 An inquiry will be started at a random time in the intervall 80 An inquiry will be started at a random time in the intervall
81 between minduration and maxduration. 81 between minduration and maxduration.
82 @param minduration minimum time between two inquiries. Rounded to 82 @param minduration minimum time between two inquiries. Rounded to
83 a multiple of 1.28, (3.84 <= d <= 83884.8) 83 a multiple of 1.28, (3.84 <= d <= 83884.8)
84 @param maxduration maximum time between two inquiries. Rounded to 84 @param maxduration maximum time between two inquiries. Rounded to
85 a multiple of 1.28, (3.84 <= d <= 83884.8) 85 a multiple of 1.28, (3.84 <= d <= 83884.8)
86 @param timeout duration of the inquiry in seconds. 86 @param timeout duration of the inquiry in seconds.
87 It will be rounded to the next multiple of 1.28 sec, 87 It will be rounded to the next multiple of 1.28 sec,
88 with a maximum of 61.44 sec. 88 with a maximum of 61.44 sec.
89 @param numResponses Number of responses after which the inquiry 89 @param numResponses Number of responses after which the inquiry
90 will be stopped. 0 means no limit. 90 will be stopped. 0 means no limit.
91 @param lap 91 @param lap
92 */ 92 */
93 /* 93 /*
94 void inquirePeriodically( double minduration, 94 void inquirePeriodically( double minduration,
95 double maxduration, 95 double maxduration,
96 double timeout = 8.0, 96 double timeout = 8.0,
97 int numResponses = 0, 97 int numResponses = 0,
98 int lap = LIAC 98 int lap = LIAC
99 ); 99 );
100*/ 100*/
101 /** checks if there the inquiry is running currently 101 /** checks if there the inquiry is running currently
102 @return true if there is an inquiry running 102 @return true if there is an inquiry running
103 which was started by this object. 103 which was started by this object.
104 @todo possibility to check for "foreign" inquiries. Deal with 104 @todo possibility to check for "foreign" inquiries. Deal with
105 the fact that we can receive foreign inquiry results. 105 the fact that we can receive foreign inquiry results.
106 */ 106 */
107 bool isInquiring(); 107 bool isInquiring();
108 108
109 /** This function returns true after after an inquiry was 109 /** This function returns true after after an inquiry was
110 started, results were received and the inquiry ended successfully. 110 started, results were received and the inquiry ended successfully.
111 This can be the case without calling inquiry() at all, because 111 This can be the case without calling inquiry() at all, because
112 results of inquiries started by other programs are also processed. 112 results of inquiries started by other programs are also processed.
113 */ 113 */
114 bool isFinished(); 114 bool isFinished();
115 115
116 /** Resets the list of received results and sets 116 /** Resets the list of received results and sets
117 isInquiryComplete() to false. 117 isInquiryComplete() to false.
118 */ 118 */
119 void reset(); 119 void reset();
120 120
121 inline OTDriver * driver() const 121 inline OTDriver * driver() const
122 { return Driver; } 122 { return Driver; }
123 123
124protected: 124protected:
125 125
126 /** Called when a new neighbour was found. The default 126 /** Called when a new neighbour was found. The default
127 implementation emits the neighbourFound signal. 127 implementation emits the neighbourFound signal.
128 @param bdaddr the address found. 128 @param bdaddr the address found.
129 */ 129 */
130 virtual void onPeerFound( OTPeer * Peer, bool ); 130 virtual void onPeerFound( OTPeer * Peer, bool );
131 131
132 enum ErrorCode { 132 enum ErrorCode {
133 InquiryFinishedTimeout = 0x0100 133 InquiryFinishedTimeout = 0x0100
134 }; 134 };
135 135
136signals : 136signals :
137 137
138 void peerFound( OTPeer *, bool ); 138 void peerFound( OTPeer *, bool );
139 139
140 /** Emitted after an inquiry has finished successfully. 140 /** Emitted after an inquiry has finished successfully.
141 If the inquiry was canceled, no finished signals is emitted. 141 If the inquiry was canceled, no finished signals is emitted.
142 This signal can be emitted without having called inquiry, since 142 This signal can be emitted without having called inquiry, since
143 other processes may have started an inquiry. 143 other processes may have started an inquiry.
144 */ 144 */
145 void finished(); 145 void finished();
146 146
147 /** Emitted instead of finished if an error occured after 147 /** Emitted instead of finished if an error occured after
148 calling inquiry() or periodicInquiryMode() 148 calling inquiry() or periodicInquiryMode()
149 @param code error code. 149 @param code error code.
150 @param message Error message 150 @param message Error message
151 */ 151 */
152 void error( QString message ); 152 void error( QString message );
153 153
154private: 154private:
155 155
156 // std::set<DeviceAddress> addrCache; 156 // std::set<DeviceAddress> addrCache;
157 // double currentTimeout; 157 // double currentTimeout;
158 // QByteArray* buf; 158 // QByteArray* buf;
159 // QSocket* hciSocket; 159 // QSocket* hciSocket;
160 QGuardedPtr<OTHCISocket> Socket; 160 QGuardedPtr<OTHCISocket> Socket;
161 OTDriver * Driver; 161 OTDriver * Driver;
162 162
163 //QDateTime *startTime; 163 //QDateTime *startTime;
164 QTimer *InquiryTimeoutTimer; 164 QTimer *InquiryTimeoutTimer;
165 165
166 // std::deque<InquiryInfo> infoQueue; 166 // std::deque<InquiryInfo> infoQueue;
167 bool SuccessfullyStarted; 167 bool SuccessfullyStarted;
168 bool SuccessfullyEnded; 168 bool SuccessfullyEnded;
169 169
170private slots: 170private slots:
171 171
172 void slotInquiryTimeout(); 172 void slotInquiryTimeout();
173 void slotHCIEvent(unsigned char eventCode, QByteArray buf); 173 void slotHCIEvent(unsigned char eventCode, QByteArray buf);
174 174
175}; 175};
176 176
177} 177};
178#endif 178#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTPeer.h b/noncore/settings/networksettings2/opietooth2/OTPeer.h
index c09af15..9cd0dc7 100644
--- a/noncore/settings/networksettings2/opietooth2/OTPeer.h
+++ b/noncore/settings/networksettings2/opietooth2/OTPeer.h
@@ -1,135 +1,135 @@
1//-*-c++-*- 1//-*-c++-*-
2/*************************************************************************** 2/***************************************************************************
3 * Copyright (C) 2003 by Fred Schaettgen * 3 * Copyright (C) 2003 by Fred Schaettgen *
4 * kdebluetooth@0xF.de * 4 * kdebluetooth@0xF.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or * 8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. * 9 * (at your option) any later version. *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12#ifndef OTPEER_H 12#ifndef OTPEER_H
13#define OTPEER_H 13#define OTPEER_H
14 14
15#include <qstring.h> 15#include <qstring.h>
16#include <qobject.h> 16#include <qobject.h>
17#include <qvector.h> 17#include <qvector.h>
18#include <bluezlib.h> 18#include <bluezlib.h>
19#include <OTDeviceAddress.h> 19#include <OTDeviceAddress.h>
20 20
21class QTextStream; 21class QTextStream;
22class QTimerEvent; 22class QTimerEvent;
23 23
24namespace Opietooth2 { 24namespace Opietooth2 {
25 25
26class OTGateway; 26class OTGateway;
27 27
28class OTDriver; 28class OTDriver;
29class OTSDPService; 29class OTSDPService;
30class OTSDPAttribute; 30class OTSDPAttribute;
31class OTUUID; 31class OTUUID;
32typedef QVector<OTSDPService> ServiceVector; 32typedef QVector<OTSDPService> ServiceVector;
33 33
34class OTPeer : public QObject { 34class OTPeer : public QObject {
35 35
36 Q_OBJECT; 36 Q_OBJECT;
37 37
38public : 38public :
39 39
40 typedef enum PeerState_E { 40 typedef enum PeerState_E {
41 Peer_Unknown = -1, 41 Peer_Unknown = -1,
42 Peer_Down = 0, 42 Peer_Down = 0,
43 Peer_Up = 1 43 Peer_Up = 1
44 } PeerState_t; 44 } PeerState_t;
45 45
46 OTPeer( OTGateway * _OT ); 46 OTPeer( OTGateway * _OT );
47 OTPeer( QTextStream & TS, OTGateway * _TS ); 47 OTPeer( QTextStream & TS, OTGateway * _TS );
48 ~OTPeer(); 48 ~OTPeer();
49 49
50 inline OTGateway * gateway() const 50 inline OTGateway * gateway() const
51 { return OT; } 51 { return OT; }
52 52
53 inline int deviceClass( void ) const 53 inline int deviceClass( void ) const
54 { return Class; } 54 { return Class; }
55 inline void setDeviceClass( int cls ) 55 inline void setDeviceClass( int cls )
56 { Class = cls; } 56 { Class = cls; }
57 57
58 void setAddress( const OTDeviceAddress & A ) 58 void setAddress( const OTDeviceAddress & A )
59 { Addr = A; } 59 { Addr = A; }
60 60
61 const OTDeviceAddress & address( void ) 61 const OTDeviceAddress & address( void )
62 { return Addr; } 62 { return Addr; }
63 63
64 inline QString name( void ) const 64 inline QString name( void ) const
65 { return Name; } 65 { return Name; }
66 inline void setName( const QString & n ) 66 inline void setName( const QString & n )
67 { Name = n; } 67 { Name = n; }
68 68
69 ServiceVector & services( bool Force = 0 ) 69 ServiceVector & services( bool Force = 0 )
70 { if( Force || serviceList.count() == 0 ) { 70 { if( Force || serviceList.count() == 0 ) {
71 updateServices(); 71 updateServices();
72 } 72 }
73 return serviceList; 73 return serviceList;
74 } 74 }
75 75
76 /* Returns TRUE if the device has at least a service 76 /* Returns TRUE if the device has at least a service
77 with inside the required class Id.*/ 77 with inside the required class Id.*/
78 bool hasServiceClassID( const OTUUID & uuid); 78 bool hasServiceClassID( const OTUUID & uuid);
79 79
80 /* Get a vector of Rfcomm channels of the services 80 /* Get a vector of Rfcomm channels of the services
81 having "uuid" in the class ID List */ 81 having "uuid" in the class ID List */
82 QArray<int> rfcommList( const OTUUID & uuid ); 82 QArray<int> rfcommList( const OTUUID & uuid );
83 83
84 inline void setState( PeerState_t S) 84 inline void setState( PeerState_t S)
85 { State = S; } 85 { State = S; }
86 inline PeerState_t state( void ) 86 inline PeerState_t state( void )
87 { return State; } 87 { return State; }
88 88
89 // go and find out state 89 // go and find out state
90 // will report back with signal 90 // will report back with signal
91 void findOutState( int timeoutInSec = 1, bool Force = 0 ); 91 void findOutState( int timeoutInSec = 1, bool Force = 0 );
92 void stopFindingOutState( void ); 92 void stopFindingOutState( void );
93 93
94 // return driver to which this peer is connected to 94 // return driver to which this peer is connected to
95 // if it is connected 95 // if it is connected
96 inline OTDriver * connectedTo( void ) const 96 inline OTDriver * connectedTo( void ) const
97 { return ConnectedTo; } 97 { return ConnectedTo; }
98 inline void setConnectedTo( OTDriver * D ) 98 inline void setConnectedTo( OTDriver * D )
99 { ConnectedTo = D; } 99 { ConnectedTo = D; }
100 100
101 void save( QTextStream& TS ); 101 void save( QTextStream& TS );
102 void load( QTextStream& TS ); 102 void load( QTextStream& TS );
103 103
104signals : 104signals :
105 105
106 // report back state 106 // report back state
107 void peerStateReport( OTPeer *); 107 void peerStateReport( OTPeer *);
108 void error( const QString & ); 108 void error( const QString & );
109 109
110protected : 110protected :
111 111
112 // while polling for result of ping 112 // while polling for result of ping
113 void timerEvent( QTimerEvent * ev ); 113 void timerEvent( QTimerEvent * ev );
114 114
115private: 115private:
116 116
117 void updateServices(); 117 void updateServices();
118 118
119 OTGateway * OT; 119 OTGateway * OT;
120 OTDeviceAddress Addr; 120 OTDeviceAddress Addr;
121 QString Name; 121 QString Name;
122 int Class; 122 int Class;
123 ServiceVector serviceList; 123 ServiceVector serviceList;
124 // -1 : don't know, 0 no, 1 yes 124 // -1 : don't know, 0 no, 1 yes
125 PeerState_t State; 125 PeerState_t State;
126 OTDriver * ConnectedTo; 126 OTDriver * ConnectedTo;
127 127
128 int ProbeFD; 128 int ProbeFD;
129 int ProbePhase; // see OTDriver 129 int ProbePhase; // see OTDriver
130 long ProbeTimeout; 130 long ProbeTimeout;
131}; 131};
132 132
133} 133};
134 134
135#endif 135#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h
index e79e33d..86b5623 100644
--- a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h
+++ b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h
@@ -1,140 +1,140 @@
1//-*-c++-*- 1//-*-c++-*-
2/*************************************************************************** 2/***************************************************************************
3 * Copyright (C) 2003 by Fred Schaettgen * 3 * Copyright (C) 2003 by Fred Schaettgen *
4 * kdebluetooth@schaettgen.de * 4 * kdebluetooth@schaettgen.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or * 8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. * 9 * (at your option) any later version. *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12#ifndef OTATTRIBUTE_H 12#ifndef OTATTRIBUTE_H
13#define OTATTRIBUTE_H 13#define OTATTRIBUTE_H
14 14
15#include <stdio.h> 15#include <stdio.h>
16#include <qstring.h> 16#include <qstring.h>
17#include <qarray.h> 17#include <qarray.h>
18#include <qvector.h> 18#include <qvector.h>
19#include <bluezlib.h> 19#include <bluezlib.h>
20#include <OTUUID.h> 20#include <OTUUID.h>
21 21
22namespace Opietooth2 { 22namespace Opietooth2 {
23 23
24class OTSDPAttribute; 24class OTSDPAttribute;
25class OTUUID; 25class OTUUID;
26 26
27typedef QVector<OTSDPAttribute> AttributeVector; 27typedef QVector<OTSDPAttribute> AttributeVector;
28 28
29/** 29/**
30@author Fred Schaettgen 30@author Fred Schaettgen
31*/ 31*/
32class OTSDPAttribute { 32class OTSDPAttribute {
33 33
34public: 34public:
35 35
36 enum AttrType { 36 enum AttrType {
37 INVALID = 0, 37 INVALID = 0,
38 NIL = 1, 38 NIL = 1,
39 UINT = 2, 39 UINT = 2,
40 INT = 3, 40 INT = 3,
41 UUID = 4, 41 UUID = 4,
42 BOOLEAN = 5, 42 BOOLEAN = 5,
43 STRING = 6, 43 STRING = 6,
44 SEQUENCE = 7, 44 SEQUENCE = 7,
45 ALTERNATIVE = 8, 45 ALTERNATIVE = 8,
46 URL = 9, 46 URL = 9,
47 UNKNOWN = 10 47 UNKNOWN = 10
48 }; 48 };
49 49
50 class int128_t { 50 class int128_t {
51 public : 51 public :
52 int128_t(int64_t l=0, int64_t h=0) { 52 int128_t(int64_t l=0, int64_t h=0) {
53 hi = h; 53 hi = h;
54 lo = l; 54 lo = l;
55 } 55 }
56 int128_t(const OTSDPAttribute::int128_t & l) { 56 int128_t(const OTSDPAttribute::int128_t & l) {
57 hi = l.hi; 57 hi = l.hi;
58 lo = l.lo; 58 lo = l.lo;
59 } 59 }
60 QString toString() const { 60 QString toString() const {
61 char Buf[50]; 61 char Buf[50];
62 sprintf( Buf, "%lld%lld", hi, lo ); 62 sprintf( Buf, "%lld%lld", hi, lo );
63 return QString( Buf ); 63 return QString( Buf );
64 } 64 }
65 int64_t hi; 65 int64_t hi;
66 int64_t lo; 66 int64_t lo;
67 }; 67 };
68 68
69 class uint128_t { 69 class uint128_t {
70 public : 70 public :
71 uint128_t( uint64_t l=0, uint64_t h=0) { 71 uint128_t( uint64_t l=0, uint64_t h=0) {
72 hi = h; 72 hi = h;
73 lo = l; 73 lo = l;
74 } 74 }
75 uint128_t( const OTSDPAttribute::uint128_t & l) { 75 uint128_t( const OTSDPAttribute::uint128_t & l) {
76 hi = l.hi; 76 hi = l.hi;
77 lo = l.lo; 77 lo = l.lo;
78 } 78 }
79 QString toString() const { 79 QString toString() const {
80 char Buf[50]; 80 char Buf[50];
81 sprintf( Buf, "%llu%llu", hi, lo ); 81 sprintf( Buf, "%llu%llu", hi, lo );
82 return QString( Buf ); 82 return QString( Buf );
83 } 83 }
84 uint64_t hi; 84 uint64_t hi;
85 uint64_t lo; 85 uint64_t lo;
86 }; 86 };
87 87
88public: 88public:
89 89
90 OTSDPAttribute(); 90 OTSDPAttribute();
91 OTSDPAttribute( sdp_data_t * D ); 91 OTSDPAttribute( sdp_data_t * D );
92 ~OTSDPAttribute(); 92 ~OTSDPAttribute();
93 93
94 QString toString( void ); 94 QString toString( void );
95 95
96 void setNil(); 96 void setNil();
97 void setInt(const OTSDPAttribute::int128_t & val); 97 void setInt(const OTSDPAttribute::int128_t & val);
98 void setUInt(const OTSDPAttribute::uint128_t & val); 98 void setUInt(const OTSDPAttribute::uint128_t & val);
99 void setUUID( const OTUUID & val); 99 void setUUID( const OTUUID & val);
100 void setBool(bool val); 100 void setBool(bool val);
101 void setString(const QString & val); 101 void setString(const QString & val);
102 void setURL(const QString & val); 102 void setURL(const QString & val);
103 void setSequence(const AttributeVector& val); 103 void setSequence(const AttributeVector& val);
104 void setAlternative(const AttributeVector& val); 104 void setAlternative(const AttributeVector& val);
105 105
106 QString getString(); 106 QString getString();
107 QString getURL(); 107 QString getURL();
108 const OTSDPAttribute::int128_t & getInt(); 108 const OTSDPAttribute::int128_t & getInt();
109 const OTSDPAttribute::uint128_t & getUInt(); 109 const OTSDPAttribute::uint128_t & getUInt();
110 const OTUUID & getUUID(); 110 const OTUUID & getUUID();
111 bool getBool(); 111 bool getBool();
112 AttributeVector * getSequence(); 112 AttributeVector * getSequence();
113 AttributeVector * getAlternative(); 113 AttributeVector * getAlternative();
114 114
115 UUIDVector getAllUUIDs(); 115 UUIDVector getAllUUIDs();
116 116
117 inline AttrType getType() 117 inline AttrType getType()
118 { return type; } 118 { return type; }
119 119
120 //QString getValString(); 120 //QString getValString();
121 const char * getTypeString(); 121 const char * getTypeString();
122 122
123private: 123private:
124 124
125 AttrType type; 125 AttrType type;
126 126
127 union { 127 union {
128 OTSDPAttribute::int128_t * intVal; 128 OTSDPAttribute::int128_t * intVal;
129 OTSDPAttribute::uint128_t * uintVal; 129 OTSDPAttribute::uint128_t * uintVal;
130 OTUUID * uuidVal; 130 OTUUID * uuidVal;
131 bool boolVal; 131 bool boolVal;
132 QString * stringVal; // strings and urls 132 QString * stringVal; // strings and urls
133 AttributeVector * sequenceVal; // sequences and alternatives 133 AttributeVector * sequenceVal; // sequences and alternatives
134 } Value; 134 } Value;
135 135
136}; 136};
137 137
138} 138};
139 139
140#endif 140#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTSDPService.h b/noncore/settings/networksettings2/opietooth2/OTSDPService.h
index 4831df0..21d7344 100644
--- a/noncore/settings/networksettings2/opietooth2/OTSDPService.h
+++ b/noncore/settings/networksettings2/opietooth2/OTSDPService.h
@@ -1,75 +1,75 @@
1//-*-c++-*- 1//-*-c++-*-
2/*************************************************************************** 2/***************************************************************************
3 * Copyright (C) 2003 by Fred Schaettgen * 3 * Copyright (C) 2003 by Fred Schaettgen *
4 * kdebluetooth@schaettgen.de * 4 * kdebluetooth@schaettgen.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or * 8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. * 9 * (at your option) any later version. *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12#ifndef SDPSERVICE_H 12#ifndef SDPSERVICE_H
13#define SDPSERVICE_H 13#define SDPSERVICE_H
14 14
15#include <qvector.h> 15#include <qvector.h>
16#include <qarray.h> 16#include <qarray.h>
17#include <OTSDPAttribute.h> 17#include <OTSDPAttribute.h>
18 18
19namespace Opietooth2 { 19namespace Opietooth2 {
20 20
21/** 21/**
22@author Fred Schaettgen 22@author Fred Schaettgen
23*/ 23*/
24class OTSDPService { 24class OTSDPService {
25 25
26public: 26public:
27 27
28 OTSDPService(); 28 OTSDPService();
29 virtual ~OTSDPService(); 29 virtual ~OTSDPService();
30 30
31 void addAttribute(int id, OTSDPAttribute * attr); 31 void addAttribute(int id, OTSDPAttribute * attr);
32 32
33 const OTSDPAttribute & attribute( int index ); 33 const OTSDPAttribute & attribute( int index );
34 int attributeID( int index ); 34 int attributeID( int index );
35 35
36 AttributeVector subAttributes( OTSDPAttribute * attr); 36 AttributeVector subAttributes( OTSDPAttribute * attr);
37 OTSDPAttribute * attributeByID( int id ); 37 OTSDPAttribute * attributeByID( int id );
38 38
39 // See Bluetooth Core Spec Sec. 5.1 39 // See Bluetooth Core Spec Sec. 5.1
40 bool recordHandle(uint32_t *handle); // 0x00 40 bool recordHandle(uint32_t *handle); // 0x00
41 41
42 //bool getServiceClassIDList(vector<uuid_t> *classIDList); // 0x01 42 //bool getServiceClassIDList(vector<uuid_t> *classIDList); // 0x01
43 //bool getServiceRecordState(uint32_t *state); // 0x02 43 //bool getServiceRecordState(uint32_t *state); // 0x02
44 //bool getServiceID(uuid_t *id); // 0x03; 44 //bool getServiceID(uuid_t *id); // 0x03;
45 //bool getProtocolDescriptorList(SDP::Attribute *attribute); // 0x04 45 //bool getProtocolDescriptorList(SDP::Attribute *attribute); // 0x04
46 //bool getBrowseGroupList(vector<uuid_t> *browseGroupList); // 0x05 46 //bool getBrowseGroupList(vector<uuid_t> *browseGroupList); // 0x05
47 QString name(void); // langBase + 0x00 47 QString name(void); // langBase + 0x00
48 QString description(void); // langBase + 0x01 48 QString description(void); // langBase + 0x01
49 49
50 UUIDVector allUUIDs(); 50 UUIDVector allUUIDs();
51 51
52 // return list of classes this service belongs to 52 // return list of classes this service belongs to
53 UUIDVector classIDList(); 53 UUIDVector classIDList();
54 54
55 /** Retrieves the Rfcomm channel. 55 /** Retrieves the Rfcomm channel.
56 This function is provided just for conveniance. 56 This function is provided just for conveniance.
57 @param n The Rfcomm channel. 57 @param n The Rfcomm channel.
58 @ret true if an rfcomm channel was found, false otherwise. */ 58 @ret true if an rfcomm channel was found, false otherwise. */
59 bool rfcommChannel(unsigned int &n); 59 bool rfcommChannel(unsigned int &n);
60 60
61 bool hasClassID(const OTUUID & uuid); 61 bool hasClassID(const OTUUID & uuid);
62 62
63private: 63private:
64 64
65 struct AttributeEntry { 65 struct AttributeEntry {
66 int id; 66 int id;
67 OTSDPAttribute * attr; 67 OTSDPAttribute * attr;
68 }; 68 };
69 69
70 QArray<AttributeEntry> attributeList; 70 QArray<AttributeEntry> attributeList;
71}; 71};
72 72
73} 73};
74 74
75#endif 75#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTUUID.h b/noncore/settings/networksettings2/opietooth2/OTUUID.h
index aebd9b9..97df114 100644
--- a/noncore/settings/networksettings2/opietooth2/OTUUID.h
+++ b/noncore/settings/networksettings2/opietooth2/OTUUID.h
@@ -1,58 +1,58 @@
1//-*-c++-*- 1//-*-c++-*-
2/*************************************************************************** 2/***************************************************************************
3 * Copyright (C) 2003 by Fred Schaettgen * 3 * Copyright (C) 2003 by Fred Schaettgen *
4 * kdebluetooth@schaettgen.de * 4 * kdebluetooth@schaettgen.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or * 8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. * 9 * (at your option) any later version. *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12#ifndef OTUUID_H 12#ifndef OTUUID_H
13#define OTUUID_H 13#define OTUUID_H
14 14
15#include <qstring.h> 15#include <qstring.h>
16#include <qarray.h> 16#include <qarray.h>
17#include <bluezlib.h> 17#include <bluezlib.h>
18 18
19namespace Opietooth2 { 19namespace Opietooth2 {
20 20
21class OTUUID; 21class OTUUID;
22 22
23typedef QArray<OTUUID> UUIDVector; 23typedef QArray<OTUUID> UUIDVector;
24 24
25class OTUUID { 25class OTUUID {
26 26
27public : 27public :
28 28
29 OTUUID( QString s ); 29 OTUUID( QString s );
30 OTUUID( uint64_t l=0, uint64_t h=0); 30 OTUUID( uint64_t l=0, uint64_t h=0);
31 OTUUID( const OTUUID & O ); 31 OTUUID( const OTUUID & O );
32 32
33 bool fromString(QString s); 33 bool fromString(QString s);
34 34
35 void setUUID128(uint64_t hi, uint64_t lo); 35 void setUUID128(uint64_t hi, uint64_t lo);
36 36
37 void setUUID32(uint32_t v); 37 void setUUID32(uint32_t v);
38 38
39 uint16_t toShort() 39 uint16_t toShort()
40 { return ((hi>>32) & 0xffff); } 40 { return ((hi>>32) & 0xffff); }
41 uint32_t toLong() 41 uint32_t toLong()
42 { return ((hi>>32) & 0xffffffff); } 42 { return ((hi>>32) & 0xffffffff); }
43 uint64_t toLongLong() 43 uint64_t toLongLong()
44 { return hi; } 44 { return hi; }
45 45
46 QString toString() const ; 46 QString toString() const ;
47 operator QString() const; 47 operator QString() const;
48 operator ::uuid_t() const; 48 operator ::uuid_t() const;
49 49
50 OTUUID & operator=( const OTUUID & other ) ; 50 OTUUID & operator=( const OTUUID & other ) ;
51 bool operator<( const OTUUID & other ) const; 51 bool operator<( const OTUUID & other ) const;
52 bool operator==(const OTUUID & uuid) const; 52 bool operator==(const OTUUID & uuid) const;
53 53
54 uint64_t hi; 54 uint64_t hi;
55 uint64_t lo; 55 uint64_t lo;
56}; 56};
57} 57};
58#endif 58#endif
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp
index f8824e0..0a46642 100644
--- a/noncore/settings/networksettings2/usb/usbrun.cpp
+++ b/noncore/settings/networksettings2/usb/usbrun.cpp
@@ -1,112 +1,124 @@
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
7State_t USBRun::detectState( void ) { 7State_t USBRun::detectState( void ) {
8 // unavailable : no card found 8 // unavailable : no card found
9 // available : card found and assigned to us or free 9 // available : card found and assigned to us or free
10 // up : card found and assigned to us and up 10 // up : card found and assigned to us and up
11 NodeCollection * NC = nodeCollection(); 11 NodeCollection * NC = nodeCollection();
12 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number()); 12 QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
13 System & Sys = NSResources->system(); 13 System & Sys = NSResources->system();
14 InterfaceInfo * Run; 14 InterfaceInfo * Run;
15 QFile F( S ); 15 QFile F( S );
16 Log(("Detecting for %s\n", NC->name().latin1() )); 16 Log(("Detecting for %s\n", NC->name().latin1() ));
17 17
18 if( F.open( IO_ReadOnly ) ) { 18 if( F.open( IO_ReadOnly ) ) {
19 // could open file -> read interface and assign 19 // could open file -> read interface and assign
20 QString X; 20 QString X;
21 QTextStream TS(&F); 21 QTextStream TS(&F);
22 X = TS.readLine(); 22 X = TS.readLine();
23 Log(("%s exists\n", S.latin1() )); 23 Log(("%s exists\n", S.latin1() ));
24 // find interface 24 // find interface
25 if( handlesInterface( X ) ) { 25 if( handlesInterface( X ) ) {
26 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 26 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
27 It.current(); 27 It.current();
28 ++It ) { 28 ++It ) {
29 Run = It.current(); 29 Run = It.current();
30 if( X == Run->Name ) { 30 if( X == Run->Name ) {
31 NC->assignInterface( Run ); 31 NC->assignInterface( Run );
32 return IsUp; 32 return IsUp;
33 } 33 }
34 } 34 }
35 } 35 }
36 } 36 }
37 37
38 Log(("Assigned %p\n", NC->assignedInterface() )); 38 Log(("Assigned %p\n", NC->assignedInterface() ));
39 if( ( Run = NC->assignedInterface() ) ) { 39 if( ( Run = NC->assignedInterface() ) ) {
40 // we already have an interface assigned -> still present ? 40 // we already have an interface assigned -> still present ?
41 if( ! Run->IsUp ) { 41 if( ! Run->IsUp ) {
42 // usb is still free -> keep assignment 42 // usb is still free -> keep assignment
43 return Available; 43 return Available;
44 } // else interface is up but NOT us -> some other profile 44 } // else interface is up but NOT us -> some other profile
45 } 45 }
46 46
47 // nothing (valid) assigned to us 47 // nothing (valid) assigned to us
48 NC->assignInterface( 0 ); 48 NC->assignInterface( 0 );
49 49
50 // find possible interface 50 // find possible interface
51 for( QDictIterator<InterfaceInfo> It(Sys.interfaces()); 51 for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
52 It.current(); 52 It.current();
53 ++It ) { 53 ++It ) {
54 Run = It.current(); 54 Run = It.current();
55 55
56 Log(("%s %d %d=%d %d\n", 56 Log(("%s %d %d=%d %d\n",
57 Run->Name.latin1(), 57 Run->Name.latin1(),
58 handlesInterface( Run->Name ), 58 handlesInterface( Run->Name ),
59 Run->CardType, ARPHRD_ETHER, 59 Run->CardType, ARPHRD_ETHER,
60 ! Run->IsUp )); 60 ! Run->IsUp ));
61 61
62 if( handlesInterface( Run->Name ) && 62 if( handlesInterface( Run->Name ) &&
63 Run->CardType == ARPHRD_ETHER && 63 Run->CardType == ARPHRD_ETHER &&
64 ! Run->IsUp 64 ! Run->IsUp
65 ) { 65 ) {
66 // proper type, and Not UP -> free 66 // proper type, and Not UP -> free
67 return Off; 67 return Off;
68 } 68 }
69 } 69 }
70 70
71 return Unavailable; 71 return Unavailable;
72} 72}
73 73
74QString USBRun::setMyState( NodeCollection *, Action_t , bool ) { 74QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
75
76 // nothing needs to be done to 'activate' or 'deactivate'
77 // 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
75 return QString(); 87 return QString();
76} 88}
77 89
78// get interface that is free or assigned to us 90// get interface that is free or assigned to us
79InterfaceInfo * USBRun::getInterface( void ) { 91InterfaceInfo * USBRun::getInterface( void ) {
80 92
81 System & S = NSResources->system(); 93 System & S = NSResources->system();
82 InterfaceInfo * best = 0, * Run; 94 InterfaceInfo * best = 0, * Run;
83 QRegExp R( "usb[0-9abcdef]" ); 95 QRegExp R( "usb[0-9abcdef]" );
84 96
85 for( QDictIterator<InterfaceInfo> It(S.interfaces()); 97 for( QDictIterator<InterfaceInfo> It(S.interfaces());
86 It.current(); 98 It.current();
87 ++It ) { 99 ++It ) {
88 Run = It.current(); 100 Run = It.current();
89 if( handlesInterface( Run->Name ) && 101 if( handlesInterface( Run->Name ) &&
90 Run->CardType == ARPHRD_ETHER 102 Run->CardType == ARPHRD_ETHER
91 ) { 103 ) {
92 // this is a USB card 104 // this is a USB card
93 if( Run->assignedConnection() == netNode()->connection() ) { 105 if( Run->assignedConnection() == netNode()->connection() ) {
94 // assigned to us 106 // assigned to us
95 return Run; 107 return Run;
96 } else if( Run->assignedConnection() == 0 ) { 108 } else if( Run->assignedConnection() == 0 ) {
97 // free 109 // free
98 best = Run; 110 best = Run;
99 } 111 }
100 } 112 }
101 } 113 }
102 return best; // can be 0 114 return best; // can be 0
103} 115}
104 116
105bool USBRun::handlesInterface( const QString & S ) { 117bool USBRun::handlesInterface( const QString & S ) {
106 return Pat.match( S ) >= 0; 118 return Pat.match( S ) >= 0;
107} 119}
108 120
109bool USBRun::handlesInterface( InterfaceInfo * I ) { 121bool USBRun::handlesInterface( InterfaceInfo * I ) {
110 return handlesInterface( I->Name ); 122 return handlesInterface( I->Name );
111} 123}
112 124