21 #include <qtextstream.h>
23 #include <QStringList>
25 static QTextStream
qcin ( stdin, QIODevice::ReadOnly );
26 static QTextStream
qcout( stdout, QIODevice::WriteOnly );
27 static QTextStream
qcerr( stderr, QIODevice::WriteOnly );
49 for (
unsigned int i = 0; i < aStr.length(); i++)
50 result += (aStr[i].unicode() < 0x20) ? aStr[i] :
51 QChar(0x1001F - aStr[i].unicode());
55 void parseGroup(
const QString &group,
const QString &rawLine )
59 if ( group ==
"MSN" || group ==
"ICQ" || group ==
"Oscar" || group ==
"Gadu" || group ==
"Jabber" || group ==
"IRC" )
64 if ( group ==
"Oscar" )
74 qcout <<
"# DELETEGROUP [" << group <<
"]" << endl;
79 qcout << rawLine << endl;
83 void parseKey(
const QString &group,
const QString &key,
const QString &value,
const QString &rawLine )
88 if ( key ==
"UserID" )
90 else if ( key ==
"Password" )
92 else if ( key ==
"AutoConnect" )
94 else if ( key ==
"Nick" )
100 else if ( group ==
"ICQ" )
104 else if ( key ==
"Password" )
106 else if ( key ==
"AutoConnect" )
108 else if ( key ==
"Nick" )
110 else if ( key ==
"Server" )
112 else if ( key ==
"Port" )
115 else if ( group ==
"Oscar" )
117 if ( key ==
"ScreenName" )
119 else if ( key ==
"Password" )
121 else if ( key ==
"Server" )
123 else if ( key ==
"Port" )
126 else if ( group ==
"Jabber" )
128 if ( key ==
"UserID" )
130 else if ( key ==
"Password" )
132 if ( key ==
"Server" ||
133 key ==
"Port" || key ==
"UseSSL" || key ==
"Resource" )
136 else if ( group ==
"Gadu" )
140 else if ( key ==
"Password" )
142 else if ( key ==
"Nick" )
145 else if ( group ==
"IRC" )
147 if ( key ==
"Nickname" )
149 if ( key ==
"Server" )
163 else if ( key ==
"Modules" )
165 QString newValue = value;
166 newValue.replace (
".plugin",
".desktop" );
167 qcout <<
"Plugins=" << newValue;
172 qcout << rawLine << endl;
182 if( group ==
"Jabber" )
190 QMap<QString, QString>::ConstIterator it;
192 qcout <<
"PluginData_" <<
protocol <<
"_" << it.key() <<
"=" << it.value() << endl;
198 qcin.setCodec(QTextCodec::codecForName(
"UTF-8"));
199 qcout.setCodec(QTextCodec::codecForName(
"UTF-8"));
203 QRegExp groupRegExp(
"^\\[(.*)\\]" );
204 QRegExp keyRegExp(
"^([a-zA-Z0-9:, _-]*)\\s*=\\s*(.*)\\s*" );
205 QRegExp commentRegExp(
"^(#.*)?$" );
207 while ( !
qcin.atEnd() )
209 QString line =
qcin.readLine();
211 if ( commentRegExp.exactMatch( line ) )
214 qcout << line << endl;
216 else if ( groupRegExp.exactMatch( line ) )
227 curGroup = groupRegExp.capturedTexts()[ 1 ];
230 else if ( keyRegExp.exactMatch( line ) )
233 parseKey( curGroup, keyRegExp.capturedTexts()[ 1 ], keyRegExp.capturedTexts()[ 2 ], line );
237 qcerr <<
"** Unknown input line: " << line << endl;
static QTextStream qcin(stdin, QIODevice::ReadOnly)
static QTextStream qcout(stdout, QIODevice::WriteOnly)
void parseGroup(const QString &group, const QString &rawLine)
QMap< QString, QString > pluginData
void flushData(const QString &group)
void parseKey(const QString &group, const QString &key, const QString &value, const QString &rawLine)
static QTextStream qcerr(stderr, QIODevice::WriteOnly)
QString cryptStr(const QString &aStr)