Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 530 lines (456 sloc) 15.278 kb
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
1 //
2 // MFClient.m
3 // MacFusion2
4 //
b798dd6 Advanced options enabled. License headers added. Added item to launch me...
Michael Gorbach authored
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
16
17 #import "MFClient.h"
18 #import "MFClientFS.h"
19 #import "MFClientPlugin.h"
20 #import "MFConstants.h"
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
21 #import "MFClientRecent.h"
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
22 #import <Security/Security.h>
23 #import "MFCore.h"
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
24 #import "MFLogReader.h"
25 #import "MFLogging.h"
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
26
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
27 #define ORDERING_FILE_PATH @"~/Library/Application Support/Macfusion/Ordering.plist"
28
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
29 @interface MFClient(PrivateAPI)
d82328f Many, many changes. Moving along
Michael Gorbach authored
30 - (void)storeFilesystem:(MFClientFS*)fs;
31 - (void)storePlugin:(MFClientPlugin*)plugin;
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
32 - (void)removeFilesystem:(MFClientFS*)fs;
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
33 - (void)loadOrdering;
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
34 - (void)setupKeychainMonitoring;
35 - (void)writeOrdering;
5ce0dda Adding some modifications to both clients to all recovery from an agent ...
Michael Gorbach authored
36 - (void)initializeIvars;
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
37 // Security monitoring
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
38
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
39 @property(readwrite, retain) NSMutableArray* persistentFilesystems;
40 @property(readwrite, retain) NSMutableArray* temporaryFilesystems;
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
41 @property(readwrite, retain) NSMutableArray* plugins;
42 @property(readwrite, retain) NSMutableArray* recents;
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
43 @end
44
45 @implementation MFClient
46
47 static MFClient* sharedClient = nil;
48
49 #pragma mark Singleton methods
50 + (MFClient*)sharedClient
51 {
52 if (sharedClient == nil)
53 {
54 [[self alloc] init];
55 }
56
57 return sharedClient;
58 }
59
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
60 + (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key
61 {
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
62 if ([key isEqualToString:@"filesystems"]
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
63 || [key isEqualToString:@"mountedFilesystems"])
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
64 return [NSSet setWithObjects:@"persistentFilesystems", @"temporaryFilesystems", nil];
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
65 else
66 return [super keyPathsForValuesAffectingValueForKey: key];
67 }
68
69
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
70 + (MFClient*)allocWithZone:(NSZone*)zone
71 {
72 if (sharedClient == nil)
73 {
74 sharedClient = [super allocWithZone: zone];
75 return sharedClient;
76 }
77
78 return nil;
79 }
80
81 - (void)registerForGeneralNotifications
82 {
83 NSDistributedNotificationCenter* dnc = [NSDistributedNotificationCenter
84 defaultCenter];
85 [dnc addObserver:self
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
86 selector:@selector(handleRecentsUpdatedNotification:)
87 name:kMFRecentsUpdatedNotification
88 object:kMFDNCObject];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
89
90 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
91 [nc addObserver:self
92 selector:@selector(handleApplicationTerminatingNotification:)
93 name:NSApplicationWillTerminateNotification
94 object:nil];
5ce0dda Adding some modifications to both clients to all recovery from an agent ...
Michael Gorbach authored
95
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
96 }
97
98 - (id) init
99 {
100 self = [super init];
101 if (self != nil) {
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
102 [[MFLogging sharedLogging] setDelegate: self];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
103 [self registerForGeneralNotifications];
5ce0dda Adding some modifications to both clients to all recovery from an agent ...
Michael Gorbach authored
104 [self initializeIvars];
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
105 [self setupKeychainMonitoring];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
106 }
107 return self;
108 }
109
110
5ce0dda Adding some modifications to both clients to all recovery from an agent ...
Michael Gorbach authored
111 - (void)initializeIvars
112 {
5ba8993 Pretty up the agent UI by putting it in a sheet.
Michael Gorbach authored
113 // persistentFilesystems = [NSMutableArray array];
114 // temporaryFilesystems = [NSMutableArray array];
5ce0dda Adding some modifications to both clients to all recovery from an agent ...
Michael Gorbach authored
115 plugins = [NSMutableArray array];
116 recents = [NSMutableArray array];
5ba8993 Pretty up the agent UI by putting it in a sheet.
Michael Gorbach authored
117 persistentFilesystems = [NSMutableArray array];
118 temporaryFilesystems = [NSMutableArray array];
5ce0dda Adding some modifications to both clients to all recovery from an agent ...
Michael Gorbach authored
119 }
120
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
121 - (void)fillInitialStatus
122 {
5ce0dda Adding some modifications to both clients to all recovery from an agent ...
Michael Gorbach authored
123 // Reset everything
124 [self initializeIvars];
125
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
126 // Fill plugins
127 NSArray* remotePlugins = [server plugins];
128 NSArray* remoteFilesystems = [server filesystems];
129
130 pluginsDictionary = [NSMutableDictionary dictionaryWithCapacity:10];
131 for(id remotePlugin in remotePlugins)
132 {
bc361ad Add a generic ability for plugins to subclass Server & Client Filesystem...
Michael Gorbach authored
133 Class PluginClientClass = NSClassFromString( [remotePlugin subclassNameForClassName: NSStringFromClass( [MFClientPlugin class ] ) ] );
134 if (!PluginClientClass)
135 {
136 MFLogS(self, @"Problem getting client plugin class for plugin %@", remotePlugin);
137 PluginClientClass = [MFClientPlugin class];
138 }
139
140 MFClientPlugin* plugin = [[PluginClientClass alloc] initWithRemotePlugin:
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
141 remotePlugin];
670c5b9 Fix Port validation bug.
Michael Gorbach authored
142 if (plugin)
143 [self storePlugin: plugin];
144 else
145 MFLogS(self, @"Could not init client plugin from server plugin %@", remotePlugin);
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
146 }
147
148 // Fill filesystems
149 filesystemsDictionary = [NSMutableDictionary dictionaryWithCapacity:10];
150 for(id remoteFS in remoteFilesystems)
151 {
bc361ad Add a generic ability for plugins to subclass Server & Client Filesystem...
Michael Gorbach authored
152 Class FSClientClass = NSClassFromString( [[remoteFS plugin] subclassNameForClassName: NSStringFromClass( [MFClientFS class] ) ] );
153 if (!FSClientClass)
154 {
155 MFLogS(self, @"Problem getting client fs class for fs %@", remoteFS);
156 FSClientClass = [ MFClientFS class ];
157 }
158
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
159 MFClientPlugin* plugin = [pluginsDictionary objectForKey: [remoteFS pluginID]];
bc361ad Add a generic ability for plugins to subclass Server & Client Filesystem...
Michael Gorbach authored
160 MFClientFS* fs = [FSClientClass clientFSWithRemoteFS: remoteFS
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
161 clientPlugin: plugin];
670c5b9 Fix Port validation bug.
Michael Gorbach authored
162 if (fs)
163 [self storeFilesystem: fs];
164 else
0cddf55 Optimize logging and enable structured info in ASL. Logging UI forthcomi...
Michael Gorbach authored
165 MFLogSO(self, remoteFS, @"Could not init client fs from server fs %@", remoteFS);
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
166 }
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
167
168 // Fill Recents
169 NSMutableArray* recentsFromServer = [[server recents] mutableCopy];
170 for (NSDictionary* recent in recentsFromServer)
171 [[self mutableArrayValueForKey:@"recents"] addObject:
172 [[MFClientRecent alloc] initWithParameterDictionary: recent]];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
173 [self loadOrdering];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
174 }
175
176 - (BOOL)establishCommunication
177 {
178 // Set up DO
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
179 connection = [NSConnection connectionWithRegisteredName:kMFDistributedObjectName host:nil];
180 id serverObject = [connection rootProxy];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
181 [serverObject setProtocolForProxy:@protocol(MFServerProtocol)];
182 server = (id <MFServerProtocol>)serverObject;
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
183 [serverObject registerClient: self];
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
184 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleConnectionDied:) name:NSConnectionDidDieNotification object:connection];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
185 if (serverObject)
186 {
bc361ad Add a generic ability for plugins to subclass Server & Client Filesystem...
Michael Gorbach authored
187 [MFLogReader sharedReader]; // Tell the log reader to update
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
188 return YES;
189 }
190 else
191 {
192 return NO;
193 }
194 }
195
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
196
197
5babd26 Fix forgotten warnings from r44 changes
Michael Gorbach authored
198 - (BOOL)setup
199 {
200 if ([self establishCommunication])
201 {
202 [self fillInitialStatus];
203 return YES;
204 }
205
206 return NO;
207 }
208
209
d82328f Many, many changes. Moving along
Michael Gorbach authored
210
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
211 #pragma mark Server Callback Handling
212 - (void)noteStatusChangedForFSWithUUID:(NSString*)uuid
d82328f Many, many changes. Moving along
Michael Gorbach authored
213 {
214 MFClientFS* fs = [self filesystemWithUUID: uuid];
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
215 MFLogSO(self, fs, @"Note status changed for fs %@", fs);
216 [fs noteStatusInfoChanged];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
217 }
218
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
219 - (void)noteParametersChangedForFSWithUUID:(NSString*)uuid
220 {
221 MFClientFS* fs = [self filesystemWithUUID: uuid];
222 MFLogSO(self, fs, @"Note parameters changed for fs %@", fs);
223 [fs noteParametersChanged];
224 }
225
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
226 - (void)noteFilesystemAddedWithUUID:(NSString*)uuid
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
227 {
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
228 MFLogS(self, @"Note fs added with uuid %@", uuid);
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
229 id remoteFilesystem = [server filesystemWithUUID: uuid];
230 if (![self filesystemWithUUID:uuid])
231 {
232 MFClientPlugin* plugin = [pluginsDictionary objectForKey: [remoteFilesystem pluginID]];
233 MFClientFS* fs = [MFClientFS clientFSWithRemoteFS:remoteFilesystem
234 clientPlugin:plugin];
235
d82328f Many, many changes. Moving along
Michael Gorbach authored
236 [self storeFilesystem:fs ];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
237 }
238 }
239
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
240 - (void)noteFilesystemRemovedWithUUID:(NSString*)uuid
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
241 {
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
242 MFLogS(self, @"Note fs removed with uuid %@", uuid);
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
243 MFClientFS* fs = [self filesystemWithUUID: uuid];
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
244 [self removeFilesystem: fs];
245 }
246
247 - (void)noteRecentAdded:(NSDictionary*)recentParameters
248 {
249 [[self mutableArrayValueForKey:@"recents"] addObject:
250 [[MFClientRecent alloc] initWithParameterDictionary: recentParameters ]];
251
252 if ([[self recents] count] > 10)
253 [[self mutableArrayValueForKey:@"recents"] removeObjectAtIndex: 0];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
254 }
255
256 #pragma mark Action methods
257 - (MFClientFS*)newFilesystemWithPlugin:(MFClientPlugin*)plugin
258 {
d82328f Many, many changes. Moving along
Michael Gorbach authored
259 NSAssert(plugin, @"MFClient asked to make new filesystem with nil plugin");
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
260 id newRemoteFS = [server newFilesystemWithPluginName: plugin.ID];
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
261 return [self filesystemWithUUID: [newRemoteFS uuid]];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
262 }
263
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
264 - (MFClientFS*)quickMountFilesystemWithURL:(NSURL*)url
265 error:(NSError**)error
266 {
267 id remoteFS = [server quickMountWithURL:url];
268 if (!remoteFS)
269 {
270 NSError* serverError = [server recentError];
271 if (serverError)
272 *error = serverError;
273 return nil;
274 }
275 else
276 {
277 if ([self filesystemWithUUID:[remoteFS uuid]])
278 {
279 return [self filesystemWithUUID: [remoteFS uuid]];
280 }
281
282 MFClientPlugin* plugin = [self pluginWithID: [remoteFS pluginID]];
283 MFClientFS* newFS = [[MFClientFS alloc] initWithRemoteFS: remoteFS
284 clientPlugin: plugin ];
285 [self storeFilesystem: newFS];
286 return newFS;
287 }
288 }
289
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
290 - (void)deleteFilesystem:(MFClientFS*)fs
291 {
292 NSString* uuid = [fs uuid];
293 [server deleteFilesystemWithUUID: uuid];
294 }
295
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
296 - (void)handleConnectionDied:(NSNotification*)note
297 {
298 MFLogS(self, @"Connection died %@", note);
299 if ([delegate respondsToSelector: @selector(handleConnectionDied)])
300 [delegate handleConnectionDied];
301 }
302
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
303 #pragma mark Recents
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
304
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
305
6a75864 Work on quickMount UI, error presentation, and the delegate API
Michael Gorbach authored
306 - (MFClientFS*)mountRecent:(MFClientRecent*)recent
307 error:(NSError**)error;
308 {
309 NSURL* url = [NSURL URLWithString: recent.descriptionString];
310 if (url)
311 {
312 MFClientFS* fs = [self quickMountFilesystemWithURL: url
313 error: error ];
314 if (fs)
315 return fs;
316 }
317
318 return nil;
319 }
320
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
321 #pragma mark Security
322 OSStatus myKeychainCallback (
323 SecKeychainEvent keychainEvent,
324 SecKeychainCallbackInfo *info,
325 void *context
326 )
327 {
328 MFClient* self = (MFClient*)context;
329 // MFLogS(self, @"Keychain callback received event is %d", keychainEvent);
330 SecKeychainItemRef itemRef = info -> item;
75d77a4 Some renaming of C functions. Fix path resolution problems that lead to ...
Michael Gorbach authored
331 NSString* uuid = (NSString*)mfsecUUIDForKeychainItemRef(itemRef);
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
332 MFClientFS* fs = [self filesystemWithUUID:uuid];
333 if (fs)
334 {
335 // MFLogS(self, @"Updating secrets for fs %@ due to keychain change", fs);
336 [fs updateSecrets];
337 }
338 return 0;
339 }
340
341 - (void)setupKeychainMonitoring
342 {
343 SecKeychainEventMask eventMask = kSecUpdateEventMask | kSecAddEventMask;
344 SecKeychainAddCallback(myKeychainCallback , eventMask, self);
345 }
346
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
347 #pragma mark Logging
348 - (void)sendASLMessageDict:(NSDictionary*)messageDict
349 {
350 [server sendASLMessageDict: messageDict];
351 }
352
353 - (void)recordASLMessageDict:(NSDictionary*)messageDict
354 {
bc361ad Add a generic ability for plugins to subclass Server & Client Filesystem...
Michael Gorbach authored
355 [[MFLogReader sharedReader] recordASLMessageDict: messageDict];
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
356 }
357
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
358 #pragma mark Accessors and Setters
359
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
360 - (NSArray*)filesystems
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
361 {
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
362 NSMutableArray* filesystems = [NSMutableArray array];
363 [filesystems addObjectsFromArray: temporaryFilesystems];
364 [filesystems addObjectsFromArray: persistentFilesystems];
365 return [filesystems copy];
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
366 }
367
368 - (NSArray*)mountedFilesystems
369 {
370 return [self.filesystems filteredArrayUsingPredicate:
371 [NSPredicate predicateWithFormat:@"self.isMounted == YES"]];
372 }
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
373
d82328f Many, many changes. Moving along
Michael Gorbach authored
374 - (void)storePlugin:(MFClientPlugin*)plugin
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
375 {
d82328f Many, many changes. Moving along
Michael Gorbach authored
376 NSAssert(plugin && plugin.ID, @"plugin or ID null when storing plugin in MfClient");
377 [pluginsDictionary setObject: plugin forKey: plugin.ID ];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
378 if ([plugins indexOfObject: plugin] == NSNotFound)
379 {
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
380 [[self mutableArrayValueForKey:@"plugins"]
381 addObject: plugin];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
382 }
383 }
384
d82328f Many, many changes. Moving along
Michael Gorbach authored
385 - (void)storeFilesystem:(MFClientFS*)fs
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
386 {
d82328f Many, many changes. Moving along
Michael Gorbach authored
387 NSAssert(fs && fs.uuid, @"FS or fs.uuid is nil when storing fs in MFClient");
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
388 [filesystemsDictionary setObject: fs
d82328f Many, many changes. Moving along
Michael Gorbach authored
389 forKey: fs.uuid];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
390 if ([fs isPersistent] && [persistentFilesystems indexOfObject: fs] == NSNotFound)
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
391 {
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
392 [[self mutableArrayValueForKey:@"persistentFilesystems"] addObject: fs];
393 }
394 else if ( (![fs isPersistent]) && [temporaryFilesystems indexOfObject: fs] == NSNotFound)
395 {
396 [[self mutableArrayValueForKey:@"temporaryFilesystems"] addObject: fs];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
397 }
398 }
399
400 - (void)removeFilesystem:(MFClientFS*)fs
401 {
402 NSAssert(fs, @"Asked to remove nil fs in MFClient");
403 [filesystemsDictionary removeObjectForKey: fs.uuid];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
404 if ([fs isPersistent] && [persistentFilesystems indexOfObject: fs] != NSNotFound)
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
405 {
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
406 [[self mutableArrayValueForKey:@"persistentFilesystems"]
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
407 removeObject: fs];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
408 }
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
409 else if (![fs isPersistent] && [temporaryFilesystems indexOfObject: fs] != NSNotFound)
410 {
411 [[self mutableArrayValueForKey:@"temporaryFilesystems"] removeObject: fs];
412 }
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
413 }
414
415
416 - (MFClientFS*)filesystemWithUUID:(NSString*)uuid
417 {
418 NSAssert(uuid, @"uuid nil when requesting FS in MFClient");
419 return [filesystemsDictionary objectForKey:uuid];
420 }
421
422 - (MFClientPlugin*)pluginWithID:(NSString*)id
423 {
424 NSAssert(id, @"id nil when requesting plugin in MFClient");
425 return [pluginsDictionary objectForKey:id];
426 }
427
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some project c...
Michael Gorbach authored
428 # pragma mark UI stuff
429 - (void)moveUUIDS:(NSArray*)uuids
430 toRow:(NSUInteger)row
431 {
432 NSMutableArray* filesystemsToInsert = [NSMutableArray array];
433 NSMutableIndexSet* indexesToDelete = [NSMutableIndexSet indexSet];
434 for(NSString* uuid in uuids)
435 {
436 MFClientFS* fs = [self filesystemWithUUID: uuid];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
437 if (fs && [fs isPersistent])
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some project c...
Michael Gorbach authored
438 {
439 [filesystemsToInsert addObject: fs];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
440 [indexesToDelete addIndex: [persistentFilesystems indexOfObject:fs]];
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some project c...
Michael Gorbach authored
441 }
442 }
443
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
444 NSIndexSet* indexesToAdd = [NSIndexSet indexSetWithIndexesInRange:
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some project c...
Michael Gorbach authored
445 NSMakeRange(row, [filesystemsToInsert count])];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
446 BOOL lastRow = (row == [persistentFilesystems count]);
447
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some project c...
Michael Gorbach authored
448 if (lastRow)
449 {
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
450 [[self mutableArrayValueForKey:@"persistentFilesystems"] addObjectsFromArray: filesystemsToInsert];
451 [[self mutableArrayValueForKey:@"persistentFilesystems"] removeObjectsAtIndexes:indexesToDelete];
452 }
453 else if ([indexesToAdd firstIndex] < [indexesToDelete firstIndex])
454 {
455 [[self mutableArrayValueForKey:@"persistentFilesystems"] removeObjectsAtIndexes:indexesToDelete];
456 [[self mutableArrayValueForKey:@"persistentFilesystems"] insertObjects:filesystemsToInsert
457 atIndexes:indexesToAdd];
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some project c...
Michael Gorbach authored
458 }
459 else
460 {
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
461 [[self mutableArrayValueForKey:@"persistentFilesystems"] insertObjects:filesystemsToInsert
462 atIndexes:indexesToAdd];
463 [[self mutableArrayValueForKey:@"persistentFilesystems"] removeObjectsAtIndexes:indexesToDelete];
464 }
465
466 // Set the ordering correctly now
467 for(MFClientFS* fs in persistentFilesystems)
468 {
469 [fs setDisplayOrder: [persistentFilesystems indexOfObject: fs]];
470 }
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
471
472 [self writeOrdering];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
473 }
474
475 - (void)writeOrdering
476 {
477 NSArray* uuidOrdering = [self.persistentFilesystems valueForKey: @"uuid"];
478 NSString* fullPath = [ORDERING_FILE_PATH stringByExpandingTildeInPath];
479 NSString* dirPath = [fullPath stringByDeletingLastPathComponent];
480 [[NSFileManager defaultManager] createDirectoryAtPath: dirPath
481 withIntermediateDirectories:YES
482 attributes:nil
483 error:NO];
484 [uuidOrdering writeToFile: fullPath atomically:YES];
485 }
486
487 - (void)loadOrdering
488 {
489 NSString* fullPath = [ORDERING_FILE_PATH stringByExpandingTildeInPath];
490 NSArray* uuidOrdering = [NSArray arrayWithContentsOfFile: fullPath];
491 if (uuidOrdering)
492 {
493 for(NSString* uuid in uuidOrdering)
494 if ([self filesystemWithUUID: uuid])
495 [[self filesystemWithUUID: uuid] setDisplayOrder:
496 [uuidOrdering indexOfObject: uuid]];
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some project c...
Michael Gorbach authored
497 }
498
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
499 [persistentFilesystems sortUsingDescriptors:
500 [NSArray arrayWithObject: [[NSSortDescriptor alloc] initWithKey:@"displayOrder" ascending:YES]]];
501 }
502
503 - (void)handleApplicationTerminatingNotification:(NSNotification*)note
504 {
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
505 [server unregisterClient: self];
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some project c...
Michael Gorbach authored
506 }
507
2926854 Adjust the default mount path for sshfs volumes, now we try to use the n...
Michael Gorbach authored
508 - (NSString*)createMountIconForFilesystem:(MFClientFS*)fs
509 atPath:(NSURL*)dirPathURL
510 {
511 if (![fs isPersistent]) // We shouldn't be creating a mount icon for a non-persistent fs
512 return nil;
513
514 NSString* dirPath = [dirPathURL path];
515 NSString* filename = [NSString stringWithFormat: @"%@.fusion", [fs name]];
516 NSString* fullPath = [dirPath stringByAppendingPathComponent: filename];
517 NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:
518 [fs uuid], KMFFSUUIDParameter, nil];
519 [dict writeToFile: fullPath
520 atomically: YES];
521 NSImage* iconImage = [NSImage imageNamed:@"macfusionIcon.icns"];
522 [[NSWorkspace sharedWorkspace] setIcon: iconImage
523 forFile:fullPath
524 options:0];
525 return filename;
526 }
527
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount point...
Michael Gorbach authored
528 @synthesize delegate, persistentFilesystems, temporaryFilesystems, plugins, recents;
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
529 @end
Something went wrong with that request. Please try again.