Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 251 lines (203 sloc) 5.264 kb
02855d8 Initial import
Michael Gorbach authored
1 //
2 // MFFilesystem.m
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
3 // MacFusion2
02855d8 Initial import
Michael Gorbach authored
4 //
5 // Created by Michael Gorbach on 11/5/07.
6 // Copyright 2007 Michael Gorbach. All rights reserved.
7 //
8
9 #import "MFFilesystem.h"
80b6ffa Parameter generation now works. Mounting to be working soon.
Michael Gorbach authored
10 //#import "MFPluginController.h"
51f1e26 Continuing work on the core classes for plugins and filesystems
Michael Gorbach authored
11 #import "MFPlugin.h"
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
12 #import "MFConstants.h"]
13 #import "MFSecurity.h"
02855d8 Initial import
Michael Gorbach authored
14
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some project c...
Michael Gorbach authored
15 #define FS_DIR_PATH @"~/Library/Application Support/Macfusion/Filesystems"
16
02855d8 Initial import
Michael Gorbach authored
17 @interface MFFilesystem(PrivateAPI)
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
18
02855d8 Initial import
Michael Gorbach authored
19 @end
20
21 @implementation MFFilesystem
22
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
23
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
24 # pragma mark Convenience methods
25 - (BOOL)isMounted
02855d8 Initial import
Michael Gorbach authored
26 {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
27 return [self.status isEqualToString: kMFStatusFSMounted];
02855d8 Initial import
Michael Gorbach authored
28 }
29
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
30 - (BOOL)isWaiting
02855d8 Initial import
Michael Gorbach authored
31 {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
32 return [self.status isEqualToString: kMFStatusFSWaiting];
02855d8 Initial import
Michael Gorbach authored
33 }
34
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
35 - (BOOL)isUnmounted
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
36 {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
37 return [self.status isEqualToString: kMFStatusFSUnmounted];
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
38 }
39
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
40 - (BOOL)isFailedToMount
31bd05c SSHFS subclassing
Michael Gorbach authored
41 {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
42 return [self.status isEqualToString: kMFStatusFSFailed];
02855d8 Initial import
Michael Gorbach authored
43 }
44
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
45 # pragma mark Accessors
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
46
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
47 - (NSDictionary*)statusInfo
02855d8 Initial import
Michael Gorbach authored
48 {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
49 return [statusInfo copy];
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
50 }
51
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
52 - (NSString*)mountPath
80b6ffa Parameter generation now works. Mounting to be working soon.
Michael Gorbach authored
53 {
d82328f Many, many changes. Moving along
Michael Gorbach authored
54 return [self valueForParameterNamed: kMFFSMountPathParameter ];
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
55 }
56
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
57 - (NSString*)uuid
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
58 {
d82328f Many, many changes. Moving along
Michael Gorbach authored
59 return [self valueForParameterNamed: KMFFSUUIDParameter ];
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
60 }
61
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
62 - (NSString*)status
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
63 {
d82328f Many, many changes. Moving along
Michael Gorbach authored
64 return [statusInfo objectForKey: kMFSTStatusKey];
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
65 }
66
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
67 - (NSString*)name
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
68 {
d82328f Many, many changes. Moving along
Michael Gorbach authored
69 return [self valueForParameterNamed: kMFFSNameParameter ];
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
70 }
71
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
72 - (NSString*)pluginID
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
73 {
d82328f Many, many changes. Moving along
Michael Gorbach authored
74 return [self valueForParameterNamed: kMFFSTypeParameter ];
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
75 }
76
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
77 # pragma mark Setters
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
78
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
79 - (void)setStatus:(NSString*)status
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
80 {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
81 if (status)
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
82 {
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
83 [statusInfo setObject:status forKey:kMFSTStatusKey];
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
84 }
85 }
86
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
87 - (void)mount
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
88 {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
89 // Abstract
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
90 }
91
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
92 - (void)unmount
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
93 {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
94 // Abstract
734747a Filesystems can now be mounted. Parameter processing still hacked togeth...
Michael Gorbach authored
95 }
96
d82328f Many, many changes. Moving along
Michael Gorbach authored
97 - (NSMutableDictionary*)parameters
98 {
99 return parameters;
100 }
101
102
103 - (id)findImpliedValueForParameterNamed:(NSString*)paramName
104 givenParameters:(NSDictionary*)params
105 {
6a75864 Work on quickMount UI, error presentation, and the delegate API
Michael Gorbach authored
106 if ([params objectForKey:paramName])
107 return [params objectForKey: paramName];
d82328f Many, many changes. Moving along
Michael Gorbach authored
108
109 id delegateValue = [delegate impliedValueParameterNamed: paramName
110 otherParameters: params];
111 if (delegateValue)
112 {
113 return delegateValue;
114 }
115
116 if ([paramName isEqualToString: kMFFSVolumeNameParameter])
117 {
118 return [parameters objectForKey: kMFFSNameParameter] ?
119 [parameters objectForKey: kMFFSNameParameter] :
120 @"Unnamed";
121 }
122 if ([paramName isEqualToString: kMFFSNameParameter])
123 {
124 return @"Unnamed";
125 }
126 if ([paramName isEqualToString: kMFFSFilePathParameter])
127 {
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some project c...
Michael Gorbach authored
128 NSString* expandedDirPath = [FS_DIR_PATH stringByExpandingTildeInPath];
129 NSString* fileName = [NSString stringWithFormat: @"%@.macfusion", self.uuid];
130 NSString* fullPath = [expandedDirPath stringByAppendingPathComponent: fileName];
131 return fullPath;
d82328f Many, many changes. Moving along
Michael Gorbach authored
132 }
133
134 return nil;
135 }
136
137 - (id)valueForParameterNamed:(NSString*)paramName
138 {
139 // return [[self parametersWithImpliedValues] objectForKey: paramName];
140 return [self findImpliedValueForParameterNamed: paramName
141 givenParameters: parameters ];
142 }
143
144
145 - (NSArray*)parameterList
146 {
147 NSMutableArray* parameterList = [NSMutableArray array];
148 NSArray* delegateParameterList = [delegate parameterList];
149 if (delegateParameterList)
150 {
151 [parameterList addObjectsFromArray: delegateParameterList];
152 }
153
154 [parameterList addObject: kMFFSNameParameter ];
155 [parameterList addObject: kMFFSMountPathParameter ];
156 [parameterList addObject: kMFFSVolumeNameParameter ];
157 [parameterList addObject: kMFFSVolumeIconPathParameter ];
158 [parameterList addObject: kMFFSFilePathParameter ];
159 [parameterList addObject: kMFFSPersistentParameter ];
160
161 return [parameterList copy];
162 }
163
164 - (NSMutableDictionary*)fillParametersWithImpliedValues:(NSDictionary*)params
165 {
166 NSMutableDictionary* impliedParameters = [params mutableCopy];
167 for(NSString* key in [self parameterList])
168 {
169 if (![impliedParameters objectForKey: key])
170 {
171 id value = [self findImpliedValueForParameterNamed: key
172 givenParameters: params];
173 if (value)
174 {
175 [impliedParameters setObject: value
176 forKey: key];
177 }
178 else
179 {
180 }
181 }
182 }
183
184 return impliedParameters;
185 }
186
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
187 - (void)updateSecrets
188 {
189 NSMutableDictionary* updateSecrets = [getSecretsDictionaryForFilesystem( self ) mutableCopy];
190 self.secrets = updateSecrets ? updateSecrets : [NSMutableDictionary dictionary];
191 }
192
d82328f Many, many changes. Moving along
Michael Gorbach authored
193 - (NSMutableDictionary*)parametersWithImpliedValues
194 {
195 return [self fillParametersWithImpliedValues: parameters];
196 }
197
198 - (NSString*)iconPath
199 {
200 return [self valueForParameterNamed: kMFFSVolumeIconPathParameter ];
201 }
202
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
203 - (NSString*)imagePath
204 {
205 return [self valueForParameterNamed: kMFFSVolumeImagePathParameter ];
206 }
207
d82328f Many, many changes. Moving along
Michael Gorbach authored
208 - (NSString*)descriptionString
209 {
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
210 if ([parameters objectForKey: kMFFSDescriptionParameter ])
211 return [parameters objectForKey: kMFFSDescriptionParameter ];
212
d82328f Many, many changes. Moving along
Michael Gorbach authored
213 NSString* delegateDescription = [delegate descriptionForParameters:
214 [self parametersWithImpliedValues]];
215 return delegateDescription ? delegateDescription : @"No description";
216 }
217
218 - (BOOL)isPersistent
219 {
220 return [[self valueForParameterNamed: kMFFSPersistentParameter]
221 boolValue];
222 }
223
224 - (void)setPersistent:(BOOL)b
225 {
226 [self valueForParameterNamed: kMFFSPersistentParameter ];
227 }
228
229 - (NSString*)filePath
230 {
231 return [self valueForParameterNamed: kMFFSFilePathParameter];
232 }
233
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
234 - (NSError*)error
235 {
236 return [statusInfo objectForKey: kMFSTErrorKey ];
237 }
238
d383b1e Dynamic view loading into a tabview. Some issues still to be resolved.
Michael Gorbach authored
239 - (id <MFFSDelegateProtocol>)delegate
240 {
241 return delegate;
242 }
243
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
244 - (NSString*)description
245 {
246 return [NSString stringWithFormat: @"%@ (%@)", [super description], self.name];
247 }
248
249 @synthesize secrets;
02855d8 Initial import
Michael Gorbach authored
250 @end
Something went wrong with that request. Please try again.