xref: /haiku/headers/private/screen_saver/ScreenSaverSettings.h (revision a3dc72e69c1f71559c4eb308d543c3e8c0ea8c70)
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 	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 
37 class ScreenSaverSettings {
38 public:
39 							ScreenSaverSettings();
40 
41 			bool			Load();
42 			void			Save();
43 			void			Defaults();
Path()44 			BPath&			Path() { return fSettingsPath; }
45 
46 			// General screen saver settings
TimeFlags()47 			int32			TimeFlags() const { return fTimeFlags; }
BlankTime()48 			bigtime_t		BlankTime() const { return fBlankTime; }
StandByTime()49 			bigtime_t		StandByTime() const { return fStandByTime; }
SuspendTime()50 			bigtime_t		SuspendTime() const { return fSuspendTime; }
OffTime()51 			bigtime_t		OffTime() const { return fOffTime; }
52 
BlankCorner()53 			screen_corner	BlankCorner() const { return fBlankCorner; }
NeverBlankCorner()54 			screen_corner	NeverBlankCorner() const { return fNeverBlankCorner; }
LockEnable()55 			bool			LockEnable() const { return fLockEnabled; }
PasswordTime()56 			bigtime_t		PasswordTime() const { return fPasswordTime; }
Password()57 			const char*		Password() { return fPassword.String(); }
LockMethod()58 			const char*		LockMethod() { return fLockMethod.String(); }
IsNetworkPassword()59 			bool			IsNetworkPassword()
60 								{ return strcmp(fLockMethod.String(), "custom")
61 									!= 0; }
62 
ModuleName()63 			const char*		ModuleName() { return fModuleName.String(); }
64 			status_t		GetModuleState(const char* name,
65 								BMessage* stateMessage);
66 
SetTimeFlags(uint32 flags)67 			void			SetTimeFlags(uint32 flags)
68 								{ fTimeFlags = flags; }
SetBlankTime(bigtime_t time)69 			void			SetBlankTime(bigtime_t time)
70 								{ fBlankTime = time; }
SetStandByTime(bigtime_t time)71 			void			SetStandByTime(bigtime_t time)
72 								{ fStandByTime = time; }
SetSuspendTime(bigtime_t time)73 			void			SetSuspendTime(bigtime_t time)
74 								{ fSuspendTime = time; }
SetOffTime(bigtime_t intime)75 			void			SetOffTime(bigtime_t intime)
76 								{ fOffTime = intime; }
SetBlankCorner(screen_corner in)77 			void			SetBlankCorner(screen_corner in)
78 								{ fBlankCorner = in; }
SetNeverBlankCorner(screen_corner in)79 			void			SetNeverBlankCorner(screen_corner in)
80 								{ fNeverBlankCorner = in; }
SetLockEnable(bool enable)81 			void			SetLockEnable(bool enable)
82 								{ fLockEnabled = enable; }
SetPasswordTime(bigtime_t time)83 			void			SetPasswordTime(bigtime_t time)
84 								{ fPasswordTime = time; }
SetPassword(const char * password)85 			void			SetPassword(const char* password)
86 								{ fPassword = password; }
87 								// Cannot set network password from here.
SetLockMethod(const char * method)88 			void			SetLockMethod(const char* method)
89 								{ fLockMethod = method; }
SetModuleName(const char * name)90 			void			SetModuleName(const char* name)
91 								{ fModuleName = name; }
92 			void			SetModuleState(const char* name,
93 								BMessage* stateMessage);
94 
95 			// ScreenSaver preferences settings
WindowFrame()96 			BRect			WindowFrame() const { return fWindowFrame; }
WindowTab()97 			int32			WindowTab() const { return fWindowTab; }
98 
SetWindowFrame(const BRect & frame)99 			void			SetWindowFrame(const BRect& frame)
100 								{ fWindowFrame = frame; }
SetWindowTab(int32 tab)101 			void			SetWindowTab(int32 tab)
102 								{ fWindowTab = tab; }
103 
104 			BMessage&		Message();
105 
106 private:
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