File indexing completed on 2025-01-05 04:47:12

0001 /*
0002     SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "xmlwritejob.h"
0008 
0009 #include "collection.h"
0010 #include "collectionpathresolver.h"
0011 
0012 #include <KAboutData>
0013 #include <KLocalizedString>
0014 #include <QApplication>
0015 #include <QCommandLineParser>
0016 #include <QDebug>
0017 
0018 using namespace Akonadi;
0019 
0020 int main(int argc, char *argv[])
0021 {
0022     QApplication app(argc, argv);
0023 
0024     KAboutData aboutData(QStringLiteral("akonadi2xml"),
0025                          i18n("Akonadi To XML converter"),
0026                          QStringLiteral("1.0"),
0027                          i18n("Converts an Akonadi collection subtree into a XML file."),
0028                          KAboutLicense::GPL,
0029                          i18n("(c) 2009 Volker Krause <vkrause@kde.org>"));
0030 
0031     QCommandLineParser parser;
0032     KAboutData::setApplicationData(aboutData);
0033 
0034     aboutData.setupCommandLine(&parser);
0035     parser.process(app);
0036     aboutData.processCommandLine(&parser);
0037 
0038     Collection root;
0039     if (parser.isSet(QStringLiteral("collection"))) {
0040         const QString path = parser.value(QStringLiteral("collection"));
0041         CollectionPathResolver resolver(path);
0042         if (!resolver.exec()) {
0043             qCritical() << resolver.errorString();
0044             return -1;
0045         }
0046         root = Collection(resolver.collection());
0047     } else {
0048         return -1;
0049     }
0050 
0051     XmlWriteJob writer(root, parser.value(QStringLiteral("output")));
0052     if (!writer.exec()) {
0053         qCritical() << writer.exec();
0054         return -1;
0055     }
0056 }