Diffstat (limited to 'noncore/net/opietooth/manager/hciconfwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/hciconfwrapper.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp index 35e9cd9..71c935c 100644 --- a/noncore/net/opietooth/manager/hciconfwrapper.cpp +++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp | |||
@@ -65,75 +65,75 @@ namespace OpieTooth { | |||
65 | 65 | ||
66 | void HciConfWrapper::setValue(const QString &key, const QString &value ) { | 66 | void HciConfWrapper::setValue(const QString &key, const QString &value ) { |
67 | 67 | ||
68 | if (m_file.isEmpty() ) // load first | 68 | if (m_file.isEmpty() ) // load first |
69 | return; | 69 | return; |
70 | 70 | ||
71 | QStringList::Iterator it; | 71 | QStringList::Iterator it; |
72 | 72 | ||
73 | QString str; | 73 | QString str; |
74 | for (it = m_file.begin(); it != m_file.end(); ++it ) { | 74 | for (it = m_file.begin(); it != m_file.end(); ++it ) { |
75 | str = (*it); | 75 | str = (*it); |
76 | if( (str.contains(key)) > 0 ) { | 76 | if( (str.contains(key)) > 0 ) { |
77 | qDebug("Found"); | 77 | odebug << "Found" << oendl; |
78 | // still need to look if its commented out!!! | 78 | // still need to look if its commented out!!! |
79 | str.simplifyWhiteSpace(); | 79 | str.simplifyWhiteSpace(); |
80 | qDebug( key ); | 80 | odebug << key << oendl; |
81 | if (str.startsWith("#")) { | 81 | if (str.startsWith("#")) { |
82 | str = (key + " " + value + ";"); | 82 | str = (key + " " + value + ";"); |
83 | } else { | 83 | } else { |
84 | str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";"); | 84 | str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";"); |
85 | } | 85 | } |
86 | qDebug( str ); | 86 | odebug << str << oendl; |
87 | it = m_file.remove( it ); | 87 | it = m_file.remove( it ); |
88 | it = m_file.insert( it, str ); | 88 | it = m_file.insert( it, str ); |
89 | //return; the regexp is too wide -zecke // all set | 89 | //return; the regexp is too wide -zecke // all set |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | } | 94 | } |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * This loads the config file and stores it inside | 97 | * This loads the config file and stores it inside |
98 | * the m_file | 98 | * the m_file |
99 | */ | 99 | */ |
100 | void HciConfWrapper::load() { | 100 | void HciConfWrapper::load() { |
101 | qWarning("loaded"); | 101 | owarn << "loaded" << oendl; |
102 | m_file.clear(); | 102 | m_file.clear(); |
103 | QFile file( m_fileName ); | 103 | QFile file( m_fileName ); |
104 | if (!file.open( IO_ReadOnly ) ) { | 104 | if (!file.open( IO_ReadOnly ) ) { |
105 | qDebug("Could not open"); | 105 | odebug << "Could not open" << oendl; |
106 | return; | 106 | return; |
107 | } | 107 | } |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * readAll() into a QByteArray | 110 | * readAll() into a QByteArray |
111 | * QStringList::split('\n', array ) | 111 | * QStringList::split('\n', array ) |
112 | * would this be faster? -zecke | 112 | * would this be faster? -zecke |
113 | */ | 113 | */ |
114 | QTextStream stream(&file ); | 114 | QTextStream stream(&file ); |
115 | QString tmp; | 115 | QString tmp; |
116 | while ( !stream.atEnd() ) { | 116 | while ( !stream.atEnd() ) { |
117 | tmp = stream.readLine(); | 117 | tmp = stream.readLine(); |
118 | m_file.append( tmp ); | 118 | m_file.append( tmp ); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | void HciConfWrapper::save() { | 121 | void HciConfWrapper::save() { |
122 | qWarning("save"); | 122 | owarn << "save" << oendl; |
123 | if (m_file.isEmpty() ) // load first | 123 | if (m_file.isEmpty() ) // load first |
124 | return; | 124 | return; |
125 | 125 | ||
126 | QFile file( m_fileName ); | 126 | QFile file( m_fileName ); |
127 | if ( !file.open(IO_WriteOnly ) ) { | 127 | if ( !file.open(IO_WriteOnly ) ) { |
128 | qWarning("could not open %s", m_fileName.latin1() ); | 128 | owarn << "could not open " << m_fileName.latin1() << "" << oendl; |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | 131 | ||
132 | QTextStream stream(&file ); | 132 | QTextStream stream(&file ); |
133 | QStringList::Iterator it; | 133 | QStringList::Iterator it; |
134 | for ( it = m_file.begin(); it != m_file.end(); ++it ) { | 134 | for ( it = m_file.begin(); it != m_file.end(); ++it ) { |
135 | stream << (*it) << endl; | 135 | stream << (*it) << endl; |
136 | } | 136 | } |
137 | qWarning("saved"); | 137 | owarn << "saved" << oendl; |
138 | }; | 138 | }; |
139 | } | 139 | } |