<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/106859/">http://git.reviewboard.kde.org/r/106859/</a>
     </td>
    </tr>
   </table>
   <br />



 <p>Ship it!</p>



 <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Ship It!</pre>
 <br />







<p>- Dario</p>


<br />
<p>On October 14th, 2012, 11:20 p.m., Alex Fiestas wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Solid.</div>
<div>By Alex Fiestas.</div>


<p style="color: grey;"><i>Updated Oct. 14, 2012, 11:20 p.m.</i></p>






<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The bug is produced because of the following code:
if (methods.contains(Solid::PowerManagement::SuspendState)) {
    handleButtonEvents.writeEntry< uint >("lidAction", ToRamMode);
} else {
    handleButtonEvents.writeEntry< uint >("lidAction", TurnOffScreenMode);
}

There, SuspendState will NOT be contained in method, so we will fallback to TurnOffScreenMode.

LibSolid is always returning an empty "methods" (QList of SuspendMethods). LibSolid uses powerdevil
dbus api to know which suspend methods are available:

libsolid---dbus--->powerdevl-----backend---->UDisk

The problem is that the DBus interface of powerdevil is being setup AFTER generateProfile is executed, so libsolid
will fail to query powerdevil for the available suspend methods because powerdevil haven't made them public yet.

The approach in the fix:
There are many ways of fixing this, the simpler one is to execute the dbus registering before generateProfiles is executed,
the others are based on the same principle of moving the current code around to make libsolid work.

The reason why I went for a different approach is because it is architecturally wrong to have an interdependence:

PowerDevil------->libsolid------->PowerDevil.

No matter how careful we are, having this interdependence is going to cause problems sooner or later.

So, what I have done to keep the patch small is add 2 new arguments to generateProfiles (toRam and toDisk) so we don't
have to call libsolid in order to get this info.
I had to add these arguments instead of using PowerDevil::BackendInfo because generateProfiles is also used in EditPage.</pre>
  </td>
 </tr>
</table>





<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>powerdevil/daemon/powerdevilcore.cpp <span style="color: grey">(b968d21)</span></li>

 <li>powerdevil/daemon/powerdevilprofilegenerator.h <span style="color: grey">(a909294)</span></li>

 <li>powerdevil/daemon/powerdevilprofilegenerator.cpp <span style="color: grey">(060fc30)</span></li>

 <li>powerdevil/kcmodule/profiles/EditPage.cpp <span style="color: grey">(95a98d9)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/106859/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>