File: main.cpp

package info (click to toggle)
kf6-networkmanager-qt 6.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,120 kB
  • sloc: cpp: 27,725; xml: 1,079; sh: 13; makefile: 7
file content (61 lines) | stat: -rw-r--r-- 2,103 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
    SPDX-FileCopyrightText: 2023 Ilya Katsnelson <me@0upti.me>

    SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include <QCoreApplication>
#include <QDebug>

#include <NetworkManagerQt/GenericTypes>
#include <NetworkManagerQt/SecretAgent>

class TestAgent: public NetworkManager::SecretAgent {
public:
    explicit TestAgent(QObject *parent = nullptr)
    : NetworkManager::SecretAgent(QStringLiteral("org.kde.plasma.example-agent"), NetworkManager::SecretAgent::Capability::VpnHints, parent)
    {
        qInfo() << "Starting fake secret agent";
    }

public Q_SLOTS:
    NMVariantMapMap GetSecrets(const NMVariantMapMap &connection,
                                       const QDBusObjectPath &connection_path,
                                       const QString &setting_name,
                                       const QStringList &hints,
                                       uint flags) override
    {
        qInfo() << "GetSecrets" \
            << "connection:" << connection \
            << "path:" << connection_path.path() \
            << "name:" << setting_name \
            << "hints:" << hints \
            << "flags:" << flags;
        return NMVariantMapMap();
    }

    void CancelGetSecrets(const QDBusObjectPath &connection_path, const QString &setting_name) override
    {
        qInfo() << "CancelGetSecrets" << "path:" << connection_path.path() << "name:" << setting_name; 
    }
    
    void SaveSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path) override
    {
        qInfo() << "SaveSecrets" \
            << "connection:" << connection \
            << "path:" << connection_path.path();
    }

    void DeleteSecrets(const NMVariantMapMap &connection, const QDBusObjectPath &connection_path) override
    {
        qInfo() << "DeleteSecrets" \
            << "connection:" << connection \
            << "path:" << connection_path.path();
    }
};

int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);
    auto agent = TestAgent(&app);
    return app.exec();
}