File: fakeUpower.cpp

package info (click to toggle)
solid 5.78.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 5,100 kB
  • sloc: cpp: 21,549; xml: 464; lex: 111; yacc: 83; sh: 14; makefile: 5
file content (83 lines) | stat: -rw-r--r-- 1,591 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
    SPDX-FileCopyrightText: 2014 Alejandro Fiestas Olivares <afiestas@kde.org>

    SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/

#include "fakeUpower.h"

#include <QDBusConnection>
#include <qdbusmessage.h>

FakeUpower::FakeUpower(QObject* parent) : QObject(parent),
m_onBattery(false)
{

}

QString FakeUpower::daemonVersion() const
{
    return "POP";
}

QString FakeUpower::GetCriticalAction()
{
    return "AAAA";
}

QDBusObjectPath FakeUpower::GetDisplayDevice()
{
    return QDBusObjectPath("AA");
}

bool FakeUpower::isDocked() const
{
    return true;
}

bool FakeUpower::lidIsClosed() const
{
    return false;
}

bool FakeUpower::lidIsPresent() const
{
    return true;
}

bool FakeUpower::onBattery() const
{
    return m_onBattery;
}

void FakeUpower::setOnBattery(bool onBattery)
{
    m_onBattery = onBattery;

    emitPropertiesChanged(QStringLiteral("OnBattery"), m_onBattery);
}

void FakeUpower::emitPropertiesChanged(const QString& name, const QVariant& value)
{
    auto msg = QDBusMessage::createSignal(
        QStringLiteral("/org/freedesktop/UPower"),
        QStringLiteral("org.freedesktop.DBus.Properties"),
        QStringLiteral("PropertiesChanged"));

    QVariantMap map;
    map.insert(name, value);
    QList<QVariant> args;
    args << QString("org.freedesktop.UPower");
    args << map;
    args << QStringList();

    msg.setArguments(args);

    QDBusConnection::systemBus().asyncCall(msg);
}

QList< QDBusObjectPath > FakeUpower::EnumerateDevices()
{
    QList<QDBusObjectPath> list;
    return list;
}