Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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