diff options
| author | handsome_feng <445865575@qq.com> | 2015-10-09 11:38:41 +0800 | 
|---|---|---|
| committer | handsome_feng <445865575@qq.com> | 2015-10-09 11:38:41 +0800 | 
| commit | 613b2cc490e43215ce609d75e8121b605c124dc8 (patch) | |
| tree | b7f446e06cd16f0cd80da46282ced395a8b4f8e3 /UnityCore | |
| parent | b7839144d4a4078a7e0a16aa46d8b2be3fcadaf4 (diff) | |
Moved the dbus call inside unity::session
(bzr r4016.2.4)
Diffstat (limited to 'UnityCore')
| -rw-r--r-- | UnityCore/GnomeSessionManager.cpp | 59 | ||||
| -rw-r--r-- | UnityCore/GnomeSessionManager.h | 2 | ||||
| -rw-r--r-- | UnityCore/GnomeSessionManagerImpl.h | 2 | ||||
| -rw-r--r-- | UnityCore/SessionManager.h | 2 | 
4 files changed, 65 insertions, 0 deletions
| diff --git a/UnityCore/GnomeSessionManager.cpp b/UnityCore/GnomeSessionManager.cpp index 0702b9433..fdf13a45f 100644 --- a/UnityCore/GnomeSessionManager.cpp +++ b/UnityCore/GnomeSessionManager.cpp @@ -429,6 +429,21 @@ void GnomeManager::Impl::CallConsoleKitMethod(std::string const& method, GVarian  });  } +void GnomeManager::Impl::CallDisplayManagerSeatMethod(std::string const& method, GVariant* parameters) +{ + auto proxy = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.DisplayManager", + g_getenv("XDG_SEAT_PATH"), + "org.freedesktop.DisplayManager.Seat", + test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM); + proxy->CallBegin(method, parameters, [this, proxy] (GVariant*, glib::Error const& e) { + if (e) + { + LOG_ERROR(logger) << "Fallback call failed: " << e.Message(); + } + }); +} + +  void GnomeManager::Impl::LockScreen(bool prompt)  {  EnsureCancelPendingAction(); @@ -490,6 +505,40 @@ bool GnomeManager::Impl::HasInhibitors()  return inhibitors.GetBool();  } +std::string GnomeManager::Impl::UserIconFile() +{ + glib::Error error; + glib::Object<GDBusConnection> system_bus(g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error)); + + if (error) + { + LOG_ERROR(logger)<<"Unable to get system bus: "<< error; + return ""; + } + + glib::Variant IconFile(g_dbus_connection_call_sync (system_bus, + "org.freedesktop.Accounts", + g_strdup_printf("/org/freedesktop/Accounts/User%i", getuid()), + "org.freedesktop.DBus.Properties", + "Get", + g_variant_new("(ss)", + "org.freedesktop.Accounts.User", + "IconFile"), + G_VARIANT_TYPE("(v)"), + G_DBUS_CALL_FLAGS_NONE, + -1, + nullptr, + &error)); + + if (error) + { + LOG_ERROR(logger)<<"Couldn't find user icon in accounts service: "<< error; + return ""; + } + + return IconFile.GetString(); +} +  bool GnomeManager::Impl::IsUserInGroup(std::string const& user_name, std::string const& group_name)  {  auto group = getgrnam(group_name.c_str()); @@ -535,6 +584,11 @@ std::string GnomeManager::HostName() const  return glib::gchar_to_string(g_get_host_name());  } +std::string GnomeManager::UserIconFile() const +{ + return impl_->UserIconFile(); +} +  void GnomeManager::ScreenSaverActivate()  {  screensaver_requested.emit(true); @@ -665,6 +719,11 @@ void GnomeManager::Hibernate()  });  } +void GnomeManager::SwitchToGreeter() +{ + impl_->CallDisplayManagerSeatMethod("SwitchToGreeter"); +} +  bool GnomeManager::CanLock() const  {  if (is_locked()) diff --git a/UnityCore/GnomeSessionManager.h b/UnityCore/GnomeSessionManager.h index df7df1178..46dd54f64 100644 --- a/UnityCore/GnomeSessionManager.h +++ b/UnityCore/GnomeSessionManager.h @@ -36,6 +36,7 @@ public:  std::string RealName() const;  std::string UserName() const;  std::string HostName() const; + std::string UserIconFile() const;  void ScreenSaverActivate();  void ScreenSaverDeactivate(); @@ -46,6 +47,7 @@ public:  void Shutdown();  void Suspend();  void Hibernate(); + void SwitchToGreeter();  bool CanLock() const;  bool CanShutdown() const; diff --git a/UnityCore/GnomeSessionManagerImpl.h b/UnityCore/GnomeSessionManagerImpl.h index ee26c3171..764e407f6 100644 --- a/UnityCore/GnomeSessionManagerImpl.h +++ b/UnityCore/GnomeSessionManagerImpl.h @@ -54,6 +54,7 @@ struct GnomeManager::Impl  bool HasInhibitors();  void EnsureCancelPendingAction();  void LockScreen(bool prompt); + std::string UserIconFile();  GVariant* OnShellMethodCall(std::string const& method, GVariant* parameters);  void CallGnomeSessionMethod(std::string const& method, GVariant* parameters = nullptr, @@ -61,6 +62,7 @@ struct GnomeManager::Impl  void CallUPowerMethod(std::string const& method, glib::DBusProxy::ReplyCallback const& cb = nullptr);  void CallLogindMethod(std::string const& method, GVariant* parameters = nullptr, glib::DBusProxy::CallFinishedCallback const& cb = nullptr);  void CallConsoleKitMethod(std::string const& method, GVariant* parameters = nullptr); + void CallDisplayManagerSeatMethod(std::string const& method, GVariant* parameters = nullptr);  bool InteractiveMode();  void UpdateHaveOtherOpenSessions(); diff --git a/UnityCore/SessionManager.h b/UnityCore/SessionManager.h index f6a0d6933..0d5a04e81 100644 --- a/UnityCore/SessionManager.h +++ b/UnityCore/SessionManager.h @@ -44,6 +44,7 @@ public:  virtual std::string RealName() const = 0;  virtual std::string UserName() const = 0;  virtual std::string HostName() const = 0; + virtual std::string UserIconFile() const = 0;  virtual void ScreenSaverActivate() = 0;  virtual void ScreenSaverDeactivate() = 0; @@ -54,6 +55,7 @@ public:  virtual void Shutdown() = 0;  virtual void Suspend() = 0;  virtual void Hibernate() = 0; + virtual void SwitchToGreeter() = 0;  virtual bool CanLock() const = 0;  virtual bool CanShutdown() const = 0; | 
