diff --git a/MFClient.h b/MFClient.h index 754e86c..109b963 100644 --- a/MFClient.h +++ b/MFClient.h @@ -16,6 +16,7 @@ #import #import "MFServerProtocol.h" +#import "MFClientDelegateProtocol.h" @class MFClientFS, MFClientPlugin, MFClientRecent; @@ -27,7 +28,8 @@ NSMutableArray* plugins; NSMutableArray* recents; id server; - id delegate; + id delegate; + NSConnection* connection; } + (MFClient*)sharedClient; diff --git a/MFClient.m b/MFClient.m index b05311a..e6547b3 100644 --- a/MFClient.m +++ b/MFClient.m @@ -176,11 +176,12 @@ - (void)fillInitialStatus - (BOOL)establishCommunication { // Set up DO - id serverObject = [NSConnection rootProxyForConnectionWithRegisteredName:kMFDistributedObjectName - host:nil]; + connection = [NSConnection connectionWithRegisteredName:kMFDistributedObjectName host:nil]; + id serverObject = [connection rootProxy]; [serverObject setProtocolForProxy:@protocol(MFServerProtocol)]; server = (id )serverObject; [serverObject registerClient: self]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleConnectionDied:) name:NSConnectionDidDieNotification object:connection]; if (serverObject) { [MFLogReader sharedReader]; // Tell the log reader to update @@ -192,6 +193,8 @@ - (BOOL)establishCommunication } } + + - (BOOL)setup { if ([self establishCommunication]) @@ -213,6 +216,13 @@ - (void)noteStatusChangedForFSWithUUID:(NSString*)uuid [fs noteStatusInfoChanged]; } +- (void)noteParametersChangedForFSWithUUID:(NSString*)uuid +{ + MFClientFS* fs = [self filesystemWithUUID: uuid]; + MFLogSO(self, fs, @"Note parameters changed for fs %@", fs); + [fs noteParametersChanged]; +} + - (void)noteFilesystemAddedWithUUID:(NSString*)uuid { MFLogS(self, @"Note fs added with uuid %@", uuid); @@ -283,6 +293,13 @@ - (void)deleteFilesystem:(MFClientFS*)fs [server deleteFilesystemWithUUID: uuid]; } +- (void)handleConnectionDied:(NSNotification*)note +{ + MFLogS(self, @"Connection died %@", note); + if ([delegate respondsToSelector: @selector(handleConnectionDied)]) + [delegate handleConnectionDied]; +} + #pragma mark Recents diff --git a/MFClientDelegateProtocol.h b/MFClientDelegateProtocol.h new file mode 100644 index 0000000..0ee8a4f --- /dev/null +++ b/MFClientDelegateProtocol.h @@ -0,0 +1,24 @@ +/* + * MFClientDelegateProtocol.h + * MacFusion2 + * + * Created by Michael Gorbach on 4/5/08. + * Copyright 2008 Michael Gorbach. All rights reserved. + * + */ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +@protocol MFClientDelegateProtocol +- (void)handleConnectionDied; +@end + diff --git a/MFClientFS.m b/MFClientFS.m index 50916af..1754ccb 100644 --- a/MFClientFS.m +++ b/MFClientFS.m @@ -218,6 +218,9 @@ - (NSError*)endEditingAndCommitChanges:(BOOL)commit mfsecSetSecretsDictionaryForFilesystem( secrets, self ); } isEditing = NO; + viewControllers = nil; + topViewController = nil; + editingTabView = nil; return nil; } } @@ -226,7 +229,9 @@ - (NSError*)endEditingAndCommitChanges:(BOOL)commit isEditing = NO; [self setParameters: [backupParameters mutableCopy] ]; [self setSecrets: [backupSecrets mutableCopy]]; - + viewControllers = nil; + topViewController = nil; + editingTabView = nil; } return nil; diff --git a/MFClientFSUI.h b/MFClientFSUI.h index 742d0e6..414bcc4 100644 --- a/MFClientFSUI.h +++ b/MFClientFSUI.h @@ -5,6 +5,17 @@ // Created by Michael Gorbach on 3/30/08. // Copyright 2008 Michael Gorbach. All rights reserved. // +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #import #import "MFClientFS.h" diff --git a/MFClientFSUI.m b/MFClientFSUI.m index 30bb27d..0cd99b2 100644 --- a/MFClientFSUI.m +++ b/MFClientFSUI.m @@ -5,6 +5,17 @@ // Created by Michael Gorbach on 3/30/08. // Copyright 2008 Michael Gorbach. All rights reserved. // +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #import "MFClientFSUI.h" #import "MFAdvancedViewController.h" diff --git a/MFClientProtocol.h b/MFClientProtocol.h index 22c3949..307fe1c 100644 --- a/MFClientProtocol.h +++ b/MFClientProtocol.h @@ -6,10 +6,22 @@ * Copyright 2008 Michael Gorbach. All rights reserved. * */ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. @protocol MFClientProtocol // Updates - (void)noteStatusChangedForFSWithUUID:(NSString*)uuid; +- (void)noteParametersChangedForFSWithUUID:(NSString*)uuid; // Filesystems Array - (void)noteFilesystemAddedWithUUID:(NSString*)uuid; diff --git a/MFCommunicationServer.m b/MFCommunicationServer.m index c765777..ec307af 100644 --- a/MFCommunicationServer.m +++ b/MFCommunicationServer.m @@ -121,6 +121,13 @@ - (void) observeValueForKeyPath:(NSString *)keyPath withObject:fs.uuid]; } + if ([keyPath isEqualToString:@"parameters"] && [object isKindOfClass: [MFFilesystem class]]) + { + MFFilesystem* fs = (MFFilesystem*)object; + [clients makeObjectsPerformSelector:@selector(noteParametersChangedForFSWithUUID:) + withObject:fs.uuid]; + } + if ([keyPath isEqualToString:@"filesystems"] && object == [MFFilesystemController sharedController]) { NSUInteger changeKind = [[change objectForKey: NSKeyValueChangeKindKey] intValue]; diff --git a/MFPreferences.h b/MFPreferences.h index f3c7982..63f9fce 100644 --- a/MFPreferences.h +++ b/MFPreferences.h @@ -3,8 +3,19 @@ // MacFusion2 // // Created by Michael Gorbach on 3/15/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. +// Copyright 2008 Michael Gorbach. All rights reserved. // +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #import // Preference Keys diff --git a/MFPreferences.m b/MFPreferences.m index e823071..c386633 100644 --- a/MFPreferences.m +++ b/MFPreferences.m @@ -3,7 +3,7 @@ // MacFusion2 // // Created by Michael Gorbach on 3/15/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. +// Copyright 2008 Michael Gorbach. All rights reserved. // #import "MFPreferences.h" diff --git a/MGTestView.h b/MGTestView.h index 9537ef5..e57c10b 100644 --- a/MGTestView.h +++ b/MGTestView.h @@ -5,6 +5,17 @@ // Created by Michael Gorbach on 3/30/08. // Copyright 2008 Michael Gorbach. All rights reserved. // +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #import diff --git a/MGTestView.m b/MGTestView.m index 329f4d9..3adddef 100644 --- a/MGTestView.m +++ b/MGTestView.m @@ -5,6 +5,17 @@ // Created by Michael Gorbach on 3/30/08. // Copyright 2008 Michael Gorbach. All rights reserved. // +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #import "MGTestView.h" #import diff --git a/MacFusion2.xcodeproj/project.pbxproj b/MacFusion2.xcodeproj/project.pbxproj index abc23b6..e32025b 100644 --- a/MacFusion2.xcodeproj/project.pbxproj +++ b/MacFusion2.xcodeproj/project.pbxproj @@ -394,6 +394,7 @@ D439D6D50D0A0FDE0025574A /* sshfsConfiguration.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = sshfsConfiguration.xib; sourceTree = ""; }; D441521F0CE2933C001EEF36 /* sshfs.mfplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = sshfs.mfplugin; sourceTree = BUILT_PRODUCTS_DIR; }; D441DB620D995C2B009F869A /* MFClientProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFClientProtocol.h; sourceTree = ""; }; + D44FA6AB0DA7D0FB007AB734 /* MFClientDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFClientDelegateProtocol.h; sourceTree = ""; }; D45579150D40715F00669882 /* MFInertButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFInertButton.h; sourceTree = ""; }; D45579160D40715F00669882 /* MFInertButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFInertButton.m; sourceTree = ""; }; D45F0D940D8B3396008CC7E3 /* macfusionAgent-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "macfusionAgent-Info.plist"; sourceTree = ""; }; @@ -741,6 +742,7 @@ D403BC8D0D64C3D00049201D /* MFServerFSProtocol.h */, D4D0E9FE0D7C887A00797279 /* MFClientFSDelegateProtocol.h */, D441DB620D995C2B009F869A /* MFClientProtocol.h */, + D44FA6AB0DA7D0FB007AB734 /* MFClientDelegateProtocol.h */, ); name = Protocols; sourceTree = ""; diff --git a/Menuling/MFMenulingAppDelegate.h b/Menuling/MFMenulingAppDelegate.h index d222444..59f15e2 100644 --- a/Menuling/MFMenulingAppDelegate.h +++ b/Menuling/MFMenulingAppDelegate.h @@ -16,10 +16,11 @@ #import #import "MFClientFSDelegateProtocol.h" +#import "MFClientDelegateProtocol.h" @class MFClient, MFQuickMountController; -@interface MFMenulingAppDelegate : NSObject { +@interface MFMenulingAppDelegate : NSObject { NSStatusItem* statusItem; MFClient* client; MFQuickMountController* qmController; diff --git a/Menuling/MFMenulingAppDelegate.m b/Menuling/MFMenulingAppDelegate.m index 49d06dd..51cb106 100644 --- a/Menuling/MFMenulingAppDelegate.m +++ b/Menuling/MFMenulingAppDelegate.m @@ -48,6 +48,8 @@ - (id)init [NSApp terminate:self]; } } + + [client setDelegate: self]; return self; } @@ -87,11 +89,6 @@ - (void)awakeFromNib [statusItem setHighlightMode: YES]; [statusItem setImage: menuIcon]; [statusItem setAlternateImage: menuIconSelected]; - NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self - selector:@selector(handleConnectionDidDie:) - name:NSConnectionDidDieNotification - object:nil]; } - (void)connectToServer:(id)sender @@ -264,7 +261,7 @@ - (void)quit:(id)sender } # pragma mark Error Handling -- (void)handleConnectionDidDie:(NSNotification*)note +- (void)handleConnectionDied { // We won't try to recover since we're a background app. Let's just die ... MFLogS(self, @"Terminating due to dead agent connection"); diff --git a/Settings/MFIconSettingImageView.h b/Settings/MFIconSettingImageView.h index 932fd9e..1999118 100644 --- a/Settings/MFIconSettingImageView.h +++ b/Settings/MFIconSettingImageView.h @@ -5,6 +5,17 @@ // Created by Michael Gorbach on 3/19/08. // Copyright 2008 Michael Gorbach. All rights reserved. // +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #import @class MFClientFS; diff --git a/Settings/MFIconSettingImageView.m b/Settings/MFIconSettingImageView.m index faabc39..4de966d 100644 --- a/Settings/MFIconSettingImageView.m +++ b/Settings/MFIconSettingImageView.m @@ -5,6 +5,17 @@ // Created by Michael Gorbach on 3/19/08. // Copyright 2008 Michael Gorbach. All rights reserved. // +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #import "MFIconSettingImageView.h" #import "MFClientFS.h" diff --git a/Settings/MFSettingsController.m b/Settings/MFSettingsController.m index 89ebd98..6eaafc2 100644 --- a/Settings/MFSettingsController.m +++ b/Settings/MFSettingsController.m @@ -178,11 +178,6 @@ - (void)awakeFromNib options:nil]; [filesystemTableView setController: self]; fsBeingEdited = nil; - NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self - selector:@selector(handleConnectionDidDie:) - name:NSConnectionDidDieNotification - object:nil]; } - (void)applicationWillFinishLaunching:(NSNotification*)note @@ -601,8 +596,9 @@ - (void)connectionDidDieAlertDidEnd:(NSAlert*)alert } } -- (void)handleConnectionDidDie:(NSNotification*)note +- (void)handleConnectionDied { + if (mfcClientIsUIElement()) [NSApp terminate:self]; @@ -616,7 +612,7 @@ - (void)handleConnectionDidDie:(NSNotification*)note [connectDidDieAlert beginSheetModalForWindow:[filesystemTableView window] modalDelegate:self didEndSelector:@selector(connectionDidDieAlertDidEnd:returnCode:contextInfo:) - contextInfo:nil]; + contextInfo:nil]; } diff --git a/Settings/MGActionButton.h b/Settings/MGActionButton.h index 7988266..52b0548 100644 --- a/Settings/MGActionButton.h +++ b/Settings/MGActionButton.h @@ -3,8 +3,19 @@ // MacFusion2 // // Created by Michael Gorbach on 3/15/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. +// Copyright 2008 Michael Gorbach. All rights reserved. // +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #import diff --git a/Settings/MGActionButton.m b/Settings/MGActionButton.m index c398f7a..4c65518 100644 --- a/Settings/MGActionButton.m +++ b/Settings/MGActionButton.m @@ -3,8 +3,19 @@ // MacFusion2 // // Created by Michael Gorbach on 3/15/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. +// Copyright 2008 Michael Gorbach. All rights reserved. // +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #import "MGActionButton.h"