Akonadi

akonadi2xml.cpp
1 /*
2  Copyright (c) 2009 Volker Krause <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "xmlwritejob.h"
21 
22 #include "collection.h"
23 #include "collectionpathresolver.h"
24 
25 #include <QDebug>
26 #include <QApplication>
27 #include <KAboutData>
28 #include <QCommandLineParser>
29 #include <KLocalizedString>
30 
31 using namespace Akonadi;
32 
33 int main(int argc, char *argv[])
34 {
35  QApplication app(argc, argv);
36 
37  KAboutData aboutData(QStringLiteral("akonadi2xml"),
38  i18n("Akonadi To XML converter"),
39  QStringLiteral("1.0"),
40  i18n("Converts an Akonadi collection subtree into a XML file."),
41  KAboutLicense::GPL,
42  i18n("(c) 2009 Volker Krause <[email protected]>"));
43 
44  QCommandLineParser parser;
46 
47  aboutData.setupCommandLine(&parser);
48  parser.process(app);
49  aboutData.processCommandLine(&parser);
50 
51  Collection root;
52  if (parser.isSet(QStringLiteral("collection"))) {
53  const QString path = parser.value(QStringLiteral("collection"));
54  CollectionPathResolver resolver(path);
55  if (!resolver.exec()) {
56  qCritical() << resolver.errorString();
57  return -1;
58  }
59  root = Collection(resolver.collection());
60  } else {
61  return -1;
62  }
63 
64  XmlWriteJob writer(root, parser.value(QStringLiteral("output")));
65  if (!writer.exec()) {
66  qCritical() << writer.exec();
67  return -1;
68  }
69 }
70 
Serializes a given Akonadi collection into a XML file.
Definition: xmlwritejob.h:35
Represents a collection of PIM items.
Definition: collection.h:76
bool exec()
bool isSet(const QString &name) const const
static void setApplicationData(const KAboutData &aboutData)
void process(const QStringList &arguments)
QString i18n(const char *text, const TYPE &arg...)
Helper integration between Akonadi and Qt.
QString value(const QString &optionName) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed May 27 2020 22:43:36 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.