[Psi-devel] [BUG] Psi prohibits user logout or system shutdown
Michał Jazłowiecki
michalj at poczta.neostrada.pl
Mon Jul 9 21:23:36 PDT 2007
textshell wrote:
>> I've just made my own quick-fix. Just a proof of concept. I'll test it
>> tomorrow.
>
> I think we will just change the return true; to return false; in
> PsiApplication::winEventFilter for 0.11. Can you test that it does fix
> the problem? it's much nicer to push actually tested patches to
> mainline ;)
Actually, it's not so easy. Here's what I did (sorry, no time to play
with diff, I'm in a hurry):
In src/psiapplication.cpp:
bool PsiApplication::winEventFilter(MSG* msg, long* result)
{
if (msg->message == WM_POWERBROADCAST || msg->message ==
WM_QUERYENDSESSION) {
static_cast<WinSystemWatch*>(SystemWatch::instance())->processWinEvent(msg,
result); // michalj: Forwarded result
return true;
}
return false;
}
In src/tools/systemwatch/systemwatch_win.h:
void processWinEvent(MSG *m, long * result); // michalj: Added last
parameter
In src/tools/systemwatch/systemwatch_win.cpp:
void WinSystemWatch::processWinEvent(MSG *m, long * result) // michalj:
Added last parameter
{
// NOTE: If you need another message type here, do not forget to add it to
// PsiApplication::winEventFilter()
if(WM_POWERBROADCAST == m->message) {
switch (m->wParam) {
case PBT_APMSUSPEND:
emit sleep();
break;
case PBT_APMRESUMESUSPEND:
emit wakeup();
break;
case PBT_APMRESUMECRITICAL:
// The system previously went into SUSPEND state (suddenly)
// without sending PBT_APMSUSPEND. Net connections are
// probably invalid. Not sure what to do about this.
// Maybe:
emit sleep();
emit wakeup();
break;
case PBT_APMQUERYSUSPEND:
// TODO: Check if file transfers are running, and don't go
// to sleep if there are. To refuse to suspend, we somehow
// need to return BROADCAST_QUERY_DENY from the actual
// windows procedure.
break;
}
}
else if (WM_QUERYENDSESSION == m->message) {
// TODO : If we allow the user to cancel suspend if they
// are doing a file transfer, we should probably also give
// them the chance to cancel a shutdown or log-off
if (result) // michalj: Test whether result is not-null; we don't like
NullReferenceExceptions and the like
*result = TRUE; // michalj: We agree to log user out or shut the
system down
}
}
Regards,
--
Michał Jazłowiecki (michalj)
Psi Forum & Wiki Moderator
More information about the psi-devel
mailing list