Loading...
Searching...
No Matches
dbuslomirisessionservice.h
/*
* Copyright (C) 2014, 2015 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DBUSLOMIRISESSIONSERVICE_H
#define DBUSLOMIRISESSIONSERVICE_H
#include <QDBusObjectPath>
#include "lomiridbusobject.h"
typedef QList<QDBusObjectPath> QDbusList;
Q_DECLARE_METATYPE(QList<QDBusObjectPath>)
class DBusLomiriSessionService : public LomiriDBusObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "com.lomiri.Shell.Session")
public:
DBusLomiriSessionService();
~DBusLomiriSessionService() = default;
// For use in QML. Javascript doesn't accept functions beginning with capital letters
Q_INVOKABLE void logout() { Logout(); }
Q_INVOKABLE void reboot() { Reboot(); }
Q_INVOKABLE void shutdown() { Shutdown(); }
Q_INVOKABLE void endSession() { EndSession(); }
// TODO: remove duplicate signals and split D-Bus and QML API's
// Apparently QML needs the signals in lowercase, while DBUS spec needs the uppercase version
Q_SIGNALS:
Q_SCRIPTABLE void LogoutRequested(bool have_inhibitors);
void logoutRequested(bool have_inhibitors);
Q_SCRIPTABLE void RebootRequested(bool have_inhibitors);
void rebootRequested(bool have_inhibitors);
Q_SCRIPTABLE void ShutdownRequested(bool have_inhibitors);
void shutdownRequested(bool have_inhibitors);
Q_SCRIPTABLE void LogoutReady();
void logoutReady();
Q_SCRIPTABLE void LockRequested();
void lockRequested();
Q_SCRIPTABLE void Locked();
Q_SCRIPTABLE void Unlocked();
void unlocked();
public Q_SLOTS:
Q_SCRIPTABLE void Logout();
Q_SCRIPTABLE void Reboot();
Q_SCRIPTABLE void Shutdown();
Q_SCRIPTABLE void Suspend();
Q_SCRIPTABLE void Hibernate();
Q_SCRIPTABLE void HybridSleep();
Q_SCRIPTABLE void RequestLogout();
Q_SCRIPTABLE void RequestReboot();
Q_SCRIPTABLE void RequestShutdown();
Q_SCRIPTABLE void EndSession();
Q_SCRIPTABLE bool CanHibernate() const;
Q_SCRIPTABLE bool CanSuspend() const;
Q_SCRIPTABLE bool CanHybridSleep() const;
Q_SCRIPTABLE bool CanReboot() const;
Q_SCRIPTABLE bool CanShutdown() const;
Q_SCRIPTABLE bool CanLock() const;
Q_SCRIPTABLE QString UserName() const;
Q_SCRIPTABLE QString RealName() const;
Q_SCRIPTABLE QString HostName() const;
Q_SCRIPTABLE void PromptLock();
Q_SCRIPTABLE void Lock();
Q_SCRIPTABLE bool IsLocked() const;
private Q_SLOTS:
void doUnlock();
private:
void switchToGreeter();
};
class DBusGnomeSessionManagerWrapper : public LomiriDBusObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager")
public:
DBusGnomeSessionManagerWrapper();
~DBusGnomeSessionManagerWrapper() = default;
public Q_SLOTS:
Q_SCRIPTABLE void Logout(quint32 mode);
Q_SCRIPTABLE void Reboot();
Q_SCRIPTABLE void RequestReboot();
Q_SCRIPTABLE void RequestShutdown();
Q_SCRIPTABLE void Shutdown();
};
class DBusGnomeSessionManagerDialogWrapper : public LomiriDBusObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager.EndSessionDialog")
public:
DBusGnomeSessionManagerDialogWrapper();
~DBusGnomeSessionManagerDialogWrapper() = default;
public Q_SLOTS:
Q_SCRIPTABLE void Open(const unsigned int type, const unsigned int arg_1, const unsigned int max_wait, const QList<QDBusObjectPath> &inhibitors);
};
class DBusGnomeScreensaverWrapper: public LomiriDBusObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.gnome.ScreenSaver")
public:
DBusGnomeScreensaverWrapper();
~DBusGnomeScreensaverWrapper() = default;
public Q_SLOTS:
Q_SCRIPTABLE bool GetActive() const;
Q_SCRIPTABLE void SetActive(bool lock);
Q_SCRIPTABLE void Lock();
Q_SCRIPTABLE quint32 GetActiveTime() const;
Q_SCRIPTABLE void SimulateUserActivity();
Q_SIGNALS:
void ActiveChanged(bool active);
};
class DBusScreensaverWrapper: public LomiriDBusObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.ScreenSaver")
public:
DBusScreensaverWrapper();
~DBusScreensaverWrapper() = default;
public Q_SLOTS:
Q_SCRIPTABLE bool GetActive() const;
Q_SCRIPTABLE bool SetActive(bool lock);
Q_SCRIPTABLE void Lock();
Q_SCRIPTABLE quint32 GetActiveTime() const;
Q_SCRIPTABLE quint32 GetSessionIdleTime() const;
Q_SCRIPTABLE void SimulateUserActivity();
Q_SIGNALS:
void ActiveChanged(bool active);
};
#endif // DBUSLOMIRISESSIONSERVICE_H
DBusLomiriSessionService::PromptLock
Q_SCRIPTABLE void PromptLock()
Definition dbuslomirisessionservice.cpp:421
DBusLomiriSessionService::Logout
Q_SCRIPTABLE void Logout()
Definition dbuslomirisessionservice.cpp:339
DBusLomiriSessionService::LogoutReady
Q_SCRIPTABLE void LogoutReady()
DBusLomiriSessionService::HostName
Q_SCRIPTABLE QString HostName() const
Definition dbuslomirisessionservice.cpp:410
DBusLomiriSessionService::Lock
Q_SCRIPTABLE void Lock()
Definition dbuslomirisessionservice.cpp:432
DBusLomiriSessionService::IsLocked
Q_SCRIPTABLE bool IsLocked() const
Definition dbuslomirisessionservice.cpp:490
DBusLomiriSessionService::Reboot
Q_SCRIPTABLE void Reboot()
Definition dbuslomirisessionservice.cpp:501
DBusLomiriSessionService::Unlocked
Q_SCRIPTABLE void Unlocked()
DBusLomiriSessionService::RequestShutdown
Q_SCRIPTABLE void RequestShutdown()
Definition dbuslomirisessionservice.cpp:535
DBusLomiriSessionService::LockRequested
Q_SCRIPTABLE void LockRequested()
DBusLomiriSessionService::ShutdownRequested
Q_SCRIPTABLE void ShutdownRequested(bool have_inhibitors)
DBusLomiriSessionService::RequestReboot
Q_SCRIPTABLE void RequestReboot()
Definition dbuslomirisessionservice.cpp:506
DBusLomiriSessionService::RebootRequested
Q_SCRIPTABLE void RebootRequested(bool have_inhibitors)
DBusLomiriSessionService::Locked
Q_SCRIPTABLE void Locked()
DBusLomiriSessionService::Hibernate
Q_SCRIPTABLE void Hibernate()
Definition dbuslomirisessionservice.cpp:523
DBusLomiriSessionService::HybridSleep
Q_SCRIPTABLE void HybridSleep()
Definition dbuslomirisessionservice.cpp:529
DBusLomiriSessionService::Suspend
Q_SCRIPTABLE void Suspend()
Definition dbuslomirisessionservice.cpp:517
DBusLomiriSessionService::CanHybridSleep
Q_SCRIPTABLE bool CanHybridSleep() const
Definition dbuslomirisessionservice.cpp:365
DBusLomiriSessionService::CanHibernate
Q_SCRIPTABLE bool CanHibernate() const
Definition dbuslomirisessionservice.cpp:355
DBusLomiriSessionService::LogoutRequested
Q_SCRIPTABLE void LogoutRequested(bool have_inhibitors)
DBusLomiriSessionService::CanShutdown
Q_SCRIPTABLE bool CanShutdown() const
Definition dbuslomirisessionservice.cpp:375
DBusLomiriSessionService::CanLock
Q_SCRIPTABLE bool CanLock() const
Definition dbuslomirisessionservice.cpp:380
DBusLomiriSessionService::EndSession
Q_SCRIPTABLE void EndSession()
Definition dbuslomirisessionservice.cpp:346
DBusLomiriSessionService::RealName
Q_SCRIPTABLE QString RealName() const
Definition dbuslomirisessionservice.cpp:396
DBusLomiriSessionService::CanReboot
Q_SCRIPTABLE bool CanReboot() const
Definition dbuslomirisessionservice.cpp:370
DBusLomiriSessionService::RequestLogout
Q_SCRIPTABLE void RequestLogout()
Definition dbuslomirisessionservice.cpp:495
DBusLomiriSessionService::Shutdown
Q_SCRIPTABLE void Shutdown()
Definition dbuslomirisessionservice.cpp:512
DBusLomiriSessionService::UserName
Q_SCRIPTABLE QString UserName() const
Definition dbuslomirisessionservice.cpp:391
DBusLomiriSessionService::CanSuspend
Q_SCRIPTABLE bool CanSuspend() const
Definition dbuslomirisessionservice.cpp:360