Changeset 14
- Timestamp:
- 02/23/08 15:24:45 (11 months ago)
- Location:
- trunk
- Files:
-
- 8 added
- 27 modified
-
. (modified) (1 prop)
-
MFClient.h (modified) (1 diff)
-
MFClient.m (modified) (10 diffs)
-
MFClientFS.h (modified) (2 diffs)
-
MFClientFS.m (modified) (6 diffs)
-
MFCommunicationServer.m (modified) (5 diffs)
-
MFConstants.h (modified) (2 diffs)
-
MFConstants.m (modified) (2 diffs)
-
MFError.h (added)
-
MFError.m (added)
-
MFFSDelegateProtocol.h (modified) (1 diff)
-
MFFilesystem.h (modified) (4 diffs)
-
MFFilesystem.m (modified) (3 diffs)
-
MFFilesystemController.h (modified) (2 diffs)
-
MFFilesystemController.m (modified) (9 diffs)
-
MFMainController.m (modified) (1 diff)
-
MFPlugin.h (modified) (1 diff)
-
MFPlugin.m (modified) (1 diff)
-
MFServerFS.h (modified) (2 diffs)
-
MFServerFS.m (modified) (13 diffs)
-
MFServerFSProtocol.h (added)
-
MFServerFSProtocol.m (added)
-
MFServerPlugin.m (modified) (1 diff)
-
MGUtilities.h (added)
-
MGUtilities.m (added)
-
MacFusion2.xcodeproj/project.pbxproj (modified) (24 diffs)
-
SSHFS/SSHFSDelegate.m (modified) (10 diffs)
-
SSHFS/sshfs.png (added)
-
SSHFS/sshfsConfiguration.xib (modified) (13 diffs)
-
SSHFS/sshfs_icon.icns (added)
-
Settings/MFFilesystemCell.m (modified) (1 diff)
-
Settings/MFSettingsController.h (modified) (1 diff)
-
Settings/MFSettingsController.m (modified) (7 diffs)
-
Settings/main.xib (modified) (96 diffs)
-
mfctl.m (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property
svn:ignore set
to
Icon*
*.moved-aside*
-
Property
svn:ignore set
to
-
trunk/MFClient.h
r12 r14 21 21 22 22 + (MFClient*)sharedClient; 23 - (void)fillInitialStatus; 24 - (BOOL)establishCommunication; 23 - (BOOL)setup; 25 24 26 25 - (NSArray*)filesystems; -
trunk/MFClient.m
r12 r14 13 13 14 14 @interface MFClient(PrivateAPI) 15 - (void)storeFilesystem:(MFClientFS*)fs withUUID:(NSString*)uuid;16 - (void)storePlugin:(MFClientPlugin*)plugin withID:(NSString*)id;15 - (void)storeFilesystem:(MFClientFS*)fs; 16 - (void)storePlugin:(MFClientPlugin*)plugin; 17 17 - (void)removeFilesystem:(MFClientFS*)fs; 18 18 @end … … 85 85 MFClientPlugin* plugin = [[MFClientPlugin alloc] initWithRemotePlugin: 86 86 remotePlugin]; 87 [self storePlugin: plugin 88 withID: plugin.ID]; 87 [self storePlugin: plugin]; 89 88 } 90 89 … … 96 95 MFClientFS* fs = [MFClientFS clientFSWithRemoteFS: remoteFS 97 96 clientPlugin: plugin]; 98 [self storeFilesystem: fs 99 withUUID: fs.uuid]; 100 } 101 97 [self storeFilesystem: fs]; 98 } 102 99 } 103 100 … … 119 116 } 120 117 118 - (BOOL)setup 119 { 120 if ([self establishCommunication]) 121 { 122 [self fillInitialStatus]; 123 return YES; 124 } 125 126 return NO; 127 } 128 121 129 #pragma mark Notification handling 122 130 - (void)handleStatusChangedNotification:(NSNotification*)note 123 131 { 124 // MFLogS(self, @"Status changed in MFClient");125 132 NSDictionary* info = [note userInfo]; 126 NSString* uuid = [info objectForKey: kMFFilesystemUUIDKey]; 127 MFClientFS* fs = [filesystemsDictionary objectForKey:uuid]; 128 if (fs) 129 { 130 [fs handleStatusInfoChangedNotification:note]; 131 } 132 133 if ([delegate respondsToSelector:@selector(clientStatusChanged)]) 134 { 135 [delegate clientStatusChanged]; 136 } 133 NSString* uuid = [info objectForKey: KMFFSUUIDParameter]; 134 MFClientFS* fs = [self filesystemWithUUID: uuid]; 135 [fs handleStatusInfoChangedNotification:note]; 137 136 } 138 137 … … 140 139 { 141 140 NSDictionary* info = [note userInfo]; 142 NSString* uuid = [info objectForKey: kMFFilesystemUUIDKey];141 NSString* uuid = [info objectForKey: KMFFSUUIDParameter]; 143 142 MFLogS(self, @"Filesystem Added: uuid %@", 144 143 uuid); … … 151 150 152 151 153 [self storeFilesystem:fs 154 withUUID:uuid]; 152 [self storeFilesystem:fs ]; 155 153 } 156 154 } … … 159 157 { 160 158 NSDictionary* info = [note userInfo]; 161 NSString* uuid = [info objectForKey: kMFFilesystemUUIDKey];159 NSString* uuid = [info objectForKey: KMFFSUUIDParameter]; 162 160 MFLogS(self, @"Filesystem Deleted: uuid %@", 163 161 uuid); … … 169 167 - (MFClientFS*)newFilesystemWithPlugin:(MFClientPlugin*)plugin 170 168 { 171 NSAssert(plugin, @" Asked to make new filesystem with nil plugin, MFClient");169 NSAssert(plugin, @"MFClient asked to make new filesystem with nil plugin"); 172 170 id newRemoteFS = [server newFilesystemWithPluginName: plugin.ID]; 173 171 MFClientFS* newFS = [[MFClientFS alloc] initWithRemoteFS: newRemoteFS 174 172 clientPlugin: plugin]; 175 [self storeFilesystem:newFS 176 withUUID:newFS.uuid]; 173 [self storeFilesystem:newFS ]; 177 174 return newFS; 178 175 } … … 180 177 #pragma Accessors and Setters 181 178 182 - (void)storePlugin:(MFClientPlugin*)plugin withID:(NSString*)id183 { 184 NSAssert( id, @"ID null when storing plugin in MfClient");185 [pluginsDictionary setObject: plugin forKey: id];179 - (void)storePlugin:(MFClientPlugin*)plugin 180 { 181 NSAssert(plugin && plugin.ID, @"plugin or ID null when storing plugin in MfClient"); 182 [pluginsDictionary setObject: plugin forKey: plugin.ID ]; 186 183 if ([plugins indexOfObject: plugin] == NSNotFound) 187 184 { … … 196 193 } 197 194 198 - (void)storeFilesystem:(MFClientFS*)fs withUUID:(NSString*)uuid199 { 200 NSAssert(fs && uuid, @"FS or UUID is nill when storing fs in MFClient");195 - (void)storeFilesystem:(MFClientFS*)fs 196 { 197 NSAssert(fs && fs.uuid, @"FS or fs.uuid is nil when storing fs in MFClient"); 201 198 [filesystemsDictionary setObject: fs 202 forKey: uuid];199 forKey: fs.uuid]; 203 200 if ([filesystems indexOfObject: fs] == NSNotFound) 204 201 { -
trunk/MFClientFS.h
r12 r14 9 9 #import <Cocoa/Cocoa.h> 10 10 #import "MFFilesystem.h" 11 #import "MFServerFSProtocol.h" 11 12 12 13 @class MFClientPlugin; 13 14 14 15 @interface MFClientFS : MFFilesystem { 15 id remoteFilesystem;16 id<MFServerFSProtocol> remoteFilesystem; 16 17 MFClientPlugin* plugin; 18 NSDictionary* backupParameters; 19 BOOL isEditing; 17 20 } 18 21 … … 29 32 - (void)handleParametersChangedNotification:(NSNotification*)note; 30 33 34 // Editing 35 - (NSError*)endEditingAndCommitChanges:(BOOL)commit; 36 - (void)beginEditing; 37 - (NSDictionary*)displayDictionary; 38 31 39 @end -
trunk/MFClientFS.m
r13 r14 14 14 - (void)fillInitialData; 15 15 - (void)registerNotifications; 16 - (void)copyParameters; 17 - (void)copyStatusInfo; 16 18 @end 17 19 … … 22 24 { 23 25 MFClientFS* fs = nil; 24 NSBundle* bundle = plugin.bundle; 25 NSString* filesystemClassName = [bundle objectForInfoDictionaryKey: 26 @"MFClientFSClassName"]; 27 if (filesystemClassName == nil) 28 { 29 MFLogS(self, @"Failed to instantiate filesystem with remote fs %@. No Client Filesystem class specified.", 30 remoteFS); 31 } 26 27 fs = [[MFClientFS alloc] initWithRemoteFS: remoteFS 28 clientPlugin: plugin]; 29 return fs; 30 } 31 32 + (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key 33 { 34 if ([key isEqualToString: @"displayDictionary"]) 35 return [NSSet setWithObjects: 36 KMFStatusDict, kMFParameterDict, nil]; 32 37 else 33 { 34 BOOL success = [bundle load]; 35 if (success) 36 { 37 Class filesystemClass = NSClassFromString(filesystemClassName); 38 if ([filesystemClass isSubclassOfClass: [MFClientFS class]]) 39 { 40 fs = [[filesystemClass alloc] initWithRemoteFS: remoteFS 41 clientPlugin: plugin]; 42 } 43 else 44 { 45 MFLogS(self, @"Client filesystem class %@ is not a subclass of MFClientFS", 46 filesystemClass); 47 } 48 } 49 } 50 51 return fs; 38 return [super keyPathsForValuesAffectingValueForKey: key]; 52 39 } 53 40 … … 60 47 remoteFilesystem = remoteFS; 61 48 plugin = p; 49 delegate = [plugin delegate]; 62 50 [self fillInitialData]; 63 51 [self registerNotifications]; … … 70 58 - (void)registerNotifications 71 59 { 60 /* 72 61 [self addObserver:self 73 forKeyPath: @"parameters"62 forKeyPath:kMFParameterDict 74 63 options:NSKeyValueObservingOptionNew 75 64 context:nil]; 65 */ 66 } 67 68 - (void)copyStatusInfo 69 { 70 [self willChangeValueForKey:KMFStatusDict]; 71 statusInfo = [[remoteFilesystem statusInfo] mutableCopy]; 72 NSAssert(![statusInfo isProxy], @"Status Info from DO is a Proxy. Oh shit."); 73 [self didChangeValueForKey:KMFStatusDict]; 74 } 75 76 - (void)copyParameters 77 { 78 [self willChangeValueForKey:kMFParameterDict]; 79 parameters = [[remoteFilesystem parameters] mutableCopy]; 80 NSAssert(![parameters isProxy], @"Parameters from DO is a Proxy. Oh shit."); 81 [self didChangeValueForKey:kMFParameterDict]; 76 82 } 77 83 78 84 - (void)fillInitialData 79 85 { 80 [self willChangeValueForKey:@"parameters"]; 81 parameters = [[remoteFilesystem parameters] mutableCopy]; 82 [self didChangeValueForKey:@"parameters"]; 83 [self willChangeValueForKey:@"statusInfo"]; 84 statusInfo = [[remoteFilesystem statusInfo] mutableCopy]; 85 [self didChangeValueForKey:@"statusInfo"]; 86 [self copyStatusInfo]; 87 [self copyParameters]; 86 88 } 87 89 … … 94 96 - (void)handleStatusInfoChangedNotification:(NSNotification*)note 95 97 { 96 // NSDictionary* info = [note userInfo]; 97 [self willChangeValueForKey: @"status"]; 98 statusInfo = [[remoteFilesystem statusInfo] mutableCopy]; 99 [self didChangeValueForKey: @"status"]; 98 [self copyStatusInfo]; 100 99 } 101 100 102 101 - (void)handleParametersChangedNotification:(NSNotification*)note 103 102 { 104 103 [self copyParameters]; 105 104 } 106 105 107 - (void) observeValueForKeyPath:(NSString *)keyPath 108 ofObject:(id)object 109 change:(NSDictionary *)change 110 context:(void *)context 106 - (NSDictionary*)displayDictionary 111 107 { 112 NSLog(@"Change detected on keypath %@, object %@, change %@", 113 keyPath, object, change); 108 NSMutableDictionary* dict = [NSMutableDictionary dictionary]; 109 [dict addEntriesFromDictionary: parameters]; 110 [dict addEntriesFromDictionary: statusInfo]; 111 return [dict copy]; 114 112 } 115 113 116 // Hack to make sure we are notified if any parameters change 117 - (void)setValue:(id)value 118 forKeyPath:(NSString*)keyPath 119 { 120 if ([keyPath isLike:@"parameters.*"]) 121 { 122 [self willChangeValueForKey:@"parameters"]; 123 } 124 [super setValue:value 125 forKeyPath:keyPath]; 126 if ([keyPath isLike:@"parameters.*"]) 127 { 128 [self didChangeValueForKey:@"parameters"]; 129 [remoteFilesystem setValue:value 130 forKeyPath:keyPath]; 131 } 132 } 133 114 # pragma mark Action Methods 134 115 - (void)mount 135 116 { … … 142 123 } 143 124 144 - (NSMutableDictionary*)parameters 125 126 #pragma mark Editing 127 128 - (void)setParameters:(NSMutableDictionary*)p 145 129 { 146 return parameters; 130 parameters = p; 131 } 132 133 - (void)beginEditing 134 { 135 isEditing = YES; 136 backupParameters = [NSDictionary dictionaryWithDictionary: 137 [self parameters]]; 138 } 139 140 - (NSError*)endEditingAndCommitChanges:(BOOL)commit 141 { 142 if (!isEditing) 143 { 144 [[NSException exceptionWithName:kMFBadAPIUsageException 145 reason:@"endEditing without beginEditing" 146 userInfo:nil] raise]; 147 } 148 149 if (commit) 150 { 151 NSError* result = [remoteFilesystem validateAndSetParameters: parameters]; 152 if (result) 153 { 154 return result; 155 } 156 else 157 { 158 isEditing = NO; 159 return nil; 160 } 161 } 162 else 163 { 164 isEditing = NO; 165 [self setParameters: [backupParameters mutableCopy] ]; 166 } 167 168 return nil; 169 } 170 171 - (void)willChangeValueForKey:(NSString*)key 172 { 173 if ([key isLike:@"parameters.*"] && !isEditing) 174 { 175 [[NSException exceptionWithName:@"MFBadAPIUsage" 176 reason:@"Trying to modify parameters without beginEditing" 177 userInfo:nil] raise]; 178 } 179 180 [super willChangeValueForKey:key]; 147 181 } 148 182 -
trunk/MFCommunicationServer.m
r12 r14 93 93 context:(void *)context 94 94 { 95 MFLogS(self, @"Observe triggered on keypath %@, object %@ change %@", keyPath, object, change);95 // MFLogS(self, @"Observe triggered on keypath %@, object %@", keyPath, object); 96 96 97 97 // TODO: This observation method will not be called on objects added to filesystems after registerNotifications is called … … 103 103 MFFilesystem* fs = (MFFilesystem*)object; 104 104 NSDictionary* userInfoDict = [NSDictionary dictionaryWithObjectsAndKeys: 105 fs.uuid, kMFFilesystemUUIDKey,106 fs.status, kMF FilesystemStatusKey,105 fs.uuid, KMFFSUUIDParameter, 106 fs.status, kMFSTStatusKey, 107 107 nil]; 108 108 [dnc postNotificationName:kMFStatusChangedNotification … … 128 128 129 129 NSDictionary* userInfoDict = [NSDictionary dictionaryWithObject: [fs uuid] 130 forKey: kMFFilesystemUUIDKey];130 forKey: KMFFSUUIDParameter]; 131 131 [dnc postNotificationName:kMFFilesystemAddedNotification 132 132 object:kMFDNCObject … … 171 171 - (MFServerFS*)newFilesystemWithPluginName:(NSString*)pluginName 172 172 { 173 NSAssert(pluginName, @"MFCommunicationServer: Asked for new filesystem with nil plugin name"); 173 174 MFServerPlugin* plugin = [[[MFPluginController sharedController] pluginsDictionary] 174 175 objectForKey:pluginName]; 175 if (plugin) 176 { 177 MFServerFS* fs = [[MFFilesystemController sharedController] 176 NSAssert(plugin, @"MFCommunicationServer: Asked for FS with invalid plugin name"); 177 MFServerFS* fs = [[MFFilesystemController sharedController] 178 178 newFilesystemWithPlugin: plugin]; 179 return fs; 180 } 181 else 182 { 183 MFLogS(self, @"Request failed to create new filesystem. Now plugin named %@", 184 pluginName); 185 return nil; 186 } 179 return fs; 187 180 } 188 181 … … 190 183 { 191 184 NSAssert(uuid, @"Filesystem requested with nil uuid in server"); 192 return [[MFFilesystemController sharedController] 193 filesystemWithUUID:uuid]; 185 return [[MFFilesystemController sharedController] filesystemWithUUID:uuid]; 194 186 } 195 187 -
trunk/MFConstants.h
r12 r14 9 9 10 10 // Status values for filesystems 11 /* 11 12 extern NSString* kMFStatusFSMounted; 12 13 extern NSString* kMFStatusFSUnmounted; … … 27 28 extern NSString* kMFFilesystemUUIDKey; 28 29 extern NSString* kMFFilesystemStatusKey; 30 */ 31 32 // Status 33 #define kMFStatusFSMounted @"Mounted" 34 #define kMFStatusFSUnmounted @"Unmounted" 35 #define kMFStatusFSWaiting @"Waiting to Mount" 36 #define kMFStatusFSFailed @"Failed to Mount" 37 38 // IPC Distribution Notifications 39 #define kMFStatusChangedNotification @"org.mgorbach.macfusion.notifications.statusChanged" 40 #define kMFFilesystemAddedNotification @"org.mgorbach.macfusion.notifications.fsAdded" 41 #define kMFFilesystemRemovedNotification @"org.mgorbach.macfusion.notifications.fsRemoved" 42 43 // IPC Object Names 44 #define kMFDNCObject @"org.mgorbach.macfusion" 45 #define kMFDistributedObjectName @"org.mgorbach.macfusion.do" 46 47 // Keys for Notifications 48 #define kMFFilesystemNameKey @"Name" 49 #define kMFFilesystemStatusKey @"Status" 50 51 // Parameters Common to All FUSE Filesystems 52 #define kMFFSNameParameter @"Name" 53 #define kMFFSTypeParameter @"Type" 54 #define kMFFSVolumeNameParameter @"Volume Name" 55 #define kMFFSVolumeIconPathParameter @"Icon Path" 56 #define kMFFSMountPathParameter @"Mount Path" 57 #define KMFFSUUIDParameter @"UUID" 58 #define kMFFSFilePathParameter @"File Path" 59 #define kMFFSPersistentParameter @"Is Persistent" 60 61 // Status keys 62 #define KMFStatusDict @"statusInfo" 63 #define kMFParameterDict @"parameters" 64 65 #define kMFSTErrorKey @"error" 66 #define kMFSTStatusKey @"status" 67 #define kMFSTOutputKey @"output" 29 68 30 69 // More key Names 31 70 #define kMFPluginShortNameKey @"MFPluginShortName" 32 71 #define kMFPluginLongNameKey @"MFPluginLongName" 72 73 // Error handling 74 #define kMFErrorDomain @"org.mgorbach.macfusion.errordomain" 75 enum macfusionErrorCodes { 76 kMFErrorCodeInvalidPath, 77 kMFErrorCodeDataCannotBeRead, 78 kMFErrorCodeMissingParameter, 79 kMFErrorInvalidParameterValue 80 }; 81 82 #define kMFErrorParameterKey @"parameter" 83 #define kMFErrorFilesystemKey @"filesystem" 84 #define KMFErrorPluginKey @"plugin" 85 #define kMFErrorValueKey @"value" 86 87 // Exceptions 88 #define kMFBadAPIUsageException @"Bad API Usage In Macfusion" 89 90 -
trunk/MFConstants.m
r12 r14 9 9 #import "MFConstants.h" 10 10 11 /* 11 12 NSString* kMFStatusFSMounted = @"Mounted"; 12 13 NSString* kMFStatusFSUnmounted = @"Unmounted"; … … 26 27 NSString* kMFFilesystemStatusKey = @"status"; 27 28 NSString* kMFFilesystemUUIDKey = @"status"; 29 30 */ -
trunk/MFFSDelegateProtocol.h
r12 r14 13 13 - (NSArray*)taskArgumentsForParameters:(NSDictionary*)parameters; 14 14 15 - (NSArray*)parameterList; 15 16 - (NSDictionary*)defaultParameterDictionary; 16 17 -
trunk/MFFilesystem.h
r12 r14 8 8 9 9 #import <Cocoa/Cocoa.h> 10 #import "MFFSDelegateProtocol.h" 11 10 12 @class MFPlugin; 11 13 … … 13 15 NSMutableDictionary* parameters; 14 16 NSMutableDictionary* statusInfo; 17 id <MFFSDelegateProtocol> delegate; 15 18 } 16 19 … … 24 27 - (BOOL)isWaiting; 25 28 - (BOOL)isUnmounted; 29 - (BOOL)isFailedToMount; 30 - (BOOL)isPersistent; 31 32 - (NSMutableDictionary*)parametersWithImpliedValues; 33 - (NSArray*)parameterList; 34 - (id)valueForParameterNamed:(NSString*)paramName; 35 - (NSMutableDictionary*)fillParametersWithImpliedValues:(NSDictionary*)params; 26 36 27
