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