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