1 /* 2 * Copyright 2005, Axel Dörfler, axeld@pinc-software.de 3 * All rights reserved. Distributed under the terms of the MIT License. 4 * 5 * Copyright 2010-2012 Haiku, Inc. All rights reserved. 6 * Distributed under the terms of the MIT License. 7 * 8 * Authors: 9 * Hamish Morrison, hamish@lavabit.com 10 * Alexander von Gluck, kallisti5@unixzen.com 11 */ 12 #ifndef SETTINGS_H 13 #define SETTINGS_H 14 15 16 #include <stdio.h> 17 #include <stdlib.h> 18 19 #include <Point.h> 20 21 22 static const int32 kErrorSettingsNotFound = B_ERRORS_END + 1; 23 static const int32 kErrorSettingsInvalid = B_ERRORS_END + 2; 24 static const int32 kErrorVolumeNotFound = B_ERRORS_END + 3; 25 26 27 class Settings { 28 public: 29 Settings(); 30 31 bool SwapEnabled() const 32 { return fCurrentSettings.enabled; } 33 bool SwapAutomatic() const 34 { return fCurrentSettings.automatic; } 35 off_t SwapSize() const { return fCurrentSettings.size; } 36 dev_t SwapVolume() { return fCurrentSettings.volume; } 37 BPoint WindowPosition() const { return fWindowPosition; } 38 39 40 void SetSwapEnabled(bool enabled, 41 bool revertable = true); 42 void SetSwapAutomatic(bool automatic, 43 bool revertable = true); 44 void SetSwapSize(off_t size, bool revertable = true); 45 void SetSwapVolume(dev_t volume, 46 bool revertable = true); 47 void SetWindowPosition(BPoint position); 48 49 status_t ReadWindowSettings(); 50 status_t WriteWindowSettings(); 51 status_t ReadSwapSettings(); 52 status_t WriteSwapSettings(); 53 54 bool IsRevertable(); 55 void RevertSwapSettings(); 56 57 bool IsDefaultable(); 58 void DefaultSwapSettings(bool revertable = true); 59 private: 60 struct SwapSettings { 61 bool enabled; 62 bool automatic; 63 off_t size; 64 dev_t volume; 65 }; 66 67 BPoint fWindowPosition; 68 69 SwapSettings fCurrentSettings; 70 SwapSettings fInitialSettings; 71 SwapSettings fDefaultSettings; 72 }; 73 74 #endif /* SETTINGS_H */ 75