mirror of https://github.com/cutefishos/core
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#include "actions.h"
|
|
#include <QCommandLineParser>
|
|
#include <QDBusInterface>
|
|
#include <QApplication>
|
|
|
|
const static QString s_dbusName = "org.cutefish.Session";
|
|
const static QString s_pathName = "/Session";
|
|
const static QString s_interfaceName = "org.cutefish.Session";
|
|
|
|
Actions::Actions(QObject *parent)
|
|
: QObject(parent)
|
|
{
|
|
|
|
}
|
|
|
|
void Actions::shutdown()
|
|
{
|
|
QDBusInterface iface(s_dbusName, s_pathName, s_interfaceName, QDBusConnection::sessionBus());
|
|
if (iface.isValid()) {
|
|
iface.call("powerOff");
|
|
}
|
|
}
|
|
|
|
void Actions::logout()
|
|
{
|
|
QDBusInterface iface(s_dbusName, s_pathName, s_interfaceName, QDBusConnection::sessionBus());
|
|
if (iface.isValid()) {
|
|
iface.call("logout");
|
|
}
|
|
}
|
|
|
|
void Actions::reboot()
|
|
{
|
|
QDBusInterface iface(s_dbusName, s_pathName, s_interfaceName, QDBusConnection::sessionBus());
|
|
if (iface.isValid()) {
|
|
iface.call("reboot");
|
|
}
|
|
}
|
|
|
|
void Actions::suspend()
|
|
{
|
|
QDBusInterface iface(s_dbusName, s_pathName, s_interfaceName, QDBusConnection::sessionBus());
|
|
if (iface.isValid()) {
|
|
iface.call("suspend");
|
|
}
|
|
QCoreApplication::exit(0);
|
|
}
|