Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 446 lines (370 sloc) 15.173 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…
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"
42833af Fix a bunch of warnings.
Michael Gorbach authored
26 #import "MFSecurity.h"
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
27
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
28 #define ORDERING_FILE_PATH @"~/Library/Application Support/Macfusion/Ordering.plist"
29
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
30 @interface MFClient(PrivateAPI)
129b488 Continued reformatting ...
Michael Gorbach authored
31 - (void)storeFilesystem:(MFClientFS *)fs;
32 - (void)storePlugin:(MFClientPlugin *)plugin;
33 - (void)removeFilesystem:(MFClientFS *)fs;
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
34 - (void)loadOrdering;
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
35 - (void)setupKeychainMonitoring;
36 - (void)writeOrdering;
5ce0dda Adding some modifications to both clients to all recovery from an age…
Michael Gorbach authored
37 - (void)initializeIvars;
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
38
129b488 Continued reformatting ...
Michael Gorbach authored
39 @property(readwrite, retain) NSMutableArray *persistentFilesystems;
40 @property(readwrite, retain) NSMutableArray *temporaryFilesystems;
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
129b488 Continued reformatting ...
Michael Gorbach authored
47 static MFClient *sharedClient = nil;
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
48
49 #pragma mark Singleton methods
129b488 Continued reformatting ...
Michael Gorbach authored
50 + (MFClient *)sharedClient {
3ea5950 Style fixes.
Michael Gorbach authored
51 if (sharedClient == nil) {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
52 [[self alloc] init];
53 }
54
55 return sharedClient;
56 }
57
129b488 Continued reformatting ...
Michael Gorbach authored
58 + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
3ea5950 Style fixes.
Michael Gorbach authored
59 if ([key isEqualToString:@"filesystems"] || [key isEqualToString:@"mountedFilesystems"]) {
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
60 return [NSSet setWithObjects:@"persistentFilesystems", @"temporaryFilesystems", nil];
3ea5950 Style fixes.
Michael Gorbach authored
61 } else {
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
62 return [super keyPathsForValuesAffectingValueForKey: key];
3ea5950 Style fixes.
Michael Gorbach authored
63 }
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
64 }
65
66
3ea5950 Style fixes.
Michael Gorbach authored
67 + (MFClient *)allocWithZone:(NSZone *)zone {
68 if (sharedClient == nil) {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
69 sharedClient = [super allocWithZone: zone];
70 return sharedClient;
71 }
72
73 return nil;
74 }
75
3ea5950 Style fixes.
Michael Gorbach authored
76 - (void)registerForGeneralNotifications {
129b488 Continued reformatting ...
Michael Gorbach authored
77 NSDistributedNotificationCenter *dnc = [NSDistributedNotificationCenter defaultCenter];
3ea5950 Style fixes.
Michael Gorbach authored
78 [dnc addObserver:self selector:@selector(handleRecentsUpdatedNotification:) name:kMFRecentsUpdatedNotification object:kMFDNCObject];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
79
129b488 Continued reformatting ...
Michael Gorbach authored
80 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
3ea5950 Style fixes.
Michael Gorbach authored
81 [nc addObserver:self selector:@selector(handleApplicationTerminatingNotification:) name:NSApplicationWillTerminateNotification object:nil];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
82 }
83
3ea5950 Style fixes.
Michael Gorbach authored
84 - (id)init {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
85 self = [super init];
86 if (self != nil) {
129b488 Continued reformatting ...
Michael Gorbach authored
87 [[MFLogging sharedLogging] setDelegate:self];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
88 [self registerForGeneralNotifications];
5ce0dda Adding some modifications to both clients to all recovery from an age…
Michael Gorbach authored
89 [self initializeIvars];
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
90 [self setupKeychainMonitoring];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
91 }
3ea5950 Style fixes.
Michael Gorbach authored
92
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
93 return self;
94 }
95
96
3ea5950 Style fixes.
Michael Gorbach authored
97 - (void)initializeIvars {
5ce0dda Adding some modifications to both clients to all recovery from an age…
Michael Gorbach authored
98 plugins = [NSMutableArray array];
99 recents = [NSMutableArray array];
5ba8993 Pretty up the agent UI by putting it in a sheet.
Michael Gorbach authored
100 persistentFilesystems = [NSMutableArray array];
101 temporaryFilesystems = [NSMutableArray array];
5ce0dda Adding some modifications to both clients to all recovery from an age…
Michael Gorbach authored
102 }
103
3ea5950 Style fixes.
Michael Gorbach authored
104 - (void)fillInitialStatus {
5ce0dda Adding some modifications to both clients to all recovery from an age…
Michael Gorbach authored
105 // Reset everything
106 [self initializeIvars];
107
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
108 // Fill plugins
3ea5950 Style fixes.
Michael Gorbach authored
109 NSArray *remotePlugins = [server plugins];
110 NSArray *remoteFilesystems = [server filesystems];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
111
112 pluginsDictionary = [NSMutableDictionary dictionaryWithCapacity:10];
3ea5950 Style fixes.
Michael Gorbach authored
113 for(id remotePlugin in remotePlugins) {
114 Class PluginClientClass = NSClassFromString([remotePlugin subclassNameForClassName: NSStringFromClass( [MFClientPlugin class ] )]);
115 if (!PluginClientClass) {
bc361ad Add a generic ability for plugins to subclass Server & Client Filesys…
Michael Gorbach authored
116 MFLogS(self, @"Problem getting client plugin class for plugin %@", remotePlugin);
117 PluginClientClass = [MFClientPlugin class];
118 }
119
3ea5950 Style fixes.
Michael Gorbach authored
120 MFClientPlugin *plugin = [[PluginClientClass alloc] initWithRemotePlugin:remotePlugin];
121 if (plugin) {
670c5b9 Fix Port validation bug.
Michael Gorbach authored
122 [self storePlugin: plugin];
129b488 Continued reformatting ...
Michael Gorbach authored
123 } else {
670c5b9 Fix Port validation bug.
Michael Gorbach authored
124 MFLogS(self, @"Could not init client plugin from server plugin %@", remotePlugin);
3ea5950 Style fixes.
Michael Gorbach authored
125 }
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
126 }
127
128 // Fill filesystems
129 filesystemsDictionary = [NSMutableDictionary dictionaryWithCapacity:10];
3ea5950 Style fixes.
Michael Gorbach authored
130 for(id remoteFS in remoteFilesystems) {
129b488 Continued reformatting ...
Michael Gorbach authored
131 Class FSClientClass = NSClassFromString([[remoteFS plugin] subclassNameForClassName:NSStringFromClass([MFClientFS class])]);
3ea5950 Style fixes.
Michael Gorbach authored
132 if (!FSClientClass) {
bc361ad Add a generic ability for plugins to subclass Server & Client Filesys…
Michael Gorbach authored
133 MFLogS(self, @"Problem getting client fs class for fs %@", remoteFS);
3ea5950 Style fixes.
Michael Gorbach authored
134 FSClientClass = [MFClientFS class];
bc361ad Add a generic ability for plugins to subclass Server & Client Filesys…
Michael Gorbach authored
135 }
136
3ea5950 Style fixes.
Michael Gorbach authored
137 MFClientPlugin *plugin = [pluginsDictionary objectForKey: [remoteFS pluginID]];
138 MFClientFS *fs = [FSClientClass clientFSWithRemoteFS: remoteFS clientPlugin: plugin];
139 if (fs) {
670c5b9 Fix Port validation bug.
Michael Gorbach authored
140 [self storeFilesystem: fs];
3ea5950 Style fixes.
Michael Gorbach authored
141 }
142 else {
0cddf55 Optimize logging and enable structured info in ASL. Logging UI forthc…
Michael Gorbach authored
143 MFLogSO(self, remoteFS, @"Could not init client fs from server fs %@", remoteFS);
3ea5950 Style fixes.
Michael Gorbach authored
144 }
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
145 }
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
146
147 // Fill Recents
3ea5950 Style fixes.
Michael Gorbach authored
148 NSMutableArray *recentsFromServer = [[server recents] mutableCopy];
149 for (NSDictionary *recent in recentsFromServer) {
150 [[self mutableArrayValueForKey:@"recents"] addObject:[[MFClientRecent alloc] initWithParameterDictionary: recent]];
151 }
152
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
153 [self loadOrdering];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
154 }
155
3ea5950 Style fixes.
Michael Gorbach authored
156 - (BOOL)establishCommunication {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
157 // Set up DO
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
158 connection = [NSConnection connectionWithRegisteredName:kMFDistributedObjectName host:nil];
74048c0 Fix the freeze
Michael Gorbach authored
159 [connection setRequestTimeout:5.0f];
160 [connection setReplyTimeout:5.0f];
161
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
162 id serverObject = [connection rootProxy];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
163 [serverObject setProtocolForProxy:@protocol(MFServerProtocol)];
164 server = (id <MFServerProtocol>)serverObject;
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
165 [serverObject registerClient: self];
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
166 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleConnectionDied:) name:NSConnectionDidDieNotification object:connection];
3ea5950 Style fixes.
Michael Gorbach authored
167 if (serverObject) {
bc361ad Add a generic ability for plugins to subclass Server & Client Filesys…
Michael Gorbach authored
168 [MFLogReader sharedReader]; // Tell the log reader to update
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
169 return YES;
3ea5950 Style fixes.
Michael Gorbach authored
170 } else {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
171 return NO;
172 }
173 }
174
3ea5950 Style fixes.
Michael Gorbach authored
175 - (BOOL)setup {
176 if ([self establishCommunication]) {
5babd26 Fix forgotten warnings from r44 changes
Michael Gorbach authored
177 [self fillInitialStatus];
178 return YES;
179 }
180
181 return NO;
182 }
183
184
d82328f Many, many changes. Moving along
Michael Gorbach authored
185
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
186 #pragma mark Server Callback Handling
3ea5950 Style fixes.
Michael Gorbach authored
187 - (void)noteStatusChangedForFSWithUUID:(NSString *)uuid {
84b94bb Formatting.
Michael Gorbach authored
188 MFClientFS *fs = [self filesystemWithUUID:uuid];
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
189 [fs noteStatusInfoChanged];
4449887 Some overall cleanup. Addressing of ticket 40 (upgrade case)
Michael Gorbach authored
190 MFLogSO(self, fs, @"Note status changed for fs %@ to %@", fs, fs.status);
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
191 }
192
3ea5950 Style fixes.
Michael Gorbach authored
193 - (void)noteParametersChangedForFSWithUUID:(NSString *)uuid {
84b94bb Formatting.
Michael Gorbach authored
194 MFClientFS *fs = [self filesystemWithUUID:uuid];
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
195 MFLogSO(self, fs, @"Note parameters changed for fs %@", fs);
196 [fs noteParametersChanged];
197 }
198
129b488 Continued reformatting ...
Michael Gorbach authored
199 - (void)noteFilesystemAddedWithUUID:(NSString *)uuid {
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
200 MFLogS(self, @"Note fs added with uuid %@", uuid);
84b94bb Formatting.
Michael Gorbach authored
201 id remoteFilesystem = [server filesystemWithUUID:uuid];
3ea5950 Style fixes.
Michael Gorbach authored
202 if (![self filesystemWithUUID:uuid]) {
203 MFClientPlugin *plugin = [pluginsDictionary objectForKey: [remoteFilesystem pluginID]];
204 MFClientFS *fs = [MFClientFS clientFSWithRemoteFS:remoteFilesystem clientPlugin:plugin];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
205
d82328f Many, many changes. Moving along
Michael Gorbach authored
206 [self storeFilesystem:fs ];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
207 }
208 }
209
129b488 Continued reformatting ...
Michael Gorbach authored
210 - (void)noteFilesystemRemovedWithUUID:(NSString *)uuid {
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
211 MFLogS(self, @"Note fs removed with uuid %@", uuid);
84b94bb Formatting.
Michael Gorbach authored
212 MFClientFS *fs = [self filesystemWithUUID:uuid];
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
213 [self removeFilesystem: fs];
214 }
215
129b488 Continued reformatting ...
Michael Gorbach authored
216 - (void)noteRecentAdded:(NSDictionary *)recentParameters {
3ea5950 Style fixes.
Michael Gorbach authored
217 [[self mutableArrayValueForKey:@"recents"] addObject:[[MFClientRecent alloc] initWithParameterDictionary: recentParameters ]];
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
218
3ea5950 Style fixes.
Michael Gorbach authored
219 if ([[self recents] count] > 10) {
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
220 [[self mutableArrayValueForKey:@"recents"] removeObjectAtIndex: 0];
3ea5950 Style fixes.
Michael Gorbach authored
221 }
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
222 }
223
224 #pragma mark Action methods
129b488 Continued reformatting ...
Michael Gorbach authored
225 - (MFClientFS *)newFilesystemWithPlugin:(MFClientPlugin *)plugin {
d82328f Many, many changes. Moving along
Michael Gorbach authored
226 NSAssert(plugin, @"MFClient asked to make new filesystem with nil plugin");
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
227 id newRemoteFS = [server newFilesystemWithPluginName: plugin.ID];
84b94bb Formatting.
Michael Gorbach authored
228 return [self filesystemWithUUID:[newRemoteFS uuid]];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
229 }
230
129b488 Continued reformatting ...
Michael Gorbach authored
231 - (MFClientFS *)quickMountFilesystemWithURL:(NSURL *)url error:(NSError **)error {
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
232 id remoteFS = [server quickMountWithURL:url];
3ea5950 Style fixes.
Michael Gorbach authored
233 if (!remoteFS) {
234 NSError *serverError = [server recentError];
435a21b Update code conventions and fixing some stupid bugs.
Michael Gorbach authored
235 if (serverError && error)
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
236 *error = serverError;
237 return nil;
3ea5950 Style fixes.
Michael Gorbach authored
238 } else {
239 if ([self filesystemWithUUID:[remoteFS uuid]]) {
84b94bb Formatting.
Michael Gorbach authored
240 return [self filesystemWithUUID:[remoteFS uuid]];
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
241 }
242
3ea5950 Style fixes.
Michael Gorbach authored
243 MFClientPlugin *plugin = [self pluginWithID: [remoteFS pluginID]];
244 MFClientFS *newFS = [[MFClientFS alloc] initWithRemoteFS: remoteFS clientPlugin: plugin ];
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
245 [self storeFilesystem: newFS];
246 return newFS;
247 }
248 }
249
3ea5950 Style fixes.
Michael Gorbach authored
250 - (void)deleteFilesystem:(MFClientFS *)fs {
251 NSString *uuid = [fs uuid];
84b94bb Formatting.
Michael Gorbach authored
252 [server deleteFilesystemWithUUID:uuid];
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
253 }
254
3ea5950 Style fixes.
Michael Gorbach authored
255 - (void)handleConnectionDied:(NSNotification *)note {
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
256 MFLogS(self, @"Connection died %@", note);
3ea5950 Style fixes.
Michael Gorbach authored
257 if ([delegate respondsToSelector: @selector(handleConnectionDied)]) {
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
258 [delegate handleConnectionDied];
3ea5950 Style fixes.
Michael Gorbach authored
259 }
a67f653 Fix synchronization of parameters (names should change in menuling now)
Michael Gorbach authored
260 }
261
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
262 #pragma mark Recents
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
263
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
264
129b488 Continued reformatting ...
Michael Gorbach authored
265 - (MFClientFS *)mountRecent:(MFClientRecent *)recent error:(NSError **)error {
6a75864 Work on quickMount UI, error presentation, and the delegate API
Michael Gorbach authored
266 NSURL* url = [NSURL URLWithString: recent.descriptionString];
3ea5950 Style fixes.
Michael Gorbach authored
267 if (url) {
129b488 Continued reformatting ...
Michael Gorbach authored
268 MFClientFS* fs = [self quickMountFilesystemWithURL:url error:error];
269 if (fs) {
6a75864 Work on quickMount UI, error presentation, and the delegate API
Michael Gorbach authored
270 return fs;
129b488 Continued reformatting ...
Michael Gorbach authored
271 }
6a75864 Work on quickMount UI, error presentation, and the delegate API
Michael Gorbach authored
272 }
273
274 return nil;
275 }
276
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
277 #pragma mark Security
3ea5950 Style fixes.
Michael Gorbach authored
278 OSStatus myKeychainCallback ( SecKeychainEvent keychainEvent,
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
279 SecKeychainCallbackInfo *info,
3ea5950 Style fixes.
Michael Gorbach authored
280 void *context ) {
281 MFClient *self = (MFClient *)context;
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
282 // MFLogS(self, @"Keychain callback received event is %d", keychainEvent);
283 SecKeychainItemRef itemRef = info -> item;
3ea5950 Style fixes.
Michael Gorbach authored
284 NSString *uuid = mfsecUUIDForKeychainItemRef(itemRef);
285 MFClientFS *fs = [self filesystemWithUUID:uuid];
286 if (fs) {
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
287 // MFLogS(self, @"Updating secrets for fs %@ due to keychain change", fs);
288 [fs updateSecrets];
289 }
290 return 0;
291 }
292
3ea5950 Style fixes.
Michael Gorbach authored
293 - (void)setupKeychainMonitoring {
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
294 SecKeychainEventMask eventMask = kSecUpdateEventMask | kSecAddEventMask;
295 SecKeychainAddCallback(myKeychainCallback , eventMask, self);
296 }
297
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
298 #pragma mark Logging
3ea5950 Style fixes.
Michael Gorbach authored
299 - (void)sendASLMessageDict:(NSDictionary*)messageDict {
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
300 [server sendASLMessageDict: messageDict];
301 }
302
3ea5950 Style fixes.
Michael Gorbach authored
303 - (void)recordASLMessageDict:(NSDictionary*)messageDict {
bc361ad Add a generic ability for plugins to subclass Server & Client Filesys…
Michael Gorbach authored
304 [[MFLogReader sharedReader] recordASLMessageDict: messageDict];
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
305 }
306
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
307 #pragma mark Accessors and Setters
308
3ea5950 Style fixes.
Michael Gorbach authored
309 - (NSArray *)filesystems {
310 NSMutableArray *filesystems = [NSMutableArray array];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
311 [filesystems addObjectsFromArray: temporaryFilesystems];
312 [filesystems addObjectsFromArray: persistentFilesystems];
313 return [filesystems copy];
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
314 }
315
3ea5950 Style fixes.
Michael Gorbach authored
316 - (NSArray *)mountedFilesystems {
317 return [self.filesystems filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.isMounted == YES"]];
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
318 }
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
319
3ea5950 Style fixes.
Michael Gorbach authored
320 - (void)storePlugin:(MFClientPlugin *)plugin {
d82328f Many, many changes. Moving along
Michael Gorbach authored
321 NSAssert(plugin && plugin.ID, @"plugin or ID null when storing plugin in MfClient");
322 [pluginsDictionary setObject: plugin forKey: plugin.ID ];
3ea5950 Style fixes.
Michael Gorbach authored
323 if ([plugins indexOfObject: plugin] == NSNotFound) {
324 [[self mutableArrayValueForKey:@"plugins"] addObject: plugin];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
325 }
326 }
327
3ea5950 Style fixes.
Michael Gorbach authored
328 - (void)storeFilesystem:(MFClientFS *)fs {
d82328f Many, many changes. Moving along
Michael Gorbach authored
329 NSAssert(fs && fs.uuid, @"FS or fs.uuid is nil when storing fs in MFClient");
3ea5950 Style fixes.
Michael Gorbach authored
330 [filesystemsDictionary setObject: fs forKey: fs.uuid];
331 if ([fs isPersistent] && [persistentFilesystems indexOfObject: fs] == NSNotFound) {
129b488 Continued reformatting ...
Michael Gorbach authored
332 [[self mutableArrayValueForKey:@"persistentFilesystems"] addObject:fs];
3ea5950 Style fixes.
Michael Gorbach authored
333 } else if ( (![fs isPersistent]) && [temporaryFilesystems indexOfObject: fs] == NSNotFound) {
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
334 [[self mutableArrayValueForKey:@"temporaryFilesystems"] addObject: fs];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
335 }
336 }
337
3ea5950 Style fixes.
Michael Gorbach authored
338 - (void)removeFilesystem:(MFClientFS *)fs {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
339 NSAssert(fs, @"Asked to remove nil fs in MFClient");
340 [filesystemsDictionary removeObjectForKey: fs.uuid];
3ea5950 Style fixes.
Michael Gorbach authored
341 if ([fs isPersistent] && [persistentFilesystems indexOfObject: fs] != NSNotFound) {
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
342 [[self mutableArrayValueForKey:@"persistentFilesystems"]
dc563f0 Error handling and further on the menuling UI
Michael Gorbach authored
343 removeObject: fs];
3ea5950 Style fixes.
Michael Gorbach authored
344 } else if (![fs isPersistent] && [temporaryFilesystems indexOfObject: fs] != NSNotFound) {
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
345 [[self mutableArrayValueForKey:@"temporaryFilesystems"] removeObject: fs];
346 }
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
347 }
348
349
3ea5950 Style fixes.
Michael Gorbach authored
350 - (MFClientFS *)filesystemWithUUID:(NSString *)uuid {
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
351 NSAssert(uuid, @"uuid nil when requesting FS in MFClient");
352 return [filesystemsDictionary objectForKey:uuid];
353 }
354
3ea5950 Style fixes.
Michael Gorbach authored
355 - (MFClientPlugin *)pluginWithID:(NSString *)anID {
d0d4747 Get things compilin'.
Michael Gorbach authored
356 NSAssert(anID, @"id nil when requesting plugin in MFClient");
3ea5950 Style fixes.
Michael Gorbach authored
357 return [pluginsDictionary objectForKey:anID];
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
358 }
359
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some projec…
Michael Gorbach authored
360 # pragma mark UI stuff
3ea5950 Style fixes.
Michael Gorbach authored
361 - (void)moveUUIDS:(NSArray*)uuids toRow:(NSUInteger)row {
362 NSMutableArray *filesystemsToInsert = [NSMutableArray array];
363 NSMutableIndexSet *indexesToDelete = [NSMutableIndexSet indexSet];
77d08d9 Polish polish polish, and bugfixing. Plus, begining sparkle integration
Michael Gorbach authored
364
3ea5950 Style fixes.
Michael Gorbach authored
365 for(NSString *uuid in uuids) {
84b94bb Formatting.
Michael Gorbach authored
366 MFClientFS *fs = [self filesystemWithUUID:uuid];
3ea5950 Style fixes.
Michael Gorbach authored
367 if (fs && [fs isPersistent]) {
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some projec…
Michael Gorbach authored
368 [filesystemsToInsert addObject: fs];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
369 [indexesToDelete addIndex: [persistentFilesystems indexOfObject:fs]];
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some projec…
Michael Gorbach authored
370 }
371 }
372
3ea5950 Style fixes.
Michael Gorbach authored
373 NSIndexSet *indexesToAdd = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(row, [filesystemsToInsert count])];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
374 BOOL lastRow = (row == [persistentFilesystems count]);
3ea5950 Style fixes.
Michael Gorbach authored
375 NSMutableArray *updatedFilesystems = [self.persistentFilesystems mutableCopy];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
376
3ea5950 Style fixes.
Michael Gorbach authored
377 if (lastRow) {
77d08d9 Polish polish polish, and bugfixing. Plus, begining sparkle integration
Michael Gorbach authored
378 [updatedFilesystems addObjectsFromArray: filesystemsToInsert];
379 [updatedFilesystems removeObjectsAtIndexes:indexesToDelete];
3ea5950 Style fixes.
Michael Gorbach authored
380 } else if ([indexesToAdd firstIndex] < [indexesToDelete firstIndex]) {
77d08d9 Polish polish polish, and bugfixing. Plus, begining sparkle integration
Michael Gorbach authored
381 [updatedFilesystems removeObjectsAtIndexes:indexesToDelete];
382 [updatedFilesystems insertObjects:filesystemsToInsert
383 atIndexes:indexesToAdd];
3ea5950 Style fixes.
Michael Gorbach authored
384 } else {
77d08d9 Polish polish polish, and bugfixing. Plus, begining sparkle integration
Michael Gorbach authored
385 [updatedFilesystems insertObjects:filesystemsToInsert atIndexes:indexesToAdd];
386 [updatedFilesystems removeObjectsAtIndexes:indexesToDelete];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
387 }
77d08d9 Polish polish polish, and bugfixing. Plus, begining sparkle integration
Michael Gorbach authored
388
389 [self willChangeValueForKey: @"persistentFilesystems"];
390 persistentFilesystems = updatedFilesystems;
391 [self didChangeValueForKey: @"persistentFilesystems"];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
392
393 // Set the ordering correctly now
3ea5950 Style fixes.
Michael Gorbach authored
394 for(MFClientFS *fs in persistentFilesystems) {
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
395 [fs setDisplayOrder: [persistentFilesystems indexOfObject: fs]];
396 }
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
397
398 [self writeOrdering];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
399 }
400
3ea5950 Style fixes.
Michael Gorbach authored
401 - (void)writeOrdering {
402 NSArray *uuidOrdering = [self.persistentFilesystems valueForKey: @"uuid"];
403 NSString *fullPath = [ORDERING_FILE_PATH stringByExpandingTildeInPath];
404 NSString *dirPath = [fullPath stringByDeletingLastPathComponent];
405 [[NSFileManager defaultManager] createDirectoryAtPath: dirPath withIntermediateDirectories:YES attributes:nil error:NULL];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
406 [uuidOrdering writeToFile: fullPath atomically:YES];
407 }
408
3ea5950 Style fixes.
Michael Gorbach authored
409 - (void)loadOrdering {
129b488 Continued reformatting ...
Michael Gorbach authored
410 NSString *fullPath = [ORDERING_FILE_PATH stringByExpandingTildeInPath];
411 NSArray *uuidOrdering = [NSArray arrayWithContentsOfFile:fullPath];
3ea5950 Style fixes.
Michael Gorbach authored
412 if (uuidOrdering) {
129b488 Continued reformatting ...
Michael Gorbach authored
413 for(NSString *uuid in uuidOrdering)
84b94bb Formatting.
Michael Gorbach authored
414 if ([self filesystemWithUUID:uuid]) {
415 [[self filesystemWithUUID:uuid] setDisplayOrder:[uuidOrdering indexOfObject:uuid]];
129b488 Continued reformatting ...
Michael Gorbach authored
416 }
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some projec…
Michael Gorbach authored
417 }
418
77d08d9 Polish polish polish, and bugfixing. Plus, begining sparkle integration
Michael Gorbach authored
419 [self willChangeValueForKey: @"persistentFilesystems"];
3ea5950 Style fixes.
Michael Gorbach authored
420 [persistentFilesystems sortUsingDescriptors:[NSArray arrayWithObject: [[NSSortDescriptor alloc] initWithKey:@"displayOrder" ascending:YES]]];
77d08d9 Polish polish polish, and bugfixing. Plus, begining sparkle integration
Michael Gorbach authored
421 [self didChangeValueForKey: @"persistentFilesystems"];
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
422 }
423
3ea5950 Style fixes.
Michael Gorbach authored
424 - (void)handleApplicationTerminatingNotification:(NSNotification *)note {
adbc9e3 Change IPC to using entirely distributed objects instead of distributed
Michael Gorbach authored
425 [server unregisterClient: self];
88f3879 Fixing bugs. Drag and drop and other work on the main UI. Some projec…
Michael Gorbach authored
426 }
427
129b488 Continued reformatting ...
Michael Gorbach authored
428 - (NSString *)createMountIconForFilesystem:(MFClientFS *)fs atPath:(NSURL *)dirPathURL {
3ea5950 Style fixes.
Michael Gorbach authored
429 if (![fs isPersistent]) {
430 // We shouldn't be creating a mount icon for a non-persistent fs
431 return nil;
432 }
2926854 Adjust the default mount path for sshfs volumes, now we try to use th…
Michael Gorbach authored
433
129b488 Continued reformatting ...
Michael Gorbach authored
434 NSString *dirPath = [dirPathURL path];
435 NSString *filename = [NSString stringWithFormat: @"%@.fusion", [fs name]];
436 NSString *fullPath = [dirPath stringByAppendingPathComponent: filename];
eb7dcfd Moar polish.
Michael Gorbach authored
437 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:[fs uuid], kMFFSUUIDParameter, nil];
3ea5950 Style fixes.
Michael Gorbach authored
438 [dict writeToFile: fullPath atomically: YES];
129b488 Continued reformatting ...
Michael Gorbach authored
439 NSImage *iconImage = [NSImage imageNamed:@"macfusionIcon.icns"];
440 [[NSWorkspace sharedWorkspace] setIcon:iconImage forFile:fullPath options:0];
2926854 Adjust the default mount path for sshfs volumes, now we try to use th…
Michael Gorbach authored
441 return filename;
442 }
443
245fb39 Error handling and mounting mechanics work. XATTR tagging of mount po…
Michael Gorbach authored
444 @synthesize delegate, persistentFilesystems, temporaryFilesystems, plugins, recents;
4cd156a Many, many changes. Macfusion2 is now useable.
Michael Gorbach authored
445 @end
Something went wrong with that request. Please try again.