* Enabled default time for shutting off the monitor (after 20 minutes).
* Removed BeOS R5 network password retrieval code. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31652 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -27,75 +27,101 @@ enum {
|
|||||||
ENABLE_DPMS_SUSPEND = 0x04,
|
ENABLE_DPMS_SUSPEND = 0x04,
|
||||||
ENABLE_DPMS_OFF = 0x08,
|
ENABLE_DPMS_OFF = 0x08,
|
||||||
|
|
||||||
ENABLE_DPMS_MASK = ENABLE_DPMS_STAND_BY | ENABLE_DPMS_SUSPEND | ENABLE_DPMS_OFF
|
ENABLE_DPMS_MASK
|
||||||
|
= ENABLE_DPMS_STAND_BY | ENABLE_DPMS_SUSPEND | ENABLE_DPMS_OFF
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCREEN_BLANKER_SIG "application/x-vnd.Haiku.screenblanker"
|
#define SCREEN_BLANKER_SIG "application/x-vnd.Haiku.screenblanker"
|
||||||
|
|
||||||
|
|
||||||
class ScreenSaverSettings {
|
class ScreenSaverSettings {
|
||||||
public:
|
public:
|
||||||
ScreenSaverSettings();
|
ScreenSaverSettings();
|
||||||
|
|
||||||
bool Load();
|
bool Load();
|
||||||
void Save();
|
void Save();
|
||||||
void Defaults();
|
void Defaults();
|
||||||
BPath& Path() { return fSettingsPath; }
|
BPath& Path() { return fSettingsPath; }
|
||||||
|
|
||||||
BRect WindowFrame() { return fWindowFrame; }
|
// General screen saver settings
|
||||||
int32 WindowTab() { return fWindowTab; }
|
int32 TimeFlags() { return fTimeFlags; }
|
||||||
int32 TimeFlags() { return fTimeFlags; }
|
bigtime_t BlankTime() { return fBlankTime; }
|
||||||
bigtime_t BlankTime() { return fBlankTime; }
|
bigtime_t StandByTime() { return fStandByTime; }
|
||||||
bigtime_t StandByTime() { return fStandByTime; }
|
bigtime_t SuspendTime() { return fSuspendTime; }
|
||||||
bigtime_t SuspendTime() { return fSuspendTime; }
|
bigtime_t OffTime() { return fOffTime; }
|
||||||
bigtime_t OffTime() { return fOffTime; }
|
|
||||||
|
|
||||||
screen_corner BlankCorner() { return fBlankCorner; }
|
screen_corner BlankCorner() { return fBlankCorner; }
|
||||||
screen_corner NeverBlankCorner() { return fNeverBlankCorner; }
|
screen_corner NeverBlankCorner() { return fNeverBlankCorner; }
|
||||||
bool LockEnable() { return fLockEnabled; }
|
bool LockEnable() { return fLockEnabled; }
|
||||||
bigtime_t PasswordTime() { return fPasswordTime; }
|
bigtime_t PasswordTime() { return fPasswordTime; }
|
||||||
const char *Password() { return fPassword.String(); }
|
const char* Password() { return fPassword.String(); }
|
||||||
const char *LockMethod() { return fLockMethod.String(); }
|
const char* LockMethod() { return fLockMethod.String(); }
|
||||||
bool IsNetworkPassword() { return strcmp(fLockMethod.String(), "custom") != 0; }
|
bool IsNetworkPassword()
|
||||||
const char *ModuleName() { return fModuleName.String(); }
|
{ return strcmp(fLockMethod.String(), "custom")
|
||||||
status_t GetModuleState(const char *name, BMessage *stateMsg);
|
!= 0; }
|
||||||
|
|
||||||
void SetWindowFrame(const BRect &fr) { fWindowFrame = fr; }
|
const char* ModuleName() { return fModuleName.String(); }
|
||||||
void SetWindowTab(int32 tab) { fWindowTab = tab; }
|
status_t GetModuleState(const char* name,
|
||||||
void SetTimeFlags(int32 tf) { fTimeFlags = tf; }
|
BMessage* stateMessage);
|
||||||
void SetBlankTime(bigtime_t bt) { fBlankTime = bt; }
|
|
||||||
void SetStandByTime(bigtime_t time) { fStandByTime = time; }
|
|
||||||
void SetSuspendTime(bigtime_t time) { fSuspendTime = time; }
|
|
||||||
void SetOffTime(bigtime_t intime) { fOffTime = intime; }
|
|
||||||
void SetBlankCorner(screen_corner in) { fBlankCorner = in; }
|
|
||||||
void SetNeverBlankCorner(screen_corner in) { fNeverBlankCorner = in; }
|
|
||||||
void SetLockEnable(bool en) { fLockEnabled = en; }
|
|
||||||
void SetPasswordTime(bigtime_t pt) { fPasswordTime = pt; }
|
|
||||||
void SetPassword(const char *pw) { fPassword = pw; }
|
|
||||||
// Cannot set network password from here.
|
|
||||||
void SetLockMethod(const char *method) { fLockMethod = method; }
|
|
||||||
void SetModuleName(const char *mn) { fModuleName = mn; }
|
|
||||||
void SetModuleState(const char *name, BMessage *stateMsg);
|
|
||||||
|
|
||||||
BMessage& Message();
|
void SetTimeFlags(uint32 flags)
|
||||||
|
{ fTimeFlags = flags; }
|
||||||
|
void SetBlankTime(bigtime_t time)
|
||||||
|
{ fBlankTime = time; }
|
||||||
|
void SetStandByTime(bigtime_t time)
|
||||||
|
{ fStandByTime = time; }
|
||||||
|
void SetSuspendTime(bigtime_t time)
|
||||||
|
{ fSuspendTime = time; }
|
||||||
|
void SetOffTime(bigtime_t intime)
|
||||||
|
{ fOffTime = intime; }
|
||||||
|
void SetBlankCorner(screen_corner in)
|
||||||
|
{ fBlankCorner = in; }
|
||||||
|
void SetNeverBlankCorner(screen_corner in)
|
||||||
|
{ fNeverBlankCorner = in; }
|
||||||
|
void SetLockEnable(bool enable)
|
||||||
|
{ fLockEnabled = enable; }
|
||||||
|
void SetPasswordTime(bigtime_t time)
|
||||||
|
{ fPasswordTime = time; }
|
||||||
|
void SetPassword(const char* password)
|
||||||
|
{ fPassword = password; }
|
||||||
|
// Cannot set network password from here.
|
||||||
|
void SetLockMethod(const char* method)
|
||||||
|
{ fLockMethod = method; }
|
||||||
|
void SetModuleName(const char* name)
|
||||||
|
{ fModuleName = name; }
|
||||||
|
void SetModuleState(const char* name,
|
||||||
|
BMessage* stateMessage);
|
||||||
|
|
||||||
private:
|
// ScreenSaver preferences settings
|
||||||
BRect fWindowFrame;
|
BRect WindowFrame() { return fWindowFrame; }
|
||||||
int32 fWindowTab;
|
int32 WindowTab() { return fWindowTab; }
|
||||||
int32 fTimeFlags;
|
|
||||||
bigtime_t fBlankTime;
|
|
||||||
bigtime_t fStandByTime;
|
|
||||||
bigtime_t fSuspendTime;
|
|
||||||
bigtime_t fOffTime;
|
|
||||||
screen_corner fBlankCorner;
|
|
||||||
screen_corner fNeverBlankCorner;
|
|
||||||
bool fLockEnabled;
|
|
||||||
bigtime_t fPasswordTime;
|
|
||||||
BString fPassword;
|
|
||||||
BString fModuleName;
|
|
||||||
BString fLockMethod;
|
|
||||||
|
|
||||||
BMessage fSettings;
|
void SetWindowFrame(const BRect& frame)
|
||||||
BPath fSettingsPath, fNetworkPath;
|
{ fWindowFrame = frame; }
|
||||||
|
void SetWindowTab(int32 tab)
|
||||||
|
{ fWindowTab = tab; }
|
||||||
|
|
||||||
|
BMessage& Message();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32 fTimeFlags;
|
||||||
|
bigtime_t fBlankTime;
|
||||||
|
bigtime_t fStandByTime;
|
||||||
|
bigtime_t fSuspendTime;
|
||||||
|
bigtime_t fOffTime;
|
||||||
|
screen_corner fBlankCorner;
|
||||||
|
screen_corner fNeverBlankCorner;
|
||||||
|
bool fLockEnabled;
|
||||||
|
bigtime_t fPasswordTime;
|
||||||
|
BString fPassword;
|
||||||
|
BString fModuleName;
|
||||||
|
BString fLockMethod;
|
||||||
|
|
||||||
|
BRect fWindowFrame;
|
||||||
|
int32 fWindowTab;
|
||||||
|
|
||||||
|
BMessage fSettings;
|
||||||
|
BPath fSettingsPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCREEN_SAVER_SETTINGS_H
|
#endif // SCREEN_SAVER_SETTINGS_H
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku.
|
* Copyright 2003-2009, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,9 +7,15 @@
|
|||||||
* Jérôme Duval, [email protected]
|
* Jérôme Duval, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*! This is the class that wraps the screensaver settings, as well as the
|
||||||
|
settings of the screensaver preference application.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ScreenSaverSettings.h"
|
#include "ScreenSaverSettings.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
@@ -17,8 +23,6 @@
|
|||||||
#include <StorageDefs.h>
|
#include <StorageDefs.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
ScreenSaverSettings::ScreenSaverSettings()
|
ScreenSaverSettings::ScreenSaverSettings()
|
||||||
{
|
{
|
||||||
@@ -27,8 +31,6 @@ ScreenSaverSettings::ScreenSaverSettings()
|
|||||||
|
|
||||||
fSettingsPath = path;
|
fSettingsPath = path;
|
||||||
fSettingsPath.Append("ScreenSaver_settings", true);
|
fSettingsPath.Append("ScreenSaver_settings", true);
|
||||||
fNetworkPath = path;
|
|
||||||
fNetworkPath.Append("network", true);
|
|
||||||
|
|
||||||
Defaults();
|
Defaults();
|
||||||
}
|
}
|
||||||
@@ -86,20 +88,7 @@ ScreenSaverSettings::Load()
|
|||||||
fModuleName = string;
|
fModuleName = string;
|
||||||
|
|
||||||
if (IsNetworkPassword()) {
|
if (IsNetworkPassword()) {
|
||||||
FILE *networkFile = NULL;
|
// TODO: this does not work yet
|
||||||
char buffer[512], *start;
|
|
||||||
// TODO: this only works under R5 net_server!
|
|
||||||
// This ugly piece opens the networking file and reads the password, if it exists.
|
|
||||||
if ((networkFile = fopen(fNetworkPath.Path(),"r")))
|
|
||||||
while (fgets(buffer, 512, networkFile) != NULL) {
|
|
||||||
if ((start = strstr(buffer,"PASSWORD = ")) != NULL) {
|
|
||||||
char password[14];
|
|
||||||
strncpy(password, start+11,strlen(start+11)-1);
|
|
||||||
password[strlen(start+11)-1] = 0;
|
|
||||||
fPassword = password;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -111,16 +100,19 @@ ScreenSaverSettings::Defaults()
|
|||||||
{
|
{
|
||||||
fWindowFrame = BRect(96.5, 77.0, 542.5, 402);
|
fWindowFrame = BRect(96.5, 77.0, 542.5, 402);
|
||||||
fWindowTab = 0;
|
fWindowTab = 0;
|
||||||
fTimeFlags = ENABLE_SAVER;
|
|
||||||
|
|
||||||
// Times are in microseconds = seconds * 1000000LL
|
// Enable blanker + turning off the screen
|
||||||
fBlankTime = 900*1000000LL; // 15 minutes
|
fTimeFlags = ENABLE_SAVER | ENABLE_DPMS_STAND_BY | ENABLE_DPMS_SUSPEND
|
||||||
|
| ENABLE_DPMS_OFF;
|
||||||
|
|
||||||
// All these times are referenced from after the above, i.e. when the screen
|
// Times are in microseconds
|
||||||
// saver is running. So standby will start 5 minutes after the screen saver.
|
fBlankTime = 900 * 1000000LL; // 15 minutes
|
||||||
fStandByTime = 300*1000000LL; // 5 minutes
|
|
||||||
fSuspendTime = 300*1000000LL; // 5 minutes
|
// All these times are relative to fBlankTime; standby will start 5 minutes
|
||||||
fOffTime = 300*1000000LL; // 5 minutes
|
// after the screen saver.
|
||||||
|
fStandByTime = 300 * 1000000LL; // 5 minutes
|
||||||
|
fSuspendTime = 300 * 1000000LL;
|
||||||
|
fOffTime = 300 * 1000000LL;
|
||||||
|
|
||||||
fBlankCorner = NO_CORNER;
|
fBlankCorner = NO_CORNER;
|
||||||
fNeverBlankCorner = NO_CORNER;
|
fNeverBlankCorner = NO_CORNER;
|
||||||
@@ -129,7 +121,7 @@ ScreenSaverSettings::Defaults()
|
|||||||
// This time is NOT referenced to when the screen saver starts, but to when
|
// This time is NOT referenced to when the screen saver starts, but to when
|
||||||
// idle time starts, like fBlankTime. By default it is the same as
|
// idle time starts, like fBlankTime. By default it is the same as
|
||||||
// fBlankTime.
|
// fBlankTime.
|
||||||
fPasswordTime = 900*1000000LL; // 15 minutes
|
fPasswordTime = 900 * 1000000LL;
|
||||||
fPassword = "";
|
fPassword = "";
|
||||||
fLockMethod = "custom";
|
fLockMethod = "custom";
|
||||||
|
|
||||||
@@ -137,7 +129,7 @@ ScreenSaverSettings::Defaults()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMessage &
|
BMessage&
|
||||||
ScreenSaverSettings::Message()
|
ScreenSaverSettings::Message()
|
||||||
{
|
{
|
||||||
// We can't just empty the message, because the module states are stored
|
// We can't just empty the message, because the module states are stored
|
||||||
@@ -180,7 +172,7 @@ ScreenSaverSettings::Message()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ScreenSaverSettings::GetModuleState(const char *name, BMessage *stateMsg)
|
ScreenSaverSettings::GetModuleState(const char* name, BMessage* stateMsg)
|
||||||
{
|
{
|
||||||
BString stateName("modulesettings_");
|
BString stateName("modulesettings_");
|
||||||
stateName += name;
|
stateName += name;
|
||||||
@@ -189,7 +181,7 @@ ScreenSaverSettings::GetModuleState(const char *name, BMessage *stateMsg)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenSaverSettings::SetModuleState(const char *name, BMessage *stateMsg)
|
ScreenSaverSettings::SetModuleState(const char* name, BMessage* stateMsg)
|
||||||
{
|
{
|
||||||
BString stateName("modulesettings_");
|
BString stateName("modulesettings_");
|
||||||
stateName += name;
|
stateName += name;
|
||||||
@@ -203,7 +195,8 @@ ScreenSaverSettings::Save()
|
|||||||
{
|
{
|
||||||
BMessage &settings = Message();
|
BMessage &settings = Message();
|
||||||
PRINT_OBJECT(settings);
|
PRINT_OBJECT(settings);
|
||||||
BFile file(fSettingsPath.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
BFile file(fSettingsPath.Path(),
|
||||||
|
B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||||
if (file.InitCheck() != B_OK || settings.Flatten(&file) != B_OK)
|
if (file.InitCheck() != B_OK || settings.Flatten(&file) != B_OK)
|
||||||
fprintf(stderr, "Problem while saving screensaver preferences file!\n");
|
fprintf(stderr, "Problem while saving screensaver preferences file!\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user