Diffstat (limited to 'noncore/net/opietooth/manager/rfcommconfhandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/rfcommconfhandler.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/net/opietooth/manager/rfcommconfhandler.cpp b/noncore/net/opietooth/manager/rfcommconfhandler.cpp index 20453e8..2ef95ff 100644 --- a/noncore/net/opietooth/manager/rfcommconfhandler.cpp +++ b/noncore/net/opietooth/manager/rfcommconfhandler.cpp | |||
@@ -47,68 +47,68 @@ RfCommConfHandler::RfCommConfHandler( const QString & filename ) { | |||
47 | RfCommConfHandler::~RfCommConfHandler() { | 47 | RfCommConfHandler::~RfCommConfHandler() { |
48 | 48 | ||
49 | } | 49 | } |
50 | 50 | ||
51 | void RfCommConfHandler::save( QMap<QString, RfCommConfObject*> devices ) { | 51 | void RfCommConfHandler::save( QMap<QString, RfCommConfObject*> devices ) { |
52 | 52 | ||
53 | QFile rfCommConf( "/tmp/test" ); | 53 | QFile rfCommConf( "/tmp/test" ); |
54 | QTextStream outStream( &rfCommConf ); | 54 | QTextStream outStream( &rfCommConf ); |
55 | if ( rfCommConf.open( IO_WriteOnly ) ) { | 55 | if ( rfCommConf.open( IO_WriteOnly ) ) { |
56 | 56 | ||
57 | QMap<QString, RfCommConfObject*>::Iterator it; | 57 | QMap<QString, RfCommConfObject*>::Iterator it; |
58 | for( it = devices.begin(); it != devices.end(); ++it ) { | 58 | for( it = devices.begin(); it != devices.end(); ++it ) { |
59 | outStream << "rfcomm" + QString("%1").arg( it.data()->number() ) + " {\n"; | 59 | outStream << "rfcomm" + QString("%1").arg( it.data()->number() ) + " {\n"; |
60 | outStream << " device " + it.data()->mac() + ";\n"; | 60 | outStream << " device " + it.data()->mac() + ";\n"; |
61 | outStream << " channel " + QString( "%1" ).arg( it.data()->channel() ) + ";\n"; | 61 | outStream << " channel " + QString( "%1" ).arg( it.data()->channel() ) + ";\n"; |
62 | outStream << " comment \"" + it.data()->comment() + "\";\n"; | 62 | outStream << " comment \"" + it.data()->comment() + "\";\n"; |
63 | outStream << "}\n\n"; | 63 | outStream << "}\n\n"; |
64 | } | 64 | } |
65 | 65 | ||
66 | rfCommConf.close(); | 66 | rfCommConf.close(); |
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | 70 | ||
71 | QMap<QString, RfCommConfObject*> RfCommConfHandler::foundEntries() { | 71 | QMap<QString, RfCommConfObject*> RfCommConfHandler::foundEntries() { |
72 | return m_foundEntries; | 72 | return m_foundEntries; |
73 | } | 73 | } |
74 | 74 | ||
75 | void RfCommConfHandler::load() { | 75 | void RfCommConfHandler::load() { |
76 | 76 | ||
77 | QFile rfCommConf( m_filename ); | 77 | QFile rfCommConf( m_filename ); |
78 | if ( rfCommConf.open( IO_ReadOnly ) ) { | 78 | if ( rfCommConf.open( IO_ReadOnly ) ) { |
79 | 79 | ||
80 | QStringList list; | 80 | QStringList list; |
81 | QTextStream inStream( &rfCommConf ); | 81 | QTextStream inStream( &rfCommConf ); |
82 | list = QStringList::split( "\n", inStream.read() ); | 82 | list = QStringList::split( "\n", inStream.read() ); |
83 | 83 | ||
84 | QString number; | 84 | QString number; |
85 | QString mac; | 85 | QString mac; |
86 | QString channel; | 86 | QString channel; |
87 | QString comment; | 87 | QString comment; |
88 | 88 | ||
89 | for ( QStringList::Iterator line=list.begin(); line != list.end(); line++ ) { | 89 | for ( QStringList::Iterator line=list.begin(); line != list.end(); line++ ) { |
90 | 90 | ||
91 | QString tmpLine = ( *line ).stripWhiteSpace(); | 91 | QString tmpLine = ( *line ).stripWhiteSpace(); |
92 | 92 | ||
93 | if ( tmpLine.startsWith("rfcomm") ) { | 93 | if ( tmpLine.startsWith("rfcomm") ) { |
94 | QString number = tmpLine.mid( 6,1 ); | 94 | QString number = tmpLine.mid( 6,1 ); |
95 | qDebug( tmpLine ); | 95 | odebug << tmpLine << oendl; |
96 | qDebug( "TEST " + number ); | 96 | odebug << "TEST " + number << oendl; |
97 | } else if ( tmpLine.startsWith( "}" ) ) { | 97 | } else if ( tmpLine.startsWith( "}" ) ) { |
98 | m_foundEntries.insert( number, new RfCommConfObject( number.toInt(), mac, channel.toInt(), comment ) ); | 98 | m_foundEntries.insert( number, new RfCommConfObject( number.toInt(), mac, channel.toInt(), comment ) ); |
99 | } else if ( tmpLine.startsWith( "device" ) ) { | 99 | } else if ( tmpLine.startsWith( "device" ) ) { |
100 | mac = tmpLine.mid( 7, 17 ); | 100 | mac = tmpLine.mid( 7, 17 ); |
101 | qDebug( "mac" + mac ); | 101 | odebug << "mac" + mac << oendl; |
102 | } else if ( tmpLine.startsWith( "channel" ) ) { | 102 | } else if ( tmpLine.startsWith( "channel" ) ) { |
103 | channel = tmpLine.mid( 8, 1 ); | 103 | channel = tmpLine.mid( 8, 1 ); |
104 | qDebug ( "Channel :" + channel ); | 104 | qDebug ( "Channel :" + channel ); |
105 | } else if ( tmpLine.startsWith( "comment" ) ) { | 105 | } else if ( tmpLine.startsWith( "comment" ) ) { |
106 | comment = tmpLine.mid( 9, tmpLine.find( ';' ) - 9 - 1 ); | 106 | comment = tmpLine.mid( 9, tmpLine.find( ';' ) - 9 - 1 ); |
107 | qDebug( "Comment: " + comment ); | 107 | odebug << "Comment: " + comment << oendl; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | rfCommConf.close(); | 110 | rfCommConf.close(); |
111 | } | 111 | } |
112 | save( m_foundEntries ); | 112 | save( m_foundEntries ); |
113 | qDebug( QString( "ENTries: %1").arg( m_foundEntries.count() ) ); | 113 | odebug << QString( "ENTries: %1").arg( m_foundEntries.count() ) << oendl; |
114 | } | 114 | } |