xref: /haiku/headers/private/screen_saver/ScreenSaverSettings.h (revision a4ef4a49150f118d47324242917a596a3f8f8bd5)
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 
14 enum 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
24 enum {
25 	SAVER_DISABLED = 0x00,
26 	ENABLE_SAVER = 0x01,
27 	ENABLE_DPMS_STAND_BY = 0x02,
28 	ENABLE_DPMS_SUSPEND = 0x04,
29 	ENABLE_DPMS_OFF = 0x08,
30 
31 	ENABLE_DPMS_MASK = ENABLE_DPMS_STAND_BY | ENABLE_DPMS_SUSPEND | ENABLE_DPMS_OFF
32 };
33 
34 #define SCREEN_BLANKER_SIG "application/x-vnd.Haiku.screenblanker"
35 
36 class ScreenSaverSettings {
37 	public:
38 		ScreenSaverSettings();
39 
40 		bool Load();
41 		void Save();
42 		void Defaults();
43 		BPath& Path() { return fSettingsPath; }
44 
45 		BRect WindowFrame() { return fWindowFrame; }
46 		int32 WindowTab() { return fWindowTab; }
47 		int32 TimeFlags() { return fTimeFlags; }
48 		bigtime_t BlankTime() { return fBlankTime; }
49 		bigtime_t StandByTime() { return fStandByTime; }
50 		bigtime_t SuspendTime() { return fSuspendTime; }
51 		bigtime_t OffTime() { return fOffTime; }
52 
53 		screen_corner BlankCorner() { return fBlankCorner; }
54 		screen_corner NeverBlankCorner() { return fNeverBlankCorner; }
55 		bool LockEnable() { return fLockEnabled; }
56 		bigtime_t PasswordTime() { return fPasswordTime; }
57 		const char *Password() { return fPassword.String(); }
58 		const char *LockMethod() { return fLockMethod.String(); }
59 		bool IsNetworkPassword() { return strcmp(fLockMethod.String(), "custom") != 0; }
60 		const char *ModuleName() { return fModuleName.String(); }
61 		status_t GetModuleState(const char *name, BMessage *stateMsg);
62 
63 		void SetWindowFrame(const BRect &fr) { fWindowFrame = fr; }
64 		void SetWindowTab(int32 tab) { fWindowTab = tab; }
65 		void SetTimeFlags(int32 tf) { fTimeFlags = tf; }
66 		void SetBlankTime(bigtime_t bt) { fBlankTime = bt; }
67 		void SetStandByTime(bigtime_t time) { fStandByTime = time; }
68 		void SetSuspendTime(bigtime_t time) { fSuspendTime = time; }
69 		void SetOffTime(bigtime_t intime) { fOffTime = intime; }
70 		void SetBlankCorner(screen_corner in) { fBlankCorner = in; }
71 		void SetNeverBlankCorner(screen_corner in) { fNeverBlankCorner = in; }
72 		void SetLockEnable(bool en) { fLockEnabled = en; }
73 		void SetPasswordTime(bigtime_t pt) { fPasswordTime = pt; }
74 		void SetPassword(const char *pw) { fPassword = pw; }
75 			// Cannot set network password from here.
76 		void SetLockMethod(const char *method) { fLockMethod = method; }
77 		void SetModuleName(const char *mn) { fModuleName = mn; }
78 		void SetModuleState(const char *name, BMessage *stateMsg);
79 
80 		BMessage& Message();
81 
82 	private:
83 		BRect fWindowFrame;
84 		int32 fWindowTab;
85 		int32 fTimeFlags;
86 		bigtime_t fBlankTime;
87 		bigtime_t fStandByTime;
88 		bigtime_t fSuspendTime;
89 		bigtime_t fOffTime;
90 		screen_corner fBlankCorner;
91 		screen_corner fNeverBlankCorner;
92 		bool fLockEnabled;
93 		bigtime_t fPasswordTime;
94 		BString fPassword;
95 		BString fModuleName;
96 		BString fLockMethod;
97 
98 		BMessage fSettings;
99 		BPath fSettingsPath, fNetworkPath;
100 };
101 
102 #endif	// SCREEN_SAVER_SETTINGS_H
103