Lomiri
DBusLomiriSessionService Class Reference

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

Inherits LomiriDBusObject.

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.

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.

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

◆ 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.

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

◆ CanLock

bool DBusLomiriSessionService::CanLock ( ) const
slot
Returns
whether the system is capable of locking the session

Definition at line 380 of file dbuslomirisessionservice.cpp.

381 {
382  auto user = UserName();
383  if (user.startsWith(QStringLiteral("guest-")) ||
384  d->isUserInGroup(user, QStringLiteral("nopasswdlogin"))) {
385  return false;
386  } else {
387  return true;
388  }
389 }
Q_SCRIPTABLE QString UserName() const

◆ CanReboot

bool DBusLomiriSessionService::CanReboot ( ) const
slot
Returns
whether the system is capable of rebooting
Since
lomiri

Definition at line 370 of file dbuslomirisessionservice.cpp.

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

◆ CanShutdown

bool DBusLomiriSessionService::CanShutdown ( ) const
slot
Returns
whether the system is capable of shutting down

Definition at line 375 of file dbuslomirisessionservice.cpp.

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

◆ CanSuspend

bool DBusLomiriSessionService::CanSuspend ( ) const
slot
Returns
whether the system is capable of suspending

Definition at line 360 of file dbuslomirisessionservice.cpp.

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

◆ 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.

347 {
348  const QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("com.lomiri.Upstart"),
349  QStringLiteral("/com/lomiri/Upstart"),
350  QStringLiteral("com.lomiri.Upstart0_6"),
351  QStringLiteral("EndSession"));
352  QDBusConnection::sessionBus().asyncCall(msg);
353 }

◆ 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.

524 {
525  PromptLock();
526  d->makeLogin1Call(QStringLiteral("Hibernate"), {false});
527 }

◆ HostName

QString DBusLomiriSessionService::HostName ( ) const
slot
Returns
the local hostname

Definition at line 410 of file dbuslomirisessionservice.cpp.

411 {
412  char hostName[512];
413  if (gethostname(hostName, sizeof(hostName)) == -1) {
414  qWarning() << "Could not determine local hostname";
415  return QString();
416  }
417  hostName[sizeof(hostName) - 1] = '\0';
418  return QString::fromLocal8Bit(hostName);
419 }

◆ 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.

530 {
531  PromptLock();
532  d->makeLogin1Call(QStringLiteral("HybridSleep"), {false});
533 }

◆ IsLocked

bool DBusLomiriSessionService::IsLocked ( ) const
slot
Returns
whether the session is currently locked

Definition at line 490 of file dbuslomirisessionservice.cpp.

491 {
492  return !d->isSessionActive;
493 }

◆ Lock

void DBusLomiriSessionService::Lock ( )
slot

Locks the session immediately

Definition at line 432 of file dbuslomirisessionservice.cpp.

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

◆ 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.

340 {
341  // TODO ask the apps to quit and then emit the signal
342  Q_EMIT LogoutReady();
343  Q_EMIT logoutReady();
344 }
Q_SCRIPTABLE void LogoutReady()

◆ 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_inhibitorsif 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.

422 {
423  // Prompt as in quick. No locking animation needed. Usually used by
424  // indicator-session in combination with a switch to greeter or other
425  // user session.
426  if (CanLock()) {
427  Q_EMIT LockRequested();
428  Q_EMIT lockRequested();
429  }
430 }
Q_SCRIPTABLE void LockRequested()
Q_SCRIPTABLE bool CanLock() const

◆ RealName

QString DBusLomiriSessionService::RealName ( ) const
slot
Returns
the real name of the current user

Definition at line 396 of file dbuslomirisessionservice.cpp.

397 {
398  struct passwd *p = getpwuid(geteuid());
399  if (p) {
400  const QString gecos = QString::fromLocal8Bit(p->pw_gecos);
401  if (!gecos.isEmpty()) {
402  const QStringList splitGecos = gecos.split(QLatin1Char(','));
403  return splitGecos.first();
404  }
405  }
406 
407  return QString();
408 }

◆ 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.

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

◆ 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_inhibitorsif 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.

496 {
497  Q_EMIT LogoutRequested(false);
498  Q_EMIT logoutRequested(false);
499 }
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.

507 {
508  Q_EMIT RebootRequested(false);
509  Q_EMIT rebootRequested(false);
510 }
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.

536 {
537  Q_EMIT ShutdownRequested(false);
538  Q_EMIT shutdownRequested(false);
539 }
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.

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

◆ 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_inhibitorsif 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.

518 {
519  PromptLock();
520  d->makeLogin1Call(QStringLiteral("Suspend"), {false});
521 }

◆ 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.

392 {
393  return QString::fromUtf8(g_get_user_name());
394 }

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