Loading...
Searching...
No Matches
DBusLomiriSessionService Class Reference

`#include <plugins/Lomiri/Session/dbuslomirisessionservice.h>`

## Public 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

## 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 Member Functions

Q_INVOKABLE void | logout ()
Q_INVOKABLE void | reboot ()
Q_INVOKABLE void | shutdown ()
Q_INVOKABLE void | endSession ()

## Detailed Description

DBusLomiriSessionService provides com.lomiri.Shell.Session dbus interface.

com.lomiri.Shell.Session interface provides public methods and signals to handle eg. Logout/Reboot/Shutdown.

Definition at line 34 of file dbuslomirisessionservice.h.

## Constructor & Destructor Documentation

## DBusLomiriSessionService()

DBusLomiriSessionService::DBusLomiriSessionService | ( |  | ) |

Definition at line 324 of file dbuslomirisessionservice.cpp.

: LomiriDBusObject(QStringLiteral("/com/lomiri/Shell/Session"), QStringLiteral("com.lomiri.Shell"))
{
if (!d->logindSessionPath.isEmpty()) {
// connect our PromptLock() slot to the logind's session Lock() signal
QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Lock"), this, SLOT(PromptLock()));
// ... and our Unlocked() signal to the logind's session Unlock() signal
// (lightdm handles the unlocking by calling logind's Unlock method which in turn emits this signal we connect to)
QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Unlock"), this, SLOT(doUnlock()));
connect(d, &DBusLomiriSessionServicePrivate::prepareForSleep, this, &DBusLomiriSessionService::PromptLock);
} else {
qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
}
}
DBusLomiriSessionService::PromptLock
Q_SCRIPTABLE void PromptLock()
Definition dbuslomirisessionservice.cpp:421

## Member Function Documentation

## CanHibernate

bool DBusLomiriSessionService::CanHibernate | ( |  | ) | const

slot

Returns
  whether the system is capable of hibernating

Definition at line 355 of file dbuslomirisessionservice.cpp.

{
return d->checkLogin1Call(QStringLiteral("CanHibernate"));
}

## CanHybridSleep

bool DBusLomiriSessionService::CanHybridSleep | ( |  | ) | const

slot

Returns
  whether the system is capable of hybrid sleep

Since
  lomiri

Definition at line 365 of file dbuslomirisessionservice.cpp.

{
return d->checkLogin1Call(QStringLiteral("CanHybridSleep"));
}

## CanLock

bool DBusLomiriSessionService::CanLock | ( |  | ) | const

slot

Returns
  whether the system is capable of locking the session

Definition at line 380 of file dbuslomirisessionservice.cpp.

{
auto user = UserName();
if (user.startsWith(QStringLiteral("guest-")) ||
d->isUserInGroup(user, QStringLiteral("nopasswdlogin"))) {
return false;
} else {
return true;
}
}
DBusLomiriSessionService::UserName
Q_SCRIPTABLE QString UserName() const
Definition dbuslomirisessionservice.cpp:391

## CanReboot

bool DBusLomiriSessionService::CanReboot | ( |  | ) | const

slot

Returns
  whether the system is capable of rebooting

Since
  lomiri

Definition at line 370 of file dbuslomirisessionservice.cpp.

{
return d->checkLogin1Call(QStringLiteral("CanReboot"));
}

## CanShutdown

bool DBusLomiriSessionService::CanShutdown | ( |  | ) | const

slot

Returns
  whether the system is capable of shutting down

Definition at line 375 of file dbuslomirisessionservice.cpp.

{
return d->checkLogin1Call(QStringLiteral("CanPowerOff"));
}

## CanSuspend

bool DBusLomiriSessionService::CanSuspend | ( |  | ) | const

slot

Returns
  whether the system is capable of suspending

Definition at line 360 of file dbuslomirisessionservice.cpp.

{
return d->checkLogin1Call(QStringLiteral("CanSuspend"));
}

## EndSession

void DBusLomiriSessionService::EndSession | ( |  | ) |

slot

Issue an EndSession request.

This method calls the EndSession() Upstart DBus method on the current DBus session bus.

Definition at line 346 of file dbuslomirisessionservice.cpp.

{
const QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("com.lomiri.Upstart"),
QStringLiteral("/com/lomiri/Upstart"),
QStringLiteral("com.lomiri.Upstart0_6"),
QStringLiteral("EndSession"));
QDBusConnection::sessionBus().asyncCall(msg);
}

## endSession()

Q_INVOKABLE void DBusLomiriSessionService::endSession | ( |  | ) |

inline

Definition at line 47 of file dbuslomirisessionservice.h.

{ EndSession(); }
DBusLomiriSessionService::EndSession
Q_SCRIPTABLE void EndSession()
Definition dbuslomirisessionservice.cpp:346

## Hibernate

void DBusLomiriSessionService::Hibernate | ( |  | ) |

slot

Hibernate the system

This method puts the system into hibernation without user's confirmation.

Definition at line 523 of file dbuslomirisessionservice.cpp.

{
PromptLock();
d->makeLogin1Call(QStringLiteral("Hibernate"), {false});
}

## HostName

QString DBusLomiriSessionService::HostName | ( |  | ) | const

slot

Returns
  the local hostname

Definition at line 410 of file dbuslomirisessionservice.cpp.

{
char hostName[512];
if (gethostname(hostName, sizeof(hostName)) == -1) {
qWarning() << "Could not determine local hostname";
return QString();
}
hostName[sizeof(hostName) - 1] = '\0';
return QString::fromLocal8Bit(hostName);
}

## HybridSleep

void DBusLomiriSessionService::HybridSleep | ( |  | ) |

slot

Hybrid sleep

This method puts the system into hybrid sleep without user's confirmation.

Since
  lomiri

Definition at line 529 of file dbuslomirisessionservice.cpp.

{
PromptLock();
d->makeLogin1Call(QStringLiteral("HybridSleep"), {false});
}

## IsLocked

bool DBusLomiriSessionService::IsLocked | ( |  | ) | const

slot

Returns
  whether the session is currently locked

Definition at line 490 of file dbuslomirisessionservice.cpp.

{
return !d->isSessionActive;
}

## Lock

void DBusLomiriSessionService::Lock | ( |  | ) |

slot

Locks the session immediately

Definition at line 432 of file dbuslomirisessionservice.cpp.

{
// Normal lock (with animation, as compared to PromptLock above). Usually
// used by indicator-session to lock the session in place.
//
// FIXME: We also -- as a bit of a hack around indicator-session not fully
// supporting a phone profile -- switch to greeter here. The lomiri7 flow is
// that the user chooses "Lock/Switch" from the indicator, and then can go
// to greeter by selecting "Switch" again from the indicator, which is now
// exposed by the desktop_lockscreen profile. But since in lomiri, we try
// to expose most things all the time, we don't use the separate lockscreen
// profile. Instead, we just go directly to the greeter the first time
// a user presses "Lock/Switch". This isn't what this DBus call is
// supposed to do, but we can live with it for now.
//
// Here's a bug about indicator-session growing a converged Touch profile:
// https://launchpad.net/bugs/1557716
//
// We only do this here in the animated-lock call because that's the only
// time the indicator locks without also asking the display manager to
// switch sessions on us. And since we are switching screens, we also
// don't bother respecting the animate request, simply doing a PromptLock.
PromptLock();
switchToGreeter();
}

## Locked

Q_SCRIPTABLE void DBusLomiriSessionService::Locked | ( |  | ) |

signal

Emitted after the session has been locked.

## LockRequested

Q_SCRIPTABLE void DBusLomiriSessionService::LockRequested | ( |  | ) |

signal

Emitted as a result of calling PromptLock()

## Logout

void DBusLomiriSessionService::Logout | ( |  | ) |

slot

Logout the system.

This method directly logs out the system without user's confirmation. Ordinary applications should avoid calling this method. Please call RequestLogout() to ask the user to decide logout or not.

Definition at line 339 of file dbuslomirisessionservice.cpp.

{
// TODO ask the apps to quit and then emit the signal
Q_EMIT LogoutReady();
Q_EMIT logoutReady();
}
DBusLomiriSessionService::LogoutReady
Q_SCRIPTABLE void LogoutReady()

## logout()

Q_INVOKABLE void DBusLomiriSessionService::logout | ( |  | ) |

inline

Definition at line 44 of file dbuslomirisessionservice.h.

{ Logout(); }
DBusLomiriSessionService::Logout
Q_SCRIPTABLE void Logout()
Definition dbuslomirisessionservice.cpp:339

## LogoutReady

Q_SCRIPTABLE void DBusLomiriSessionService::LogoutReady | ( |  | ) |

signal

LogoutReady signal

This signal is emitted when all the apps are closed. And the system is safe to logout.

## LogoutRequested

Q_SCRIPTABLE void DBusLomiriSessionService::LogoutRequested | ( | bool | have_inhibitors | ) |

signal

LogoutRequested signal

This signal is emitted when some applications request the system to logout.

Parameters

  have_inhibitors | if there are any special running applications which inhibit the logout.

## PromptLock

void DBusLomiriSessionService::PromptLock | ( |  | ) |

slot

Request that the session get locked, emits signal LockRequested()

Definition at line 421 of file dbuslomirisessionservice.cpp.

{
// Prompt as in quick. No locking animation needed. Usually used by
// indicator-session in combination with a switch to greeter or other
// user session.
if (CanLock()) {
Q_EMIT LockRequested();
Q_EMIT lockRequested();
}
}
DBusLomiriSessionService::LockRequested
Q_SCRIPTABLE void LockRequested()
DBusLomiriSessionService::CanLock
Q_SCRIPTABLE bool CanLock() const
Definition dbuslomirisessionservice.cpp:380

## RealName

QString DBusLomiriSessionService::RealName | ( |  | ) | const

slot

Returns
  the real name of the current user

Definition at line 396 of file dbuslomirisessionservice.cpp.

{
struct passwd *p = getpwuid(geteuid());
if (p) {
const QString gecos = QString::fromLocal8Bit(p->pw_gecos);
if (!gecos.isEmpty()) {
const QStringList splitGecos = gecos.split(QLatin1Char(','));
return splitGecos.first();
}
}
return QString();
}

