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