summaryrefslogtreecommitdiff
path: root/noncore/net
authorkorovkin <korovkin>2006-04-04 12:16:09 (UTC)
committer korovkin <korovkin>2006-04-04 12:16:09 (UTC)
commit76276b77e99897ae264aa5b171191521edada420 (patch) (unidiff)
treeb182f312ecac405b3eff0938272692cb414d51fe /noncore/net
parent57f97a65fc7ce932231585895f358f1089900879 (diff)
downloadopie-76276b77e99897ae264aa5b171191521edada420.zip
opie-76276b77e99897ae264aa5b171191521edada420.tar.gz
opie-76276b77e99897ae264aa5b171191521edada420.tar.bz2
Modified parser so it ignores lines like something_key_something.
Diffstat (limited to 'noncore/net') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/hciconfwrapper.cpp45
-rw-r--r--noncore/net/opietooth/manager/hciconfwrapper.h10
2 files changed, 43 insertions, 12 deletions
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp
index 47e170e..2413f2b 100644
--- a/noncore/net/opietooth/manager/hciconfwrapper.cpp
+++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp
@@ -1,3 +1,13 @@
1/* $Id$ */
2/* hcid.conf parser */
3/***************************************************************************
4 * *
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 *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 ***************************************************************************/
1#include "hciconfwrapper.h" 11#include "hciconfwrapper.h"
2 12
3#include <qfile.h> 13#include <qfile.h>
@@ -50,8 +60,10 @@ namespace OpieTooth {
50 60
51 if ( enable ) { 61 if ( enable ) {
52 setValue( "auth" , "enable" ); 62 setValue( "auth" , "enable" );
63 setValue( "security" , "auto" );
53 } else { 64 } else {
54 setValue( "auth" , "disable" ); 65 setValue( "auth" , "disable" );
66 setValue( "security" , "none" );
55 } 67 }
56 } 68 }
57 69
@@ -74,26 +86,35 @@ namespace OpieTooth {
74 QStringList::Iterator it; 86 QStringList::Iterator it;
75 87
76 QString str; 88 QString str;
89 QString tmpLine;
90 bool wasCommented = false; //If the optin string was commented out
91 QRegExp rx1("^" + key + "[ ]+"); //Regexp fo key searching
92 QRegExp rx2(";[ ]*" + key + "[ ]+"); //Regexp fo key searching
77 for (it = m_file.begin(); it != m_file.end(); ++it ) { 93 for (it = m_file.begin(); it != m_file.end(); ++it ) {
94 wasCommented = false;
78 str = (*it); 95 str = (*it);
79 if( (str.contains(key)) > 0 ) { 96 tmpLine = str.simplifyWhiteSpace();
80 odebug << "Found" << oendl; 97 //If it's commented out, remove the comment and check again
81 // still need to look if its commented out!!! 98 //Now, let's check if this is a real keyword (not word_keyword)
82 str.simplifyWhiteSpace(); 99 if (tmpLine.startsWith("#")) {
83 odebug << key << oendl; 100 tmpLine.remove(0, 1);
84 if (str.startsWith("#")) { 101 tmpLine = tmpLine.simplifyWhiteSpace();
85 str = (key + " " + value + ";"); 102 wasCommented = true;
86 } else { 103 }
87 str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";"); 104 if( (tmpLine.contains(rx1)) > 0 || (tmpLine.contains(rx2)) > 0) {
88 } 105 odebug << "Found " + key << oendl;
106
107 if (wasCommented)
108 str = ("\t" + key + " " + value + ";");
109 else
110 str = str.replace(QRegExp("\\s*" + key + "\\s+[^\\s][^;]*;"),
111 "\t" + key + " " + value + ";");
89 odebug << str << oendl; 112 odebug << str << oendl;
90 it = m_file.remove( it ); 113 it = m_file.remove( it );
91 it = m_file.insert( it, str ); 114 it = m_file.insert( it, str );
92 //return; the regexp is too wide -zecke // all set 115 //return; the regexp is too wide -zecke // all set
93 } 116 }
94 } 117 }
95
96
97 } 118 }
98 119
99 /** 120 /**
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.h b/noncore/net/opietooth/manager/hciconfwrapper.h
index 0c4b290..5bf483c 100644
--- a/noncore/net/opietooth/manager/hciconfwrapper.h
+++ b/noncore/net/opietooth/manager/hciconfwrapper.h
@@ -1,3 +1,13 @@
1/* $Id$ */
2/* hcid.conf parser */
3/***************************************************************************
4 * *
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 *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 ***************************************************************************/
1#ifndef HCICONFWRAPPER_H 11#ifndef HCICONFWRAPPER_H
2#define HCICONFWRAPPER_H 12#define HCICONFWRAPPER_H
3 13