File indexing completed on 2024-03-03 04:00:31

0001 /*
0002     SPDX-FileCopyrightText: 2017 Elvis Angelaccio <elvis.angelaccio@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #undef QT_NO_CAST_FROM_ASCII
0008 
0009 #include <KAuth/Action>
0010 #include <KAuth/ExecuteJob>
0011 
0012 #include <QCoreApplication>
0013 #include <QDebug>
0014 
0015 using namespace KAuth;
0016 
0017 int main(int argc, char **argv)
0018 {
0019     QCoreApplication app(argc, argv);
0020 
0021     QString filename = "foo.txt";
0022 
0023     //! [client_how_to_call_helper]
0024     QVariantMap args;
0025     args["filename"] = filename;
0026     Action readAction("org.kde.kf6auth.example.read");
0027     readAction.setHelperId("org.kde.kf6auth.example");
0028     readAction.setArguments(args);
0029     ExecuteJob *job = readAction.execute();
0030     if (!job->exec()) {
0031         qDebug() << "KAuth returned an error code:" << job->error();
0032     } else {
0033         QString contents = job->data()["contents"].toString();
0034         qDebug() << "KAuth succeeded. Contents: " << contents;
0035     }
0036     //! [client_how_to_call_helper]
0037 
0038     return app.exec();
0039 }