xref: /haiku/src/servers/mount/AutoMounter.h (revision 508f54795f39c3e7552d87c95aae9dd8ec6f505b)
1 /*
2  * Copyright 2007-2009, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef	AUTO_MOUNTER_H
6 #define AUTO_MOUNTER_H
7 
8 #include <Application.h>
9 #include <DiskDeviceDefs.h>
10 #include <File.h>
11 #include <Message.h>
12 
13 class BPartition;
14 class BPath;
15 
16 
17 class AutoMounter : public BApplication {
18 public:
19 								AutoMounter();
20 	virtual						~AutoMounter();
21 
22 	virtual	void				MessageReceived(BMessage* message);
23 	virtual	bool				QuitRequested();
24 
25 	virtual	BHandler*			ResolveSpecifier(BMessage* message,
26 									int32 index, BMessage* specifier,
27 									int32 what, const char* property);
28 	virtual	status_t			GetSupportedSuites(BMessage* data);
29 
30 private:
31 			enum mount_mode {
32 				kNoVolumes,
33 				kOnlyBFSVolumes,
34 				kAllVolumes,
35 				kRestorePreviousVolumes
36 			};
37 
38 			void				_GetSettings(BMessage* message);
39 			bool				_ScriptReceived(BMessage* msg, int32 index,
40 									BMessage* specifier, int32 form,
41 									const char* property);
42 
43 			void				_MountVolumes(mount_mode normal,
44 									mount_mode removable,
45 									bool initialRescan = false,
46 									partition_id deviceID = -1);
47 			void				_MountVolume(const BMessage* message);
48 			bool				_SuggestForceUnmount(const char* name,
49 									status_t error);
50 			void				_ReportUnmountError(const char* name,
51 									status_t error);
52 			void				_UnmountAndEjectVolume(BPartition* partition,
53 									BPath& mountPoint, const char* name);
54 			void				_UnmountAndEjectVolume(BMessage* message);
55 
56 			void				_FromMode(mount_mode mode, bool& all,
57 									bool& bfs, bool& restore);
58 			mount_mode			_ToMode(bool all, bool bfs,
59 									bool restore = false);
60 
61 			void				_UpdateSettingsFromMessage(BMessage* message);
62 			void				_ReadSettings();
63 			void				_WriteSettings();
64 
65 private:
66 			mount_mode			fNormalMode;
67 			mount_mode			fRemovableMode;
68 			bool				fEjectWhenUnmounting;
69 
70 			BFile				fPrefsFile;
71 			BMessage			fSettings;
72 };
73 
74 #endif // AUTO_MOUNTER_H
75