Skip to content

Commit

Permalink
Filesystems can now be mounted. Parameter processing still hacked tog…
Browse files Browse the repository at this point in the history
…ether. UI (Prefpane) and IPC skeletons now in place.
  • Loading branch information
Michael Gorbach committed Dec 9, 2007
1 parent bd49ecf commit 734747a
Show file tree
Hide file tree
Showing 24 changed files with 1,064 additions and 143 deletions.
25 changes: 25 additions & 0 deletions MFCommunicationServer.h
@@ -0,0 +1,25 @@
//
// MFCommunicationServer.h
// MacFusion2
//
// Created by Michael Gorbach on 12/7/07.
// Copyright 2007 Michael Gorbach. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "MFServerProtocol.h"

@class MFFilesystemController, MFPluginController;

@interface MFCommunicationServer : NSObject <MFServerProtocol>
{

}

+ (MFCommunicationServer*)sharedServer;

- (MFFilesystemController*)filesystemController;
- (MFPluginController*)pluginController;
- (void)startServingRunloop;

@end
103 changes: 103 additions & 0 deletions MFCommunicationServer.m
@@ -0,0 +1,103 @@
//
// MFCommunicationServer.m
// MacFusion2
//
// Created by Michael Gorbach on 12/7/07.
// Copyright 2007 Michael Gorbach. All rights reserved.
//

#import "MFCommunicationServer.h"
#import "MFFilesystemController.h"
#import "MFPluginController.h"

@implementation MFCommunicationServer
static MFCommunicationServer* sharedServer = nil;


+ (MFCommunicationServer*)sharedServer
{
if (sharedServer == nil)
{
[[self alloc] init];
}

return sharedServer;
}

+ (MFCommunicationServer*)allocWithZone:(NSZone*)zone
{
if (sharedServer == nil)
{
sharedServer = [super allocWithZone: zone];
return sharedServer;
}

return nil;
}

- (void)registerNotifications
{
NSArray* filesystems = [[self filesystemController] filesystems];
NSIndexSet* indexes = [NSIndexSet indexSetWithIndexesInRange:
NSMakeRange(0, [filesystems count])];
[filesystems addObserver:self
toObjectsAtIndexes:indexes
forKeyPath:@"status"
options:NSKeyValueObservingOptionNew
context:nil];
}

- (id) init
{
self = [super init];
if (self != nil) {
[self registerNotifications];
}
return self;
}

- (void)vendDisributedObject
{
NSConnection* connection = [NSConnection defaultConnection];
// TODO: Vend a proxy to set up protocol instead of, um , everything
[connection setRootObject:self];
if ([connection registerName:@"macfusion"] == YES)
{
MFLogS(self, @"Now Vending distributed object");
}
else
{
MFLogS(self, @"Failed to register connection name");
}
}

- (void) observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
// MFLogS(self, @"Observe triggered on keypath %@, object %@", keyPath, object);
}

- (MFFilesystemController*)filesystemController
{
return [MFFilesystemController sharedController];
}

- (MFPluginController*)pluginController
{
return [MFPluginController sharedController];
}

- (void)startServingRunloop
{
[self vendDisributedObject];
[[NSRunLoop currentRunLoop] run];
}

- (void)sendStatus
{
MFLogS(self, @"Status send triggered");
}

@end
17 changes: 17 additions & 0 deletions MFConstants.h
@@ -0,0 +1,17 @@
/*
* MFConstants.h
* MacFusion2
*
* Created by Michael Gorbach on 12/1/07.
* Copyright 2007 Michael Gorbach. All rights reserved.
*
*/

// Status values for filesystems
extern NSString* kMFStatusFSMounted;
extern NSString* kMFStatusFSUnmounted;
extern NSString* kMFStatusFSWaiting;
extern NSString* kMFStatusFSFailed;

// Notification Names
extern NSString* kMFStatusChangedNotification;
16 changes: 16 additions & 0 deletions MFConstants.m
@@ -0,0 +1,16 @@
//
// MFConstants.m
// MacFusion2
//
// Created by Michael Gorbach on 12/1/07.
// Copyright 2007 Michael Gorbach. All rights reserved.
//

#import "MFConstants.h"

NSString* kMFStatusFSMounted = @"Mounted";
NSString* kMFStatusFSUnmounted = @"Unmounted";
NSString* kMFStatusFSWaiting = @"Waiting to Mount";
NSString* kMFStatusFSFailed = @"Failed to Mount";

NSString* kMFStatusChangedNotification = @"Status Changed Notification";
19 changes: 16 additions & 3 deletions MFFilesystem.h
Expand Up @@ -12,18 +12,31 @@
@interface MFFilesystem : NSObject {
NSMutableDictionary* parameters;
MFPlugin* plugin;
NSTask* task;
NSString* status;
NSString* faliureReason;
NSString* recentOutput;
}

+ (MFFilesystem*)filesystemFromParameters:(NSDictionary*)parameters
plugin:(MFPlugin*)p;

- (MFPlugin*)plugin;
- (MFFilesystem*)initWithParameters:(NSDictionary*)parameters
plugin:(MFPlugin*)p;
- (NSDictionary*)parameterDictionary;

- (NSMutableDictionary*)fullParametersWithDictionary: (NSDictionary*)fsParams;
- (NSArray*)taskArguments;

- (BOOL)validateValue:(id)value forParameterNamed:(NSString*)param;

- (NSString*)pluginID;
//- (void)mount;
//- (void)unmount;

- (void)mount;

// - (void)unmount;

@property(readonly) MFPlugin* plugin;
@property(retain) NSString* status;

@end

0 comments on commit 734747a

Please sign in to comment.