• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/kopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • kopete
  • kconf_update
kopete-pluginloader2.cpp
Go to the documentation of this file.
1 /*
2  kconf_update app for migrating the list of loaded plugins in
3  kopete 0.7.x to the new KPluginSelector format.
4 
5  Copyright (c) 2003 by Martijn Klingens <klingens@kde.org>
6 
7  Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
8 
9  *************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2 of the License, or (at your option) any later version. *
15  * *
16  *************************************************************************
17 */
18 
19 #include <qtextstream.h>
20 #include <qregexp.h>
21 #include <QStringList>
22 
23 static QTextStream qcin ( stdin, QIODevice::ReadOnly );
24 static QTextStream qcout( stdout, QIODevice::WriteOnly );
25 static QTextStream qcerr( stderr, QIODevice::WriteOnly );
26 
27 void parseKey( const QString &group, const QString &key, const QString &value, const QString &rawLine )
28 {
29  //qcerr << "*** group='" << group << "'" << endl;
30  if ( group.isEmpty() && key == "Plugins" )
31  {
32  QStringList plugins = QStringList::split( ',', value );
33  if ( !plugins.isEmpty() )
34  {
35  qcout << "[Plugins]" << endl;
36  for ( QStringList::Iterator it = plugins.begin(); it != plugins.end(); ++it )
37  qcout << "kopete_" << ( *it ).remove( ".desktop" ) << "Enabled=true" << endl;
38  }
39  qcout << "# DELETE []Plugins" << endl;
40  }
41  else
42  {
43  // groups we don't convert. output the raw line instead.
44  qcout << rawLine << endl;
45  }
46 }
47 
48 int main()
49 {
50  qcin.setCodec(QTextCodec::codecForName("UTF-8"));
51  qcout.setCodec(QTextCodec::codecForName("UTF-8"));
52 
53  QString curGroup;
54 
55  QRegExp groupRegExp( "^\\[(.*)\\]" );
56  QRegExp keyRegExp( "^([a-zA-Z0-9:, _-]*)\\s*=\\s*(.*)\\s*" );
57  QRegExp commentRegExp( "^(#.*)?$" );
58 
59  while ( !qcin.atEnd() )
60  {
61  QString line = qcin.readLine();
62 
63  if ( commentRegExp.exactMatch( line ) )
64  {
65  // We found a comment, leave unchanged
66  qcout << line << endl;
67  }
68  else if ( groupRegExp.exactMatch( line ) )
69  {
70  // We found the start of a group, leave unchanged
71  qcout << line << endl;
72 
73  curGroup = groupRegExp.capturedTexts()[ 1 ];
74  }
75  else if ( keyRegExp.exactMatch( line ) )
76  {
77  // We found the a key line
78  parseKey( curGroup, keyRegExp.capturedTexts()[ 1 ], keyRegExp.capturedTexts()[ 2 ], line );
79  }
80  else
81  {
82  qcerr << "** Unknown input line: " << line << endl;
83  }
84  }
85 
86  return 0;
87 }
88 
89 // vim: set noet ts=4 sts=4 sw=4:
90 
QTextStream::setCodec
void setCodec(QTextCodec *codec)
QTextStream::readLine
QString readLine(qint64 maxlen)
parseKey
void parseKey(const QString &group, const QString &key, const QString &value, const QString &rawLine)
Definition: kopete-pluginloader2.cpp:27
QTextStream
qcout
static QTextStream qcout(stdout, QIODevice::WriteOnly)
qcerr
static QTextStream qcerr(stderr, QIODevice::WriteOnly)
QRegExp
QTextStream::atEnd
bool atEnd() const
QRegExp::capturedTexts
QStringList capturedTexts() const
QList::isEmpty
bool isEmpty() const
QString::isEmpty
bool isEmpty() const
QList::Iterator
typedef Iterator
QString
main
int main()
Definition: kopete-pluginloader2.cpp:48
QStringList
QList::end
iterator end()
qcin
static QTextStream qcin(stdin, QIODevice::ReadOnly)
QTextCodec::codecForName
QTextCodec * codecForName(const QByteArray &name)
QStringList::split
QStringList split(const QString &sep, const QString &str, bool allowEmptyEntries)
QRegExp::exactMatch
bool exactMatch(const QString &str) const
QList::begin
iterator begin()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/kopete

Skip menu "kopete/kopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal