1/*
2 * Copyright 2003-2006, Michael Phipps. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef SCREEN_SAVER_SETTINGS_H
6#define SCREEN_SAVER_SETTINGS_H
7
8
9#include <Message.h>
10#include <Path.h>
11#include <String.h>
12
13
14enum screen_corner {
15	NO_CORNER = -1,
16	UP_LEFT_CORNER,
17	UP_RIGHT_CORNER,
18	DOWN_RIGHT_CORNER,
19	DOWN_LEFT_CORNER,
20	CENTER_CORNER
21};
22
23// time flags
24enum {
25	ENABLE_SAVER = 0x01,
26	ENABLE_DPMS_STAND_BY = 0x02,
27	ENABLE_DPMS_SUSPEND = 0x04,
28	ENABLE_DPMS_OFF = 0x08,
29
30	ENABLE_DPMS_MASK
31		= ENABLE_DPMS_STAND_BY | ENABLE_DPMS_SUSPEND | ENABLE_DPMS_OFF
32};
33
34#define SCREEN_BLANKER_SIG "application/x-vnd.Haiku.screenblanker"
35
36
37class ScreenSaverSettings {
38public:
39							ScreenSaverSettings();
40
41			bool			Load();
42			void			Save();
43			void			Defaults();
44			BPath&			Path() { return fSettingsPath; }
45
46			// General screen saver settings
47			int32			TimeFlags() const { return fTimeFlags; }
48			bigtime_t		BlankTime() const { return fBlankTime; }
49			bigtime_t		StandByTime() const { return fStandByTime; }
50			bigtime_t		SuspendTime() const { return fSuspendTime; }
51			bigtime_t		OffTime() const { return fOffTime; }
52
53			screen_corner	BlankCorner() const { return fBlankCorner; }
54			screen_corner	NeverBlankCorner() const { return fNeverBlankCorner; }
55			bool			LockEnable() const { return fLockEnabled; }
56			bigtime_t		PasswordTime() const { return fPasswordTime; }
57			const char*		Password() { return fPassword.String(); }
58			const char*		LockMethod() { return fLockMethod.String(); }
59			bool			IsNetworkPassword()
60								{ return strcmp(fLockMethod.String(), "custom")
61									!= 0; }
62
63			const char*		ModuleName() { return fModuleName.String(); }
64			status_t		GetModuleState(const char* name,
65								BMessage* stateMessage);
66
67			void			SetTimeFlags(uint32 flags)
68								{ fTimeFlags = flags; }
69			void			SetBlankTime(bigtime_t time)
70								{ fBlankTime = time; }
71			void			SetStandByTime(bigtime_t time)
72								{ fStandByTime = time; }
73			void			SetSuspendTime(bigtime_t time)
74								{ fSuspendTime = time; }
75			void			SetOffTime(bigtime_t intime)
76								{ fOffTime = intime; }
77			void			SetBlankCorner(screen_corner in)
78								{ fBlankCorner = in; }
79			void			SetNeverBlankCorner(screen_corner in)
80								{ fNeverBlankCorner = in; }
81			void			SetLockEnable(bool enable)
82								{ fLockEnabled = enable; }
83			void			SetPasswordTime(bigtime_t time)
84								{ fPasswordTime = time; }
85			void			SetPassword(const char* password)
86								{ fPassword = password; }
87								// Cannot set network password from here.
88			void			SetLockMethod(const char* method)
89								{ fLockMethod = method; }
90			void			SetModuleName(const char* name)
91								{ fModuleName = name; }
92			void			SetModuleState(const char* name,
93								BMessage* stateMessage);
94
95			// ScreenSaver preferences settings
96			BRect			WindowFrame() const { return fWindowFrame; }
97			int32			WindowTab() const { return fWindowTab; }
98
99			void			SetWindowFrame(const BRect& frame)
100								{ fWindowFrame = frame; }
101			void			SetWindowTab(int32 tab)
102								{ fWindowTab = tab; }
103
104			BMessage&		Message();
105
106private:
107			int32			fTimeFlags;
108			bigtime_t		fBlankTime;
109			bigtime_t		fStandByTime;
110			bigtime_t		fSuspendTime;
111			bigtime_t		fOffTime;
112			screen_corner	fBlankCorner;
113			screen_corner	fNeverBlankCorner;
114			bool			fLockEnabled;
115			bigtime_t		fPasswordTime;
116			BString			fPassword;
117			BString			fModuleName;
118			BString			fLockMethod;
119
120			BRect			fWindowFrame;
121			int32			fWindowTab;
122
123			BMessage		fSettings;
124			BPath			fSettingsPath;
125};
126
127#endif	// SCREEN_SAVER_SETTINGS_H
128