summaryrefslogtreecommitdiff
path: root/lockscreen
diff options
authorAndrea Azzarone <azzaronea@gmail.com>2014-10-10 16:03:44 +0200
committerAndrea Azzarone <azzaronea@gmail.com>2014-10-10 16:03:44 +0200
commitdae721c2276c987833be6b49b32297c09826a687 (patch)
tree4fedbd9b85a06138fa16ee41bd4073a8108f9dcb /lockscreen
parent30cc2d558e960c15da9b924b8ce087c5a4806da9 (diff)
Fix shutdown notifier and use it inside lockscreen controller.
(bzr r3874.1.2)
Diffstat (limited to 'lockscreen')
-rw-r--r--lockscreen/LockScreenController.cpp7
-rw-r--r--lockscreen/LockScreenController.h2
-rw-r--r--lockscreen/ShutdownNotifier.cpp10
-rw-r--r--lockscreen/ShutdownNotifier.h2
4 files changed, 13 insertions, 8 deletions
diff --git a/lockscreen/LockScreenController.cpp b/lockscreen/LockScreenController.cpp
index 04cdcdbcb..abfbdbbcb 100644
--- a/lockscreen/LockScreenController.cpp
+++ b/lockscreen/LockScreenController.cpp
@@ -59,6 +59,7 @@ Controller::Controller(DBusManager::Ptr const& dbus_manager,
, session_manager_(session_manager)
, upstart_wrapper_(upstart_wrapper)
, shield_factory_(shield_factory)
+ , shutdown_notifier_(std::make_shared<ShutdownNotifier>())
, fade_animator_(LOCK_FADE_DURATION)
, blank_window_animator_(IDLE_FADE_DURATION)
, test_mode_(test_mode)
@@ -419,6 +420,10 @@ void Controller::LockScreen()
indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>();
upstart_wrapper_->Emit("desktop-lock");
+ shutdown_notifier_->RegisterInterest([](){
+ std::cout << "Shutdown!" << std::endl;
+ });
+
accelerator_controller_ = std::make_shared<AcceleratorController>(session_manager_);
auto activate_key = WindowManager::Default().activate_indicators_key();
auto accelerator = std::make_shared<Accelerator>(activate_key.second, 0, activate_key.first);
@@ -456,6 +461,8 @@ void Controller::SimulateActivity()
void Controller::OnUnlockRequested()
{
+ shutdown_notifier_->UnregisterInterest();
+
lockscreen_timeout_.reset();
screensaver_post_lock_timeout_.reset();
diff --git a/lockscreen/LockScreenController.h b/lockscreen/LockScreenController.h
index 383e15788..a89814aba 100644
--- a/lockscreen/LockScreenController.h
+++ b/lockscreen/LockScreenController.h
@@ -27,6 +27,7 @@
#include "LockScreenShieldFactory.h"
#include "LockScreenAcceleratorController.h"
#include "ScreenSaverDBusManager.h"
+#include "ShutdownNotifier.h"
#include "UserPromptView.h"
#include "unity-shared/BackgroundEffectHelper.h"
#include "unity-shared/UpstartWrapper.h"
@@ -85,6 +86,7 @@ private:
AcceleratorController::Ptr accelerator_controller_;
UpstartWrapper::Ptr upstart_wrapper_;
ShieldFactoryInterface::Ptr shield_factory_;
+ ShutdownNotifier::Ptr shutdown_notifier_;
nux::animation::AnimateValue<double> fade_animator_;
nux::animation::AnimateValue<double> blank_window_animator_;
diff --git a/lockscreen/ShutdownNotifier.cpp b/lockscreen/ShutdownNotifier.cpp
index 5a82d73d5..e6a31939d 100644
--- a/lockscreen/ShutdownNotifier.cpp
+++ b/lockscreen/ShutdownNotifier.cpp
@@ -64,17 +64,11 @@ bool ShutdownNotifier::Impl::RegisterInterest(ShutdownCallback const& cb)
cb_ = cb;
- std::vector<std::string> parameters;
- parameters.push_back("shutdown"); // what
- parameters.push_back("Unity Lockscreen"); // who
- parameters.push_back("Screen Locked"); // why
- parameters.push_back("delay"); // mode
-
logind_proxy_->CallWithUnixFdList("Inhibit",
- glib::Variant::FromVector(parameters),
+ g_variant_new("(ssss)", "shutdown", "Unity Lockscreen", "Screen is locked", "delay"),
[this](GVariant* variant, glib::Error const& e){
// FIXME: we should handle the error.
- delay_inhibit_fd_ = glib::Variant(variant).GetUInt32();
+ delay_inhibit_fd_ = glib::Variant(variant).GetInt32();
});
logind_proxy_->Connect("PrepareForShutdown", [this](GVariant* variant) {
diff --git a/lockscreen/ShutdownNotifier.h b/lockscreen/ShutdownNotifier.h
index 7c502a013..8a3eebab5 100644
--- a/lockscreen/ShutdownNotifier.h
+++ b/lockscreen/ShutdownNotifier.h
@@ -32,6 +32,8 @@ typedef std::function<void()> ShutdownCallback;
class ShutdownNotifier
{
public:
+ typedef std::shared_ptr<ShutdownNotifier> Ptr;
+
ShutdownNotifier();
~ShutdownNotifier();