summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-28 16:46:52 (UTC)
committer harlekin <harlekin>2002-06-28 16:46:52 (UTC)
commit986a23a683f53ab612be03b56dd9bc7c1aeb3651 (patch) (unidiff)
tree6447f2738d30aff40126b327272effdf8745597b
parente72d93a703f4b38109f8f02ec96a759d93b8f91c (diff)
downloadopie-986a23a683f53ab612be03b56dd9bc7c1aeb3651.zip
opie-986a23a683f53ab612be03b56dd9bc7c1aeb3651.tar.gz
opie-986a23a683f53ab612be03b56dd9bc7c1aeb3651.tar.bz2
update
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/hciconfwrapper.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp
index db6a326..7b2497a 100644
--- a/noncore/net/opietooth/manager/hciconfwrapper.cpp
+++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp
@@ -1,115 +1,114 @@
1#include "hciconfwrapper.h" 1 #include "hciconfwrapper.h"
2 2
3#include <qfile.h> 3#include <qfile.h>
4#include <qtextstream.h> 4#include <qtextstream.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6#include <qregexp.h> 6#include <qregexp.h>
7 7
8namespace OpieTooth { 8namespace OpieTooth {
9 9
10 10
11 HciConfWrapper::HciConfWrapper( const QString &fileName) { 11 HciConfWrapper::HciConfWrapper( const QString &fileName) {
12 m_fileName = fileName; 12 m_fileName = fileName;
13 } 13 }
14 14
15 HciConfWrapper::~HciConfWrapper() { 15 HciConfWrapper::~HciConfWrapper() {
16 } 16 }
17 17
18 18
19 void HciConfWrapper::setPinHelper( QString app ) { 19 void HciConfWrapper::setPinHelper( QString app ) {
20 setValue( "pin_helper" , app ); 20 setValue( "pin_helper" , app );
21 } 21 }
22 22
23 void HciConfWrapper::setName( QString name ) { 23 void HciConfWrapper::setName( QString name ) {
24 qDebug ("NAME : " + name); 24 qDebug ("NAME : " + name);
25 setValue( "name" , "\"" + name + "\"" ); 25 setValue( "name" , "\"" + name + "\"" );
26 } 26 }
27 27
28 void HciConfWrapper::setIscan( bool enable) { 28 void HciConfWrapper::setIscan( bool enable) {
29 29
30 if ( enable ) { 30 if ( enable ) {
31 setValue( "iscan" , "enable" ); 31 setValue( "iscan" , "enable" );
32 } else { 32 } else {
33 setValue( "iscan" , "disable" ); 33 setValue( "iscan" , "disable" );
34 } 34 }
35 } 35 }
36 36
37 void HciConfWrapper::setPscan( bool enable) { 37 void HciConfWrapper::setPscan( bool enable) {
38 38
39 if ( enable ) { 39 if ( enable ) {
40 setValue( "pscan" , "enable" ); 40 setValue( "pscan" , "enable" );
41 } else { 41 } else {
42 setValue( "pscan" , "disable" ); 42 setValue( "pscan" , "disable" );
43 } 43 }
44 } 44 }
45 45
46 46
47 void HciConfWrapper::setAuth( bool enable) { 47 void HciConfWrapper::setAuth( bool enable) {
48 48
49 if ( enable ) { 49 if ( enable ) {
50 setValue( "auth" , "enable" ); 50 setValue( "auth" , "enable" );
51 } else { 51 } else {
52 setValue( "auth" , "disable" ); 52 setValue( "auth" , "disable" );
53 } 53 }
54 } 54 }
55 55
56 56
57 void HciConfWrapper::setEncrypt( bool enable) { 57 void HciConfWrapper::setEncrypt( bool enable) {
58 58
59 if ( enable ) { 59 if ( enable ) {
60 setValue( "encrypt" , "enable" ); 60 setValue( "encrypt" , "enable" );
61 } else { 61 } else {
62 setValue( "encrypt" , "disable" ); 62 setValue( "encrypt" , "disable" );
63 } 63 }
64 } 64 }
65 65
66 66
67 void HciConfWrapper::setValue(const QString &key, const QString &value ) { 67 void HciConfWrapper::setValue(const QString &key, const QString &value ) {
68 68
69 QFile f( m_fileName ); 69 QFile f( m_fileName );
70 QFile f2( m_fileName ); 70 QFile f2( m_fileName );
71 71
72 if ( !f.open( IO_ReadOnly) ) { 72 if ( !f.open( IO_ReadOnly) ) {
73 qDebug("Could not open readonly"); 73 qDebug("Could not open readonly");
74 return; 74 return;
75 } 75 }
76 76
77 if ( !f2.open( IO_ReadWrite ) ) { 77 if ( !f2.open( IO_ReadWrite ) ) {
78 qDebug("Just readonly - not enough"); 78 qDebug("Just readonly - not enough");
79 return; 79 return;
80 } 80 }
81 81
82 QStringList list; 82 QStringList list;
83 qDebug(m_fileName); 83 qDebug(m_fileName);
84 QTextStream stream ( &f); 84 QTextStream stream ( &f);
85 QTextStream outstream (&f2); 85 QTextStream outstream (&f2);
86 86
87 QString str; 87 QString str;
88 while ( !(str=stream.readLine()).isNull() ) { 88 while ( !(str=stream.readLine()).isNull() ) {
89 89
90 90
91 //qDebug(str); 91 //qDebug(str);
92 if( (str.contains(key)) > 0 ) { 92 if( (str.contains(key)) > 0 ) {
93 qDebug("Found"); 93 qDebug("Found");
94 // still need look if its commented out!!! 94 // still need to look if its commented out!!!
95 str.simplifyWhiteSpace(); 95 str.simplifyWhiteSpace();
96 qDebug( key ); 96 qDebug( key );
97 if (str.startsWith("#")) { 97 if (str.startsWith("#")) {
98 outstream << (key + " " + value + ";\n"); 98 str = (key + " " + value + ";");
99 } else { 99 } else {
100 str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";\n"); 100 str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";");
101 } 101 }
102 102
103 qDebug( str ); 103 qDebug( str );
104 outstream << str;
105 } else {
106 outstream << str + "\n";
107 } 104 }
105
106 outstream << str << endl;
108 } 107 }
109 108
110 f.close(); 109 f.close();
111 f2.flush(); 110 f2.flush();
112 f2.close(); 111 f2.close();
113 } 112 }
114 113
115} 114}