author | zecke <zecke> | 2002-07-14 18:04:14 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-07-14 18:04:14 (UTC) |
commit | 26c7e63572e729b4846e4f7551bb041aa6d4bd83 (patch) (side-by-side diff) | |
tree | 5c3bc09142bd19e84fbebb88f2e37b02e6d603cd /noncore/net/opietooth/manager/hciconfwrapper.cpp | |
parent | 31e233a6cf72bc853137ea05285f4d0f41665365 (diff) | |
download | opie-26c7e63572e729b4846e4f7551bb041aa6d4bd83.zip opie-26c7e63572e729b4846e4f7551bb041aa6d4bd83.tar.gz opie-26c7e63572e729b4846e4f7551bb041aa6d4bd83.tar.bz2 |
- able to configure HCID
- able to save and restore known devices
- able to scan servivces and shows the right pixmap too
- able to do some more
- scan dialog clean up ( tiny )
Diffstat (limited to 'noncore/net/opietooth/manager/hciconfwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/hciconfwrapper.cpp | 74 |
1 files changed, 51 insertions, 23 deletions
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp index 5f74fee..46eed42 100644 --- a/noncore/net/opietooth/manager/hciconfwrapper.cpp +++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp @@ -67,27 +67,12 @@ namespace OpieTooth { 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"); + if (m_file.isEmpty() ) // load first return; - } - - if ( !f2.open( IO_ReadWrite ) ) { - qDebug("Just readonly - not enough"); - return; - } - QStringList list; - qDebug(m_fileName); - QTextStream stream ( &f); - QTextStream outstream (&f2); + QStringList::Iterator it; QString str; - while ( !(str=stream.readLine()).isNull() ) { - - - //qDebug(str); + for (it = m_file.begin(); it != m_file.end(); ++it ) { + str = (*it); if( (str.contains(key)) > 0 ) { qDebug("Found"); @@ -101,12 +86,55 @@ namespace OpieTooth { } qDebug( str ); + it = m_file.remove( it ); + it = m_file.insert( it, str ); + //return; the regexp is too wide -zecke // all set } - outstream << str << endl; } - f.close(); - f2.flush(); - f2.close(); } + + /** + * This loads the config file and stores it inside + * the m_file + */ + void HciConfWrapper::load() { + qWarning("loaded"); + m_file.clear(); + QFile file( m_fileName ); + if (!file.open( IO_ReadOnly ) ) { + qDebug("Could not open"); + return; + } + + /** + * readAll() into a QByteArray + * QStringList::split('\n', array ) + * would this be faster? -zecke + */ + QTextStream stream(&file ); + QString tmp; + while ( !stream.atEnd() ) { + tmp = stream.readLine(); + m_file.append( tmp ); + } + } + void HciConfWrapper::save() { + qWarning("save"); + if (m_file.isEmpty() ) // load first + return; + + QFile file( m_fileName ); + if ( !file.open(IO_WriteOnly ) ) { + qWarning("could not open %s", m_fileName.latin1() ); + return; + } + + QTextStream stream(&file ); + QStringList::Iterator it; + for ( it = m_file.begin(); it != m_file.end(); ++it ) { + stream << (*it) << endl; + } + qWarning("saved"); + }; } |