Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 194873 | Differences between
and this patch

Collapse All | Expand All

(-)kdebase-3.5.5a.dfsg.1/ksmserver/Makefile.am (-3 / +3 lines)
Lines 17-23 Link Here
17
17
18
SUBDIRS = .
18
SUBDIRS = .
19
19
20
INCLUDES= -I$(top_srcdir)/kdmlib $(all_includes)
20
INCLUDES= -I$(top_srcdir)/kdmlib $(all_includes) $(HAL_INCS) $(DBUS_INCS)
21
21
22
bin_PROGRAMS =
22
bin_PROGRAMS =
23
lib_LTLIBRARIES =
23
lib_LTLIBRARIES =
Lines 31-37 Link Here
31
	KSMServerInterface.skel server.skel
31
	KSMServerInterface.skel server.skel
32
32
33
ksmserver_la_LDFLAGS = $(all_libraries) -avoid-version -module
33
ksmserver_la_LDFLAGS = $(all_libraries) -avoid-version -module
34
ksmserver_la_LIBADD = ../kdmlib/libdmctl.la $(LIB_KDEUI)
34
ksmserver_la_LIBADD = ../kdmlib/libdmctl.la $(LIB_KDEUI) $(HAL_LIBS) $(DBUS_LIBS)
35
35
36
picsdir = $(kde_datadir)/ksmserver/pics
36
picsdir = $(kde_datadir)/ksmserver/pics
37
pics_DATA = shutdownkonq.png
37
pics_DATA = shutdownkonq.png
Lines 44-50 Link Here
44
EXTRA_PROGRAMS = testsh
44
EXTRA_PROGRAMS = testsh
45
testsh_SOURCES = test.cpp
45
testsh_SOURCES = test.cpp
46
testsh_LDFLAGS = $(all_libraries) $(KDE_RPATH)
46
testsh_LDFLAGS = $(all_libraries) $(KDE_RPATH)
47
testsh_LDADD = $(LIB_KDEUI) shutdowndlg.lo ../kdmlib/libdmctl.la
47
testsh_LDADD = $(LIB_KDEUI) shutdowndlg.lo ../kdmlib/libdmctl.la $(HAL_LIBS) $(DBUS_LIBS)
48
48
49
messages:
49
messages:
50
	$(XGETTEXT) *.cpp -o $(podir)/ksmserver.pot
50
	$(XGETTEXT) *.cpp -o $(podir)/ksmserver.pot
(-)kdebase-3.5.5a.dfsg.1/ksmserver/Makefile.in (-3 / +3 lines)
Lines 655-661 Link Here
655
xdg_directorydir = @xdg_directorydir@
655
xdg_directorydir = @xdg_directorydir@
656
xdg_menudir = @xdg_menudir@
656
xdg_menudir = @xdg_menudir@
657
SUBDIRS = .
657
SUBDIRS = .
658
INCLUDES = -I$(top_srcdir)/kdmlib $(all_includes)
658
INCLUDES = -I$(top_srcdir)/kdmlib $(all_includes) $(HAL_INCS) $(DBUS_INCS)
659
#>- lib_LTLIBRARIES = 
659
#>- lib_LTLIBRARIES = 
660
#>+ 1
660
#>+ 1
661
lib_LTLIBRARIES =   libkdeinit_ksmserver.la
661
lib_LTLIBRARIES =   libkdeinit_ksmserver.la
Lines 685-691 Link Here
685
updatedir = $(kde_datadir)/kconf_update
685
updatedir = $(kde_datadir)/kconf_update
686
testsh_SOURCES = test.cpp
686
testsh_SOURCES = test.cpp
687
testsh_LDFLAGS = $(all_libraries) $(KDE_RPATH)
687
testsh_LDFLAGS = $(all_libraries) $(KDE_RPATH)
688
testsh_LDADD = $(LIB_KDEUI) shutdowndlg.lo ../kdmlib/libdmctl.la
688
testsh_LDADD = $(LIB_KDEUI) shutdowndlg.lo ../kdmlib/libdmctl.la $(HAL_LIBS) $(DBUS_LIBS)
689
#>- all: all-recursive
689
#>- all: all-recursive
690
#>+ 1
690
#>+ 1
691
all: docs-am  all-recursive
691
all: docs-am  all-recursive
Lines 1220-1226 Link Here
1220
.NOEXPORT:
1220
.NOEXPORT:
1221
1221
1222
#>+ 2
1222
#>+ 2
1223
libkdeinit_ksmserver_la_LIBADD = ../kdmlib/libdmctl.la $(LIB_KDEUI)
1223
libkdeinit_ksmserver_la_LIBADD = ../kdmlib/libdmctl.la $(LIB_KDEUI) $(HAL_LIBS) $(DBUS_LIBS)
1224
1224
1225
#>+ 2
1225
#>+ 2
1226
libkdeinit_ksmserver_la_LDFLAGS = -no-undefined -avoid-version $(all_libraries)
1226
libkdeinit_ksmserver_la_LDFLAGS = -no-undefined -avoid-version $(all_libraries)
(-)kdebase-3.5.5a.dfsg.1/ksmserver/shutdowndlg.cpp (+144 lines)
Lines 37-42 Link Here
37
#include <kimageeffect.h>
37
#include <kimageeffect.h>
38
#include <kdialog.h>
38
#include <kdialog.h>
39
#include <kseparator.h>
39
#include <kseparator.h>
40
#include <kconfig.h>
41
42
#include <dcopclient.h>
43
#include <dcopref.h>
40
44
41
#include <sys/types.h>
45
#include <sys/types.h>
42
#include <sys/utsname.h>
46
#include <sys/utsname.h>
Lines 130-135 Link Here
130
    buttonlay->addWidget( btnLogout );
134
    buttonlay->addWidget( btnLogout );
131
    connect(btnLogout, SIGNAL(clicked()), SLOT(slotLogout()));
135
    connect(btnLogout, SIGNAL(clicked()), SLOT(slotLogout()));
132
136
137
    m_halCtx = NULL;
138
133
    if (maysd) {
139
    if (maysd) {
134
140
135
        // Shutdown
141
        // Shutdown
Lines 167-172 Link Here
167
	  btnReboot->setPopup(targets);
173
	  btnReboot->setPopup(targets);
168
	  connect( targets, SIGNAL(activated(int)), SLOT(slotReboot(int)) );
174
	  connect( targets, SIGNAL(activated(int)), SLOT(slotReboot(int)) );
169
	}
175
	}
176
177
        // respect lock on resume & disable suspend/hibernate settings 
178
        // from power-manager
179
        KConfig config("power-managerrc");
180
        bool disableSuspend = config.readBoolEntry("disableSuspend", false);
181
        bool disableHibernate = config.readBoolEntry("disableHibernate", false);
182
        m_lockOnResume = config.readBoolEntry("lockOnResume", true);
183
184
        bool canSuspend = false;
185
        bool canHibernate = false;
186
187
        // Query HAL for suspend/resume support
188
        m_halCtx = libhal_ctx_new();
189
190
        DBusError error;
191
        dbus_error_init(&error);
192
        m_dbusConn = dbus_connection_open_private(DBUS_SYSTEM_BUS, &error);
193
        if (!m_dbusConn)
194
        {
195
            dbus_error_free(&error);
196
            libhal_ctx_free(m_halCtx);
197
            m_halCtx = NULL;
198
        }
199
        else
200
        {
201
            dbus_bus_register(m_dbusConn, &error);
202
            if (dbus_error_is_set(&error))
203
            {
204
                dbus_error_free(&error);
205
                libhal_ctx_free(m_halCtx);
206
                m_dbusConn = NULL;
207
                m_halCtx = NULL;
208
            }
209
            else
210
            {
211
                libhal_ctx_set_dbus_connection(m_halCtx, m_dbusConn);
212
                if (!libhal_ctx_init(m_halCtx, &error))
213
                {
214
                    if (dbus_error_is_set(&error))
215
                        dbus_error_free(&error);
216
                    libhal_ctx_free(m_halCtx);
217
                    m_dbusConn = NULL;
218
                    m_halCtx = NULL;
219
                }
220
            }
221
        }
222
223
        if (m_halCtx)
224
        {
225
            if (libhal_device_get_property_bool(m_halCtx,
226
                                                "/org/freedesktop/Hal/devices/computer",
227
                                                "power_management.can_suspend_to_ram", 
228
                                                NULL))
229
            {
230
                canSuspend = true;
231
            }
232
233
            if (libhal_device_get_property_bool(m_halCtx, 
234
                                                "/org/freedesktop/Hal/devices/computer",
235
                                                "power_management.can_suspend_to_disk",
236
                                                NULL))
237
            {
238
                canHibernate = true;
239
            }
240
        }
241
242
        if (canSuspend && !disableSuspend)
243
        {
244
            KPushButton* btnSuspend = new KPushButton( KGuiItem( i18n("&Suspend Computer"), "suspend"), frame );
245
            btnSuspend->setFont( btnFont );
246
            buttonlay->addWidget( btnSuspend );
247
            connect(btnSuspend, SIGNAL(clicked()), SLOT(slotSuspend()));
248
        }
249
250
        if (canHibernate && !disableHibernate)
251
        {
252
            KPushButton* btnHibernate = new KPushButton( KGuiItem( i18n("&Hibernate Computer"), "hibernate"), frame );
253
            btnHibernate->setFont( btnFont );
254
            buttonlay->addWidget( btnHibernate );
255
            connect(btnHibernate, SIGNAL(clicked()), SLOT(slotHibernate()));
256
        }
170
    }
257
    }
171
258
172
    buttonlay->addStretch( 1 );
259
    buttonlay->addStretch( 1 );
Lines 181-186 Link Here
181
268
182
}
269
}
183
270
271
KSMShutdownDlg::~KSMShutdownDlg()
272
{
273
    if (m_halCtx)
274
    {
275
        DBusError error;
276
        dbus_error_init(&error);
277
        libhal_ctx_shutdown(m_halCtx, &error);
278
        libhal_ctx_free(m_halCtx);
279
    }
280
}
281
184
282
185
void KSMShutdownDlg::slotLogout()
283
void KSMShutdownDlg::slotLogout()
186
{
284
{
Lines 213-218 Link Here
213
    accept();
311
    accept();
214
}
312
}
215
313
314
void KSMShutdownDlg::slotSuspend()
315
{
316
    if (m_lockOnResume) {
317
        DCOPRef("kdesktop", "KScreensaverIface").send("lock");
318
    }
319
320
    if (m_dbusConn) 
321
    {
322
        DBusMessage *msg = dbus_message_new_method_call(
323
                              "org.freedesktop.Hal",
324
                              "/org/freedesktop/Hal/devices/computer", 
325
                              "org.freedesktop.Hal.Device.SystemPowerManagement", 
326
                              "Suspend");
327
328
        int wakeup=0;
329
	    dbus_message_append_args(msg, DBUS_TYPE_INT32, &wakeup, DBUS_TYPE_INVALID);
330
331
        dbus_connection_send(m_dbusConn, msg, NULL);
332
333
        dbus_message_unref(msg);
334
    }
335
336
    reject(); // continue on resume
337
}
338
339
void KSMShutdownDlg::slotHibernate()
340
{
341
    if (m_lockOnResume) {
342
        DCOPRef("kdesktop", "KScreensaverIface").send("lock");
343
    }
344
345
    if (m_dbusConn) 
346
    {
347
        DBusMessage *msg = dbus_message_new_method_call(
348
                              "org.freedesktop.Hal",
349
                              "/org/freedesktop/Hal/devices/computer", 
350
                              "org.freedesktop.Hal.Device.SystemPowerManagement", 
351
                              "Hibernate");
352
353
        dbus_connection_send(m_dbusConn, msg, NULL);
354
355
        dbus_message_unref(msg);
356
    }
357
358
    reject(); // continue on resume
359
}
216
360
217
bool KSMShutdownDlg::confirmShutdown( bool maysd, KApplication::ShutdownType& sdtype, QString& bootOption )
361
bool KSMShutdownDlg::confirmShutdown( bool maysd, KApplication::ShutdownType& sdtype, QString& bootOption )
218
{
362
{
(-)kdebase-3.5.5a.dfsg.1/ksmserver/shutdowndlg.h (-1 / +11 lines)
Lines 17-22 Link Here
17
17
18
#include <kapplication.h>
18
#include <kapplication.h>
19
19
20
/* We acknowledge the the dbus API is unstable */
21
#define DBUS_API_SUBJECT_TO_CHANGE
22
#include <dbus/connection.h>
23
#include <libhal.h>
24
20
// The (singleton) widget that makes the desktop gray.
25
// The (singleton) widget that makes the desktop gray.
21
class KSMShutdownFeedback : public QWidget
26
class KSMShutdownFeedback : public QWidget
22
{
27
{
Lines 54-62 Link Here
54
    void slotHalt();
59
    void slotHalt();
55
    void slotReboot();
60
    void slotReboot();
56
    void slotReboot(int);
61
    void slotReboot(int);
62
    void slotSuspend();
63
    void slotHibernate();
57
64
58
protected:
65
protected:
59
    ~KSMShutdownDlg() {};
66
    ~KSMShutdownDlg();
60
67
61
private:
68
private:
62
    KSMShutdownDlg( QWidget* parent, bool maysd, KApplication::ShutdownType sdtype );
69
    KSMShutdownDlg( QWidget* parent, bool maysd, KApplication::ShutdownType sdtype );
Lines 64-69 Link Here
64
    QString m_bootOption;
71
    QString m_bootOption;
65
    QPopupMenu *targets;
72
    QPopupMenu *targets;
66
    QStringList rebootOptions;
73
    QStringList rebootOptions;
74
    LibHalContext* m_halCtx;
75
    DBusConnection *m_dbusConn;
76
    bool m_lockOnResume;
67
};
77
};
68
78
69
class KSMDelayedPushButton : public KPushButton
79
class KSMDelayedPushButton : public KPushButton

Return to bug 194873