aboutsummaryrefslogtreecommitdiff
path: root/libcontextsubscriber/reg-cli/print-info.cpp
blob: 55d4c2cec08eed14d4e3940852001e5f790d3525 (plain)
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
#include "contextproperty.h"
#include "contextpropertyinfo.h"
#include <QCoreApplication>
#include <QString>
#include <QStringList>
#include <QMap>
#include <QDebug>

int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);

    QStringList args = app.arguments();
    if (args.count() <= 1)
        qWarning() << "Usage: print-info PROPERTY...";

    args.pop_front();
    QTextStream out(stdout);

    foreach (QString key, args) {
        ContextProperty property(key);
        const ContextPropertyInfo* info = property.info();
        if (info == 0) {
            qWarning() << "Info for property" << key << "not available";
            return 1;
        }
        out << "Key: " << key << endl;
        out << "Existance: " << (info->exists() ? "true" : "false")  << endl;
        QDBusConnection::BusType busType = info->providerDBusType();
        out << "Provider DBus type: " << (busType == QDBusConnection::SessionBus ? "session" : "system") << endl;
        out << "Provider DBus name: " << info->providerDBusName() << endl;
        out << "Documentation: " << info->doc() << endl;
    }

    return 0;
}