#include "usdhelper.h"
#include <QCoreApplication>
#include <QDebug>
#include <QDBusConnection>
#include <QDBusInterface>
#include <QDBusConnectionInterface>

const static QString usdService = QStringLiteral("org.ukui.SettingsDaemon");
const static QString usdMediaKeysPath = QStringLiteral("/org/ukui/SettingsDaemon/MediaKeys");
const static QString usdMediaKeysInterface = QStringLiteral("org.ukui.SettingsDaemon.MediaKeys");

UsdHelper::UsdHelper(QObject *parent) : QObject(parent)
{
    usdInterface = new QDBusInterface(usdService,
                                       usdMediaKeysPath,
                                       usdMediaKeysInterface,
                                       QDBusConnection::sessionBus(),
                                       this);
}


UsdHelper::~UsdHelper()
{

}

bool UsdHelper::usdExternalDoAction(int actionType)
{
    QDBusPendingCall result = usdInterface->asyncCall("externalDoAction", actionType, "screensaver");
    if (result.reply().type() == QDBusMessage::ErrorMessage) {
        qWarning() << "setDefaultDevice error!!!!!!!!!!!!!!";
        return false;
    }
    return true;
}