## Reboot

void DBusLomiriSessionService::Reboot | ( |  | ) |

slot

Reboot the system.

This method directly reboots the system without user's confirmation. Ordinary applications should avoid calling this method. Please call RequestReboot() to ask the user to decide reboot or not.

Definition at line 501 of file dbuslomirisessionservice.cpp.

{
d->makeLogin1Call(QStringLiteral("Reboot"), {false});
}

## reboot()

Q_INVOKABLE void DBusLomiriSessionService::reboot | ( |  | ) |

inline

Definition at line 45 of file dbuslomirisessionservice.h.

{ Reboot(); }
DBusLomiriSessionService::Reboot
Q_SCRIPTABLE void Reboot()
Definition dbuslomirisessionservice.cpp:501

## RebootRequested

Q_SCRIPTABLE void DBusLomiriSessionService::RebootRequested | ( | bool | have_inhibitors | ) |

signal

RebootRequested signal

This signal is emitted when some applications request the system to reboot.

Parameters

  have_inhibitors | if there are any special running applications which inhibit the reboot.

## RequestLogout

void DBusLomiriSessionService::RequestLogout | ( |  | ) |

slot

Issue a logout request.

This method emits the LogoutRequested signal to the shell with a boolean which indicates if there's any inhibitors. The shell should receive this signal and display a dialog to ask the user to confirm the logout action. If confirmed, shell can call Logout() method to logout.

Definition at line 495 of file dbuslomirisessionservice.cpp.

{
Q_EMIT LogoutRequested(false);
Q_EMIT logoutRequested(false);
}
DBusLomiriSessionService::LogoutRequested
Q_SCRIPTABLE void LogoutRequested(bool have_inhibitors)

## RequestReboot

void DBusLomiriSessionService::RequestReboot | ( |  | ) |

slot

Issue a reboot request.

This method emits the RebootRequested signal to the shell with a boolean which indicates if there's any inhibitors. The shell should receive this signal and display a dialog to ask the user to confirm the reboot action. If confirmed, shell can call Reboot() method to reboot.

Definition at line 506 of file dbuslomirisessionservice.cpp.

{
Q_EMIT RebootRequested(false);
Q_EMIT rebootRequested(false);
}
DBusLomiriSessionService::RebootRequested
Q_SCRIPTABLE void RebootRequested(bool have_inhibitors)

## RequestShutdown

void DBusLomiriSessionService::RequestShutdown | ( |  | ) |

slot

Issue a shutdown request.

This method emits the ShutdownRequested signal to the shell with a boolean which indicates if there's any inhibitors. The shell should receive this signal and display a dialog to ask the user to confirm the reboot action. If confirmed, shell can call Shutdown() method to shutdown.

Definition at line 535 of file dbuslomirisessionservice.cpp.

{
Q_EMIT ShutdownRequested(false);
Q_EMIT shutdownRequested(false);
}
DBusLomiriSessionService::ShutdownRequested
Q_SCRIPTABLE void ShutdownRequested(bool have_inhibitors)

## Shutdown

void DBusLomiriSessionService::Shutdown | ( |  | ) |

slot

Shutdown the system.

This method directly shuts down the system without user's confirmation. Ordinary applications should avoid calling this method. Please call RequestShutdown() to ask the user to decide shutdown or not.

Definition at line 512 of file dbuslomirisessionservice.cpp.

{
d->makeLogin1Call(QStringLiteral("PowerOff"), {false});
}

## shutdown()

Q_INVOKABLE void DBusLomiriSessionService::shutdown | ( |  | ) |

inline

Definition at line 46 of file dbuslomirisessionservice.h.

{ Shutdown(); }
DBusLomiriSessionService::Shutdown
Q_SCRIPTABLE void Shutdown()
Definition dbuslomirisessionservice.cpp:512

## ShutdownRequested

Q_SCRIPTABLE void DBusLomiriSessionService::ShutdownRequested | ( | bool | have_inhibitors | ) |

signal

ShutdownRequested signal

This signal is emitted when some applications request the system to shutdown.

Parameters

  have_inhibitors | if there are any special running applications which inhibit the shutdown.

## Suspend

void DBusLomiriSessionService::Suspend | ( |  | ) |

slot

Suspend the system

This method puts the system into sleep without user's confirmation.

Definition at line 517 of file dbuslomirisessionservice.cpp.

{
PromptLock();
d->makeLogin1Call(QStringLiteral("Suspend"), {false});
}

## Unlocked

Q_SCRIPTABLE void DBusLomiriSessionService::Unlocked | ( |  | ) |

signal

Emitted after the session has been unlocked.

## UserName

QString DBusLomiriSessionService::UserName | ( |  | ) | const

slot

Returns
  the login name of the current user

Definition at line 391 of file dbuslomirisessionservice.cpp.

{
return QString::fromUtf8(g_get_user_name());
}

The documentation for this class was generated from the following files:

- plugins/Lomiri/Session/dbuslomirisessionservice.h
- plugins/Lomiri/Session/dbuslomirisessionservice.cpp