LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
screensaverprohibitor.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
10 #include <QUuid>
12 #include "util.h"
13 
14 namespace LC::Util
15 {
17  : IEM_ { iem }
18  , ContextID_ { QUuid::createUuid ().toString () }
19  {
20  }
21 
22  ScreensaverProhibitor::~ScreensaverProhibitor ()
23  {
24  SetProhibited (false);
25  }
26 
27  void ScreensaverProhibitor::SetProhibited (bool prohibited)
28  {
29  if (Prohibited_ == prohibited)
30  return;
31 
32  Prohibited_ = prohibited;
33 
34  if (Enabled_)
35  SendEntity (Prohibited_);
36  }
37 
38  void ScreensaverProhibitor::SetProhibitionsEnabled (bool enabled)
39  {
40  if (Enabled_ == enabled)
41  return;
42 
43  Enabled_ = enabled;
44 
45  if (Prohibited_)
46  SendEntity (Enabled_);
47  }
48 
49  void ScreensaverProhibitor::SendEntity (bool prohibit)
50  {
51  auto e = MakeEntity ("ScreensaverProhibition", {}, {}, QStringLiteral ("x-leechcraft/power-management"));
52  e.Additional_ = {
53  { QStringLiteral ("Enable"), prohibit },
54  { QStringLiteral ("ContextID"), ContextID_ }
55  };
56  IEM_->HandleEntity (e);
57  }
58 }
LC::Util
Definition: icoreproxy.h:33
LC::Entity::Additional_
QMap< QString, QVariant > Additional_
Additional parameters.
Definition: structures.h:164
screensaverprohibitor.h
LC::Util::MakeEntity
Entity MakeEntity(const QVariant &entity, const QString &location, TaskParameters tp, const QString &mime)
Definition: util.cpp:82
util.h
IEntityManager
Proxy to core entity manager.
Definition: ientitymanager.h:31
ientitymanager.h
LC::Util::ScreensaverProhibitor::ScreensaverProhibitor
ScreensaverProhibitor(IEntityManager *)
Definition: screensaverprohibitor.cpp:22