summaryrefslogtreecommitdiffstats
path: root/kopete/kopete/kconf_update/kopete-pluginloader2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/kopete/kconf_update/kopete-pluginloader2.cpp')
-rw-r--r--kopete/kopete/kconf_update/kopete-pluginloader2.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/kopete/kopete/kconf_update/kopete-pluginloader2.cpp b/kopete/kopete/kconf_update/kopete-pluginloader2.cpp
new file mode 100644
index 00000000..af8daa69
--- /dev/null
+++ b/kopete/kopete/kconf_update/kopete-pluginloader2.cpp
@@ -0,0 +1,89 @@
+/*
+ kconf_update app for migrating the list of loaded plugins in
+ kopete 0.7.x to the new KPluginSelector format.
+
+ Copyright (c) 2003 by Martijn Klingens <klingens@kde.org>
+
+ Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
+
+ *************************************************************************
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ *************************************************************************
+*/
+
+#include <qtextstream.h>
+#include <qregexp.h>
+
+static QTextStream qcin ( stdin, IO_ReadOnly );
+static QTextStream qcout( stdout, IO_WriteOnly );
+static QTextStream qcerr( stderr, IO_WriteOnly );
+
+void parseKey( const QString &group, const QString &key, const QString &value, const QString &rawLine )
+{
+ //qcerr << "*** group='" << group << "'" << endl;
+ if ( group.isEmpty() && key == "Plugins" )
+ {
+ QStringList plugins = QStringList::split( ',', value );
+ if ( !plugins.isEmpty() )
+ {
+ qcout << "[Plugins]" << endl;
+ for ( QStringList::Iterator it = plugins.begin(); it != plugins.end(); ++it )
+ qcout << "kopete_" << ( *it ).remove( ".desktop" ) << "Enabled=true" << endl;
+ }
+ qcout << "# DELETE []Plugins" << endl;
+ }
+ else
+ {
+ // groups we don't convert. output the raw line instead.
+ qcout << rawLine << endl;
+ }
+}
+
+int main()
+{
+ qcin.setEncoding( QTextStream::UnicodeUTF8 );
+ qcout.setEncoding( QTextStream::UnicodeUTF8 );
+
+ QString curGroup;
+
+ QRegExp groupRegExp( "^\\[(.*)\\]" );
+ QRegExp keyRegExp( "^([a-zA-Z0-9:, _-]*)\\s*=\\s*(.*)\\s*" );
+ QRegExp commentRegExp( "^(#.*)?$" );
+
+ while ( !qcin.atEnd() )
+ {
+ QString line = qcin.readLine();
+
+ if ( commentRegExp.exactMatch( line ) )
+ {
+ // We found a comment, leave unchanged
+ qcout << line << endl;
+ }
+ else if ( groupRegExp.exactMatch( line ) )
+ {
+ // We found the start of a group, leave unchanged
+ qcout << line << endl;
+
+ curGroup = groupRegExp.capturedTexts()[ 1 ];
+ }
+ else if ( keyRegExp.exactMatch( line ) )
+ {
+ // We found the a key line
+ parseKey( curGroup, keyRegExp.capturedTexts()[ 1 ], keyRegExp.capturedTexts()[ 2 ], line );
+ }
+ else
+ {
+ qcerr << "** Unknown input line: " << line << endl;
+ }
+ }
+
+ return 0;
+}
+
+// vim: set noet ts=4 sts=4 sw=4:
+