summaryrefslogtreecommitdiff
path: root/noncore
authorharlekin <harlekin>2002-06-28 12:35:13 (UTC)
committer harlekin <harlekin>2002-06-28 12:35:13 (UTC)
commitffcfdb4e932dcbd147b0294aeb70762927cdbc5f (patch) (side-by-side diff)
tree702174c68e4ab9bceee5e445febd4d9d4baa0661 /noncore
parent9607d7d0953b0fbb128d23d3cb2effa9fe0657c4 (diff)
downloadopie-ffcfdb4e932dcbd147b0294aeb70762927cdbc5f.zip
opie-ffcfdb4e932dcbd147b0294aeb70762927cdbc5f.tar.gz
opie-ffcfdb4e932dcbd147b0294aeb70762927cdbc5f.tar.bz2
wrapper for hcid.conf
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/hciconfwrapper.cpp115
-rw-r--r--noncore/net/opietooth/manager/hciconfwrapper.h30
2 files changed, 145 insertions, 0 deletions
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp
new file mode 100644
index 0000000..db6a326
--- a/dev/null
+++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp
@@ -0,0 +1,115 @@
+#include "hciconfwrapper.h"
+
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qstringlist.h>
+#include <qregexp.h>
+
+namespace OpieTooth {
+
+
+ HciConfWrapper::HciConfWrapper( const QString &fileName) {
+ m_fileName = fileName;
+ }
+
+ HciConfWrapper::~HciConfWrapper() {
+ }
+
+
+ void HciConfWrapper::setPinHelper( QString app ) {
+ setValue( "pin_helper" , app );
+ }
+
+ void HciConfWrapper::setName( QString name ) {
+ qDebug ("NAME : " + name);
+ setValue( "name" , "\"" + name + "\"" );
+ }
+
+ void HciConfWrapper::setIscan( bool enable) {
+
+ if ( enable ) {
+ setValue( "iscan" , "enable" );
+ } else {
+ setValue( "iscan" , "disable" );
+ }
+ }
+
+ void HciConfWrapper::setPscan( bool enable) {
+
+ if ( enable ) {
+ setValue( "pscan" , "enable" );
+ } else {
+ setValue( "pscan" , "disable" );
+ }
+ }
+
+
+ void HciConfWrapper::setAuth( bool enable) {
+
+ if ( enable ) {
+ setValue( "auth" , "enable" );
+ } else {
+ setValue( "auth" , "disable" );
+ }
+ }
+
+
+ void HciConfWrapper::setEncrypt( bool enable) {
+
+ if ( enable ) {
+ setValue( "encrypt" , "enable" );
+ } else {
+ setValue( "encrypt" , "disable" );
+ }
+ }
+
+
+ void HciConfWrapper::setValue(const QString &key, const QString &value ) {
+
+ QFile f( m_fileName );
+ QFile f2( m_fileName );
+
+ if ( !f.open( IO_ReadOnly) ) {
+ qDebug("Could not open readonly");
+ return;
+ }
+
+ if ( !f2.open( IO_ReadWrite ) ) {
+ qDebug("Just readonly - not enough");
+ return;
+ }
+
+ QStringList list;
+ qDebug(m_fileName);
+ QTextStream stream ( &f);
+ QTextStream outstream (&f2);
+
+ QString str;
+ while ( !(str=stream.readLine()).isNull() ) {
+
+
+ //qDebug(str);
+ if( (str.contains(key)) > 0 ) {
+ qDebug("Found");
+ // still need look if its commented out!!!
+ str.simplifyWhiteSpace();
+ qDebug( key );
+ if (str.startsWith("#")) {
+ outstream << (key + " " + value + ";\n");
+ } else {
+ str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";\n");
+ }
+
+ qDebug( str );
+ outstream << str;
+ } else {
+ outstream << str + "\n";
+ }
+ }
+
+ f.close();
+ f2.flush();
+ f2.close();
+ }
+
+}
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.h b/noncore/net/opietooth/manager/hciconfwrapper.h
new file mode 100644
index 0000000..10738c0
--- a/dev/null
+++ b/noncore/net/opietooth/manager/hciconfwrapper.h
@@ -0,0 +1,30 @@
+#ifndef HCICONFWRAPPER_H
+#define HCICONFWRAPPER_H
+
+#include <qstring.h>
+
+namespace OpieTooth {
+
+ class HciConfWrapper {
+
+ public:
+ HciConfWrapper( const QString &fileName );
+ ~HciConfWrapper();
+
+ void setPinHelper( QString app );
+ void setName( QString name );
+ void setIscan( bool enable );
+ void setPscan( bool enable );
+ void setAuth( bool enable);
+ void setEncrypt( bool enable);
+
+ private:
+
+ void setValue(const QString &entry, const QString &value );
+
+ QString m_fileName;
+ };
+
+}
+
+#endif