Akonadi

akonadi2xml.cpp
1 /*
2  SPDX-FileCopyrightText: 2009 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "xmlwritejob.h"
8 
9 #include "collection.h"
10 #include "collectionpathresolver.h"
11 
12 #include <KAboutData>
13 #include <KLocalizedString>
14 #include <QApplication>
15 #include <QCommandLineParser>
16 #include <QDebug>
17 
18 using namespace Akonadi;
19 
20 int main(int argc, char *argv[])
21 {
22  QApplication app(argc, argv);
23 
24  KAboutData aboutData(QStringLiteral("akonadi2xml"),
25  i18n("Akonadi To XML converter"),
26  QStringLiteral("1.0"),
27  i18n("Converts an Akonadi collection subtree into a XML file."),
29  i18n("(c) 2009 Volker Krause <[email protected]>"));
30 
31  QCommandLineParser parser;
33 
34  aboutData.setupCommandLine(&parser);
35  parser.process(app);
36  aboutData.processCommandLine(&parser);
37 
38  Collection root;
39  if (parser.isSet(QStringLiteral("collection"))) {
40  const QString path = parser.value(QStringLiteral("collection"));
41  CollectionPathResolver resolver(path);
42  if (!resolver.exec()) {
43  qCritical() << resolver.errorString();
44  return -1;
45  }
46  root = Collection(resolver.collection());
47  } else {
48  return -1;
49  }
50 
51  XmlWriteJob writer(root, parser.value(QStringLiteral("output")));
52  if (!writer.exec()) {
53  qCritical() << writer.exec();
54  return -1;
55  }
56 }
static void setApplicationData(const KAboutData &aboutData)
Represents a collection of PIM items.
Definition: collection.h:61
Serializes a given Akonadi collection into a XML file.
Definition: xmlwritejob.h:24
QString i18n(const char *text, const TYPE &arg...)
void process(const QStringList &arguments)
QString value(const QString &optionName) const const
bool isSet(const QString &name) const const
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:46 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.