trinity-devel@lists.pearsoncomputing.net

Message: previous - next
Month: February 2012

Re: [trinity-devel] UPower support added in tdebase/ksmserver

From: Ilya Chernykh <anixxsus@...>
Date: Thu, 16 Feb 2012 19:56:38 +0400
On Thursday 16 February 2012 20:48:28 Calvin Morrison wrote:
> > Currently kickoff detects well if kpowersave is running. I thought you patched kpowersave to work through upower instead of hal.
> 
> Err what? I don't see kpowersave referenced anywhere in our kickoff
> branch. It actually detects from hal directly. I don't know where you
> got that idea.

If kpowersave is not installed, the suspend/hybernate buttons are unavailable.


 	} else
             QToolTip::add( btnReboot, i18n( "<qt><h3>Restart Computer</h3><p>Log out of the current session and restart the computer</p></qt>" ) );
 
	DCOPRef kpowersave( "kpowersave", "KPowersaveIface" );
	DCOPReply reply = kpowersave.call( "allowed_sleepingStates" );
	if( reply.isValid()) {
	    QStringList supported = reply;
	    suspend_ram = supported.contains( "suspendToRAM" );
	    suspend_disk = supported.contains( "suspendToDisk" );
	    standby = supported.contains( "standBy" );
	} else {
 	int supported = -1;
 	liblazy_hal_get_property_bool(HAL_UDI_COMPUTER, "power_management.can_suspend", &supported);
 	if (supported == 1)

===

 void KSMShutdownDlg::slotSuspend()
 {
   int error = 0;
    DCOPRef kpowersave( "kpowersave", "KPowersaveIface" );
    DCOPReply reply = kpowersave.call( "allowed_sleepingStates" );
    if( reply.isValid()) {
	bool ok;
	// so that screen locking can take place
	extern Time qt_x_time;
	XUngrabKeyboard( qt_xdisplay(), qt_x_time );
	XUngrabPointer( qt_xdisplay(), qt_x_time );
	XSync( qt_xdisplay(), False );
	if( suspend_disk )
	    ok = kpowersave.call( "do_suspendToDisk" );
	else if( suspend_ram )
	    ok = kpowersave.call( "do_suspendToRAM" );
	else
	    ok = kpowersave.call( "do_standBy" );
	error = ok ? 0 : 1;
    } else {
  
   int wake = 0;
   DBusMessage *reply;

===

 void KSMShutdownDlg::slotSuspend(int id)
 {
   int error = 0;

    DCOPRef kpowersave( "kpowersave", "KPowersaveIface" );
    DCOPReply reply = kpowersave.call( "allowed_sleepingStates" );
    if( reply.isValid()) {
	bool ok;
	extern Time qt_x_time;
	XUngrabKeyboard( qt_xdisplay(), qt_x_time );
	XUngrabPointer( qt_xdisplay(), qt_x_time );
	XSync( qt_xdisplay(), False );
	if( suspend_disk && id == 1 )
	    ok = kpowersave.call( "do_suspendToDisk" );
	else if( suspend_ram && id == 2 )
	    ok = kpowersave.call( "do_suspendToRAM" );
	else if( standby && id == 3 )
	    ok = kpowersave.call( "do_standBy" );
	else
	    return;
	error = ok ? 0 : 1;
    } else {


> 
> > Would not it be a better solution?
> 
> Nope, kpowersave does exactly what kickoff does, communicate via hal.

kickoff and the shutdown dialog, and the k-munu and the kicker panel applet with the power buttons
all call kpowersave to detect whether suspend and hybernate are available. kpowersave on the other hand
either calls hal or its own daemon.

> the best solution is to implement a interface for all programs to
> access via dcop, that way we can use hal or udev or whatever backend
> and not have to rewrite the system every time

They all ask kpowersave. Once somebody patches kpowersave, all kde components wioll know whether
hybernate|suspend is available.
 
> > Previously it used its own daemon, then it was ported to hal, why not to port it to upower?
> 
> previously what did? ksmserver?

kpowersave

> 
> > Hybernate/suspend dialog circumventing kpowersave is not good I think.
> 
> Kpowersave works the same way, via hal.

Not necessary.