From 78d29b74fedfc3bdbb5c6f2511e826c944a73df4 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Sat, 3 Nov 2012 17:39:44 +0100 Subject: [PATCH 01/36] Forgot to change UTIs in APDataProvider when moving away from our own UTI for m4v files --- Plugins/AtomicParsley/src/APDataProvider.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/AtomicParsley/src/APDataProvider.m b/Plugins/AtomicParsley/src/APDataProvider.m index 0c23301d..2408e42c 100644 --- a/Plugins/AtomicParsley/src/APDataProvider.m +++ b/Plugins/AtomicParsley/src/APDataProvider.m @@ -107,7 +107,7 @@ - (id)init writes = [[NSMutableArray alloc] init]; types = [[NSArray alloc] initWithObjects: @"public.mpeg-4", @"com.apple.quicktime-movie", - @"org.maven-group.mpeg4-video", nil]; + @"com.apple.m4v-video", @"com.apple.protected-mpeg-4-video", nil]; tags = [[MZTag allKnownTags] retain]; NSArray* readmapkeys = [NSArray arrayWithObjects: @"©nam", @"©ART", @"©day", From 90bae9732d6d92879f008963c25e8d238158a971 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Sat, 3 Nov 2012 17:50:04 +0100 Subject: [PATCH 02/36] Added our own array controller with delayed rearrangement and enabled automaticallyRearrangesObjects for files --- App/English.lproj/MainMenu.xib | 27 +++++++++++++++++++++------ App/src/MZArrayController.h | 15 +++++++++++++++ App/src/MZArrayController.m | 29 +++++++++++++++++++++++++++++ MetaZ.xcodeproj/project.pbxproj | 6 ++++++ 4 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 App/src/MZArrayController.h create mode 100644 App/src/MZArrayController.m diff --git a/App/English.lproj/MainMenu.xib b/App/English.lproj/MainMenu.xib index f0517f98..bbc58d03 100644 --- a/App/English.lproj/MainMenu.xib +++ b/App/English.lproj/MainMenu.xib @@ -13,10 +13,10 @@ YES + - - + YES @@ -5783,6 +5783,7 @@ YES YES YES + YES FilesUndoController @@ -13459,6 +13460,7 @@ 780.IBPluginDependency 781.IBPluginDependency 800.IBPluginDependency + 805.CustomClassName 805.IBPluginDependency 81.IBEditorWindowLastContentRect 81.IBPluginDependency @@ -14090,6 +14092,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + MZArrayController com.apple.InterfaceBuilder.CocoaPlugin {{520, 696}, {148, 93}} com.apple.InterfaceBuilder.CocoaPlugin @@ -14749,6 +14752,14 @@ App/src/GenreDataSource.h + + MZArrayController + NSArrayController + + IBProjectSource + App/src/MZArrayController.h + + MZMetaLoader NSObject @@ -14853,6 +14864,13 @@ App/src/MetaZApplication.h + + NSObject + + IBProjectSource + App/src/UndoTableView.h + + NSObject @@ -15368,10 +15386,7 @@ UndoTableView NSTableView - - IBProjectSource - App/src/UndoTableView.h - + diff --git a/App/src/MZArrayController.h b/App/src/MZArrayController.h new file mode 100644 index 00000000..a2471c1a --- /dev/null +++ b/App/src/MZArrayController.h @@ -0,0 +1,15 @@ +// +// MZArrayController.h +// MetaZ +// +// Created by Brian Olsen on 03/11/12. +// Copyright 2012 Maven-Group. All rights reserved. +// + +#import + + +@interface MZArrayController : NSArrayController { +} + +@end diff --git a/App/src/MZArrayController.m b/App/src/MZArrayController.m new file mode 100644 index 00000000..7846baf0 --- /dev/null +++ b/App/src/MZArrayController.m @@ -0,0 +1,29 @@ +// +// MZArrayController.m +// MetaZ +// +// Created by Brian Olsen on 03/11/12. +// Copyright 2012 Maven-Group. All rights reserved. +// + +#import "MZArrayController.h" + + +@implementation MZArrayController + +- (void)reallyRearrangeObjects +{ + [super rearrangeObjects]; +} + +/** + * This is delayed because otherwise when using the automaticallyRearrangesObjects + * option and inline table view editing the table view will lose firstResponder + * status when rearrangeObjects gets called. + */ +- (void)rearrangeObjects +{ + [self performSelector:@selector(reallyRearrangeObjects) withObject:nil afterDelay:0]; +} + +@end diff --git a/MetaZ.xcodeproj/project.pbxproj b/MetaZ.xcodeproj/project.pbxproj index a915b597..f9e39a70 100644 --- a/MetaZ.xcodeproj/project.pbxproj +++ b/MetaZ.xcodeproj/project.pbxproj @@ -136,6 +136,7 @@ 1B523C5113FDCD1A00C20B7D /* ASIHTTPRequestDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B523B5713F4B2B500C20B7D /* ASIHTTPRequestDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1B523C5213FDCD1A00C20B7D /* ASIProgressDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B523B5C13F4B2B500C20B7D /* ASIProgressDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1B5AC76F10532E5200F9CE36 /* MetaEditPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B5AC76E10532E5200F9CE36 /* MetaEditPanel.m */; }; + 1B63A1D31644D8D100461FC9 /* MZArrayController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B63A1D21644D8D100461FC9 /* MZArrayController.m */; }; 1B6E43C810845F8200DFE165 /* TCSearch.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B6E43C710845F8200DFE165 /* TCSearch.m */; }; 1B6E43CB108468B100DFE165 /* MZSearchResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B6E43C9108468B100DFE165 /* MZSearchResult.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1B6E43CC108468B100DFE165 /* MZSearchResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B6E43CA108468B100DFE165 /* MZSearchResult.m */; }; @@ -939,6 +940,8 @@ 1B523B9613F4B3D900C20B7D /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; 1B5AC76D10532E5200F9CE36 /* MetaEditPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetaEditPanel.h; sourceTree = ""; }; 1B5AC76E10532E5200F9CE36 /* MetaEditPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MetaEditPanel.m; sourceTree = ""; }; + 1B63A1D11644D8D100461FC9 /* MZArrayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZArrayController.h; sourceTree = ""; }; + 1B63A1D21644D8D100461FC9 /* MZArrayController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MZArrayController.m; sourceTree = ""; }; 1B6E43C610845F8200DFE165 /* TCSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TCSearch.h; sourceTree = ""; }; 1B6E43C710845F8200DFE165 /* TCSearch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TCSearch.m; sourceTree = ""; }; 1B6E43C9108468B100DFE165 /* MZSearchResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZSearchResult.h; sourceTree = ""; }; @@ -2000,6 +2003,8 @@ 1B040CD6108146140027FA0D /* ChapterItemWrapper.m */, 1BD3D30F108DD03E00BE6943 /* PictureEditor.h */, 1BD3D310108DD03E00BE6943 /* PictureEditor.m */, + 1B63A1D11644D8D100461FC9 /* MZArrayController.h */, + 1B63A1D21644D8D100461FC9 /* MZArrayController.m */, ); name = Controller; sourceTree = ""; @@ -2931,6 +2936,7 @@ 1B8905B1163F87BB008C5C8B /* MZScriptingAdditions.m in Sources */, 1B89073116420437008C5C8B /* MZScriptingEnums.m in Sources */, 1B8908E416424790008C5C8B /* MZSelectedMetaDataDocument.m in Sources */, + 1B63A1D31644D8D100461FC9 /* MZArrayController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 049821ab2dac651421b240c21316ab48d7745542 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Sat, 3 Nov 2012 17:55:37 +0100 Subject: [PATCH 03/36] Generalized SearchTableView menuForEvent, moved it to UndoTableView and deleted SearchTableView --- App/English.lproj/MainMenu.xib | 39 +++----------------- App/src/SearchTableView.h | 19 ---------- App/src/SearchTableView.m | 65 --------------------------------- App/src/UndoTableView.h | 3 ++ App/src/UndoTableView.m | 44 +++++++++++++++++++++- MetaZ.xcodeproj/project.pbxproj | 6 --- 6 files changed, 52 insertions(+), 124 deletions(-) delete mode 100644 App/src/SearchTableView.h delete mode 100644 App/src/SearchTableView.m diff --git a/App/English.lproj/MainMenu.xib b/App/English.lproj/MainMenu.xib index bbc58d03..8e0d612a 100644 --- a/App/English.lproj/MainMenu.xib +++ b/App/English.lproj/MainMenu.xib @@ -12,11 +12,11 @@ YES - - + - + + YES @@ -8509,14 +8509,6 @@ 1729 - - - searchController - - - - 1730 - retryButton @@ -13837,7 +13829,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - SearchTableView + UndoTableView com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -14866,7 +14858,7 @@ NSObject - + IBProjectSource App/src/UndoTableView.h @@ -15364,29 +15356,10 @@ App/src/ResizeController.h - - SearchTableView - UndoTableView - - searchController - NSArrayController - - - searchController - - searchController - NSArrayController - - - - IBProjectSource - App/src/SearchTableView.h - - UndoTableView NSTableView - + diff --git a/App/src/SearchTableView.h b/App/src/SearchTableView.h deleted file mode 100644 index 20a52b36..00000000 --- a/App/src/SearchTableView.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// SearchTableView.h -// MetaZ -// -// Created by Brian Olsen on 17/10/09. -// Copyright 2009 Maven-Group. All rights reserved. -// - -#import -#import "UndoTableView.h" - -@interface SearchTableView : UndoTableView -{ - NSArrayController* searchController; - -} -@property (nonatomic, retain) IBOutlet NSArrayController* searchController; - -@end diff --git a/App/src/SearchTableView.m b/App/src/SearchTableView.m deleted file mode 100644 index ddf7b233..00000000 --- a/App/src/SearchTableView.m +++ /dev/null @@ -1,65 +0,0 @@ -// -// SearchTableView.m -// MetaZ -// -// Created by Brian Olsen on 17/10/09. -// Copyright 2009 Maven-Group. All rights reserved. -// - -#import "SearchTableView.h" - - -@implementation SearchTableView -@synthesize searchController; - -- (NSMenu *)menuForEvent:(NSEvent *)event -{ - NSPoint event_location = [event locationInWindow]; - NSPoint local_point = [self convertPointFromBase:event_location]; - NSInteger row = [self rowAtPoint:local_point]; - [self selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO]; - MZSearchResult* object = [[searchController arrangedObjects] objectAtIndex:row]; - if([object menu] && [self menu]) - { - NSMenu* cp = [[[self menu] copy] autorelease]; - for(NSMenuItem* item in [cp itemArray]) - [item setRepresentedObject:self]; - //[cp addItem:[NSMenuItem separatorItem]]; - for(NSMenuItem* item in [[object menu] itemArray]) - [cp addItem:[[item copy] autorelease]]; - return cp; - } - if([object menu]) - return [object menu]; - return [self menu]; -} - -- (void)keyDown:(NSEvent *)theEvent -{ - /* - NSString* ns = [theEvent charactersIgnoringModifiers]; - NSUInteger flags = [theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask; - if([ns isEqual:@"A"] && flags == (NSShiftKeyMask | NSCommandKeyMask) ) - { - [self sendAction:[self doubleAction] to:[self target]]; - return; - } - */ - /* - if([ns length] == 1) - { - unichar ch = [ns characterAtIndex:0]; - - switch(ch) { - case NSNewlineCharacter: - case NSCarriageReturnCharacter: - case NSEnterCharacter: - [self sendAction:[self doubleAction] to:[self target]]; - break; - } - } - */ - [super keyDown:theEvent]; -} - -@end diff --git a/App/src/UndoTableView.h b/App/src/UndoTableView.h index 5565e1b4..e595b74b 100644 --- a/App/src/UndoTableView.h +++ b/App/src/UndoTableView.h @@ -8,6 +8,9 @@ #import +@interface NSObject (MenuForRow) +- (NSMenu *)tableView:(NSTableView *)aTableView menuForRow:(NSInteger)aRow; +@end @interface UndoTableView : NSTableView { diff --git a/App/src/UndoTableView.m b/App/src/UndoTableView.m index 35c4bed6..000ce988 100644 --- a/App/src/UndoTableView.m +++ b/App/src/UndoTableView.m @@ -8,7 +8,6 @@ #import "UndoTableView.h" - @implementation UndoTableView - (void)dealloc @@ -17,6 +16,49 @@ - (void)dealloc [super dealloc]; } +- (NSMenu *)menuForEvent:(NSEvent *)event +{ + NSPoint event_location = [event locationInWindow]; + NSPoint local_point = [self convertPointFromBase:event_location]; + NSInteger row = [self rowAtPoint:local_point]; + [self selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO]; + + NSMenu* menu = nil; + + id ds = [self dataSource]; + if(ds) + { + if([ds respondsToSelector:@selector(tableView:menuForRow:)]) + menu = [ds tableView:self menuForRow:row]; + } + if(!menu) + { + NSDictionary* dict = [self infoForBinding:@"content"]; + if(dict) + { + id observed = [dict objectForKey:NSObservedObjectKey]; + NSString* keyPath = [dict objectForKey:NSObservedKeyPathKey]; + NSArray* content = [observed valueForKeyPath:keyPath]; + id object = [content objectAtIndex:row]; + if(object && [object respondsToSelector:@selector(menu)]) + menu = [object menu]; + } + } + + if(menu && [self menu]) + { + NSMenu* cp = [[[self menu] copy] autorelease]; + for(NSMenuItem* item in [cp itemArray]) + [item setRepresentedObject:self]; + for(NSMenuItem* item in [menu itemArray]) + [cp addItem:[[item copy] autorelease]]; + return cp; + } + if(menu) + return menu; + return [self menu]; +} + -(IBAction)beginEnterEdit:(id)sender { NSInteger row = [self selectedRow]; diff --git a/MetaZ.xcodeproj/project.pbxproj b/MetaZ.xcodeproj/project.pbxproj index f9e39a70..31845577 100644 --- a/MetaZ.xcodeproj/project.pbxproj +++ b/MetaZ.xcodeproj/project.pbxproj @@ -166,7 +166,6 @@ 1B92BC58108890090057EFD7 /* NSObject+ProtectedKeyValue.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B92BC56108890090057EFD7 /* NSObject+ProtectedKeyValue.m */; }; 1B92BFBB1089F9060057EFD7 /* SearchMeta.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B92BFBA1089F9060057EFD7 /* SearchMeta.m */; }; 1B92C0A3108A23BA0057EFD7 /* NSUserDefaults+KeyPath.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B92C0A2108A23BA0057EFD7 /* NSUserDefaults+KeyPath.m */; }; - 1B92C0EB108A31680057EFD7 /* SearchTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B92C0EA108A31680057EFD7 /* SearchTableView.m */; }; 1B99355010AC818300E78D2D /* NSXMLNode+MZExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1B99354E10AC818300E78D2D /* NSXMLNode+MZExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1B99355110AC818300E78D2D /* NSXMLNode+MZExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B99354F10AC818300E78D2D /* NSXMLNode+MZExtensions.m */; }; 1B9B393F106C0FA200928C83 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1B9B393D106C0FA200928C83 /* Localizable.strings */; }; @@ -986,8 +985,6 @@ 1B92BFBA1089F9060057EFD7 /* SearchMeta.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchMeta.m; sourceTree = ""; }; 1B92C0A1108A23BA0057EFD7 /* NSUserDefaults+KeyPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSUserDefaults+KeyPath.h"; sourceTree = ""; }; 1B92C0A2108A23BA0057EFD7 /* NSUserDefaults+KeyPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSUserDefaults+KeyPath.m"; sourceTree = ""; }; - 1B92C0E9108A31680057EFD7 /* SearchTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchTableView.h; sourceTree = ""; }; - 1B92C0EA108A31680057EFD7 /* SearchTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchTableView.m; sourceTree = ""; }; 1B99354E10AC818300E78D2D /* NSXMLNode+MZExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSXMLNode+MZExtensions.h"; sourceTree = ""; }; 1B99354F10AC818300E78D2D /* NSXMLNode+MZExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSXMLNode+MZExtensions.m"; sourceTree = ""; }; 1B9B393E106C0FA200928C83 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = App/English.lproj/Localizable.strings; sourceTree = ""; }; @@ -1960,8 +1957,6 @@ 1B040DC2108176A70027FA0D /* UndoTableView.h */, 1B040DC3108176A70027FA0D /* UndoTableView.m */, 1BEA6D4F106E8B7C004B1A7F /* IKImageView-Missing.h */, - 1B92C0E9108A31680057EFD7 /* SearchTableView.h */, - 1B92C0EA108A31680057EFD7 /* SearchTableView.m */, 1B0331A410B13DC800B28E3A /* ToolTipLabel.h */, 1B0331A510B13DC800B28E3A /* ToolTipLabel.m */, 1B0331A710B13F8000B28E3A /* ToolTipButton.h */, @@ -2914,7 +2909,6 @@ 1B92BC04108880D60057EFD7 /* Resources.m in Sources */, 1B92BFBB1089F9060057EFD7 /* SearchMeta.m in Sources */, 1B92C0A3108A23BA0057EFD7 /* NSUserDefaults+KeyPath.m in Sources */, - 1B92C0EB108A31680057EFD7 /* SearchTableView.m in Sources */, 1BD3D311108DD03E00BE6943 /* PictureEditor.m in Sources */, 1BDD86A71094A8CC00E3C81D /* MZPresets.m in Sources */, 1BDD87A11095FB5100E3C81D /* PresetsWindowController.m in Sources */, From 40568551d550050c0f21ee8e6da3e4d39c509f14 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Sat, 3 Nov 2012 17:57:44 +0100 Subject: [PATCH 04/36] Fixed spelling error in MZPresets --- App/src/MZPresets.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/App/src/MZPresets.m b/App/src/MZPresets.m index 4c9fde3a..aa91f946 100644 --- a/App/src/MZPresets.m +++ b/App/src/MZPresets.m @@ -547,7 +547,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)note "This is most likely due to a bad MetaX import done " "by a previous version of MetaZ.\nWe were unable to " "find the preset with the same name in your current " - "MetaX presets so you need to specify the video type bellow.", + "MetaX presets so you need to specify the video type below.", @"Found bad MetaX preset message"), preset.name]]; From 6cb0262bebbc75fd768c14bedb5590ac0343e59f Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Sat, 3 Nov 2012 18:04:16 +0100 Subject: [PATCH 05/36] Removed commented out code --- App/src/UndoTableView.m | 4 - Plugins/AtomicParsley/src/APDataProvider.m | 221 +------------------ Plugins/AtomicParsley/src/APReadDataTask.h | 22 -- Plugins/AtomicParsley/src/APReadDataTask.m | 68 ------ Plugins/AtomicParsley/src/APWriteManager.h | 45 ---- Plugins/AtomicParsley/src/APWriteManager.m | 238 --------------------- 6 files changed, 1 insertion(+), 597 deletions(-) diff --git a/App/src/UndoTableView.m b/App/src/UndoTableView.m index 000ce988..58ba80d9 100644 --- a/App/src/UndoTableView.m +++ b/App/src/UndoTableView.m @@ -81,14 +81,10 @@ - (void)keyDown:(NSEvent *)theEvent if([ns length] == 1) { unichar ch = [ns characterAtIndex:0]; - //MZLoggerDebug(@"keyDown %x %x", ch, NSNewlineCharacter); switch(ch) { case NSNewlineCharacter: - //MZLoggerDebug(@"Caught NL"); case NSCarriageReturnCharacter: - //MZLoggerDebug(@"Caught CR"); case NSEnterCharacter: - //MZLoggerDebug(@"Caught Enter"); if([self numberOfSelectedRows] == 1) { [self beginEnterEdit:self]; return; diff --git a/Plugins/AtomicParsley/src/APDataProvider.m b/Plugins/AtomicParsley/src/APDataProvider.m index 2408e42c..be3843da 100644 --- a/Plugins/AtomicParsley/src/APDataProvider.m +++ b/Plugins/AtomicParsley/src/APDataProvider.m @@ -452,33 +452,6 @@ -(NSArray *)providedTags return op; } -/* -- (MetaLoaded *)loadFromFile:(NSString *)fileName -{ - NSTask* task = [[NSTask alloc] init]; - [task setLaunchPath:[self launchPath]]; - [task setArguments:[NSArray arrayWithObjects:fileName, @"-t", nil]]; - NSPipe* out = [NSPipe pipe]; - [task setStandardOutput:out]; - NSPipe* err = [NSPipe pipe]; - [task setStandardError:err]; - [task launch]; - - NSData* data = [[out fileHandleForReading] readDataToEndOfFile]; - [task waitUntilExit]; - [APDataProvider logFromProgram:@"AtomicParsley" pipe:err]; - - int status = [task terminationStatus]; - [task release]; - if (status != 0) - { - MZLoggerError(@"AtomicParsley failed. %d", status); - return nil; - } - -} -*/ - - (void)parseData:(NSData *)data withFileName:(NSString *)fileName dict:(NSMutableDictionary *)tagdict { NSString* str = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; @@ -496,7 +469,6 @@ - (void)parseData:(NSData *)data withFileName:(NSString *)fileName dict:(NSMutab [dict setObject:content forKey:type]; } - //NSMutableDictionary* tagdict = [NSMutableDictionary dictionaryWithCapacity:[tags count]]; // Initialize a null value for all known keys for(MZTag* tag in tags) [tagdict setObject:[NSNull null] forKey:[tag identifier]]; @@ -507,7 +479,6 @@ - (void)parseData:(NSData *)data withFileName:(NSString *)fileName dict:(NSMutab NSString* tagId = [read_mapping objectForKey:map]; MZTag* tag = [MZTag tagForIdentifier:tagId]; NSString* value = [dict objectForKey:map]; - //MZLoggerDebug(@"%@ %@", tagId, value); if(value) [tagdict setObject:[tag convertObjectForStorage:[tag objectFromString:value]] forKey:tagId]; } @@ -532,37 +503,6 @@ - (void)parseData:(NSData *)data withFileName:(NSString *)fileName dict:(NSMutab [tagdict setObject:rate forKey:MZRatingTagIdent]; } - // Special video type handling (stik) - /* - NSString* stik = [dict objectForKey:@"stik"]; - if(stik) - { - MZVideoType stikNo = MZUnsetVideoType; - if([stik isEqualToString:@"Movie"]) - stikNo = MZMovieVideoType; - else if([stik isEqualToString:@"Normal"]) - stikNo = MZNormalVideoType; - else if([stik isEqualToString:@"Audiobook"]) - stikNo = MZAudiobookVideoType; - else if([stik isEqualToString:@"Whacked Bookmark"]) - stikNo = MZWhackedBookmarkVideoType; - else if([stik isEqualToString:@"Music Video"]) - stikNo = MZMusicVideoType; - else if([stik isEqualToString:@"Short Film"]) - stikNo = MZShortFilmVideoType; - else if([stik isEqualToString:@"TV Show"]) - stikNo = MZTVShowVideoType; - else if([stik isEqualToString:@"Booklet"]) - stikNo = MZBookletVideoType; - if(stikNo!=MZUnsetVideoType) - { - MZTag* tag = [MZTag tagForIdentifier:MZVideoTypeTagIdent]; - [tagdict setObject:[tag nullConvertValueToObject:&stikNo] - forKey:MZVideoTypeTagIdent]; - } - } - */ - // Special handling for cast, directors, producers and screenwriters NSString* iTunMOVIStr = [dict objectForKey:@"com.apple.iTunes;iTunMOVI"]; if(iTunMOVIStr) @@ -648,102 +588,6 @@ - (void)parseData:(NSData *)data withFileName:(NSString *)fileName dict:(NSMutab NSString* covr = [dict objectForKey:@"covr"]; if(covr) [tagdict setObject:[NSNull null] forKey:MZPictureTagIdent]; - - /* - { - task = [[NSTask alloc] init]; - [task setLaunchPath:[self launchPath]]; - NSString* file = [NSString temporaryPathWithFormat:@"MetaZImage_%@"]; - [task setArguments:[NSArray arrayWithObjects:fileName, @"-e", file, nil]]; - NSPipe* err = [NSPipe pipe]; - [task setStandardError:err]; - [task setStandardOutput:err]; - [task launch]; - [task waitUntilExit]; - [APDataProvider logFromProgram:@"AtomicParsley" pipe:err]; - [task release]; - - file = [file stringByAppendingString:@"_artwork_1"]; - - NSFileManager* mgr = [NSFileManager manager]; - BOOL isDir; - if([mgr fileExistsAtPath:[file stringByAppendingString:@".png"] isDirectory:&isDir] && !isDir) - { - NSData* data = [NSData dataWithContentsOfFile:[file stringByAppendingString:@".png"]]; - [tagdict setObject:data forKey:MZPictureTagIdent]; - [mgr removeItemAtPath:[file stringByAppendingString:@".png"] error:NULL]; - } - else if([mgr fileExistsAtPath:[file stringByAppendingString:@".jpg"] isDirectory:&isDir] && !isDir) - { - NSData* data = [NSData dataWithContentsOfFile:[file stringByAppendingString:@".jpg"]]; - [tagdict setObject:data forKey:MZPictureTagIdent]; - [mgr removeItemAtPath:[file stringByAppendingString:@".jpg"] error:NULL]; - } - } - - - // Chapter reading - { - task = [[NSTask alloc] init]; - [task setLaunchPath:[self launchChapsPath]]; - [task setArguments:[NSArray arrayWithObjects:@"-l", fileName, nil]]; - NSPipe* out = [NSPipe pipe]; - [task setStandardOutput:out]; - NSPipe* err = [NSPipe pipe]; - [task setStandardError:err]; - [task launch]; - - NSData* data = [[out fileHandleForReading] readDataToEndOfFile]; - [task waitUntilExit]; - [APDataProvider logFromProgram:@"mp4chaps" pipe:err]; - int chapStatus = [task terminationStatus]; - [task release]; - - if(chapStatus != 0) - { - MZLoggerError(@"mp4chaps failed. %d", chapStatus); - return nil; - } - - NSString* str = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; - - NSRange f = [str rangeOfString:@"Duration "]; - NSString* movieDurationStr = [str substringWithRange:NSMakeRange(f.location+f.length, 12)]; - //MZLoggerDebug(@"Movie duration '%@'", movieDurationStr); - MZTimeCode* movieDuration = [MZTimeCode timeCodeWithString:movieDurationStr]; - [tagdict setObject:movieDuration forKey:MZDurationTagIdent]; - - NSArray* lines = [str componentsSeparatedByString:@"\tChapter #"]; - if([lines count]>1) - { - NSMutableArray* chapters = [NSMutableArray array]; - int len = [lines count]; - for(int i=1; i delegate; - id provider; - NSString* fileName; - NSMutableDictionary* tagdict; -} -@property(readonly) NSMutableDictionary* tagdict; - -+ (id)controllerWithProvider:(id)provider - fromFileName:(NSString *)fileName - delegate:(id)delegate; - -- (id)initWithProvider:(id)provider - fromFileName:(NSString *)fileName - delegate:(id)delegate; - -- (void)operationsFinished; - -@end -*/ diff --git a/Plugins/AtomicParsley/src/APReadDataTask.m b/Plugins/AtomicParsley/src/APReadDataTask.m index 71e42b5e..b19def34 100644 --- a/Plugins/AtomicParsley/src/APReadDataTask.m +++ b/Plugins/AtomicParsley/src/APReadDataTask.m @@ -141,20 +141,6 @@ - (void)dealloc [tagdict release]; [super dealloc]; } -/* -- (id)retain -{ - NSLog(@"APReadChapter retain %d", [self retainCount]); - return [super retain]; -} - -- (oneway void)release -{ - NSUInteger count = [self retainCount]-1; - [super release]; - NSLog(@"APReadChapter release %d", count); -} -*/ - (void)parseData { @@ -165,7 +151,6 @@ - (void)parseData NSRange f = [str rangeOfString:@"Duration "]; NSString* movieDurationStr = [str substringWithRange:NSMakeRange(f.location+f.length, 12)]; - //MZLoggerDebug(@"Movie duration '%@'", movieDurationStr); MZTimeCode* movieDuration = [MZTimeCode timeCodeWithString:movieDurationStr]; [tagdict setObject:movieDuration forKey:MZDurationTagIdent]; @@ -182,7 +167,6 @@ - (void)parseData NSString* startStr = [line substringWithRange:NSMakeRange(6, 12)]; NSString* durationStr = [line substringWithRange:NSMakeRange(21, 12)]; NSString* name = [line substringWithRange:NSMakeRange(37, [line length]-38)]; - //MZLoggerDebug(@"Found args: '%@' '%@' '%@'", start, duration, name); MZTimeCode* start = [MZTimeCode timeCodeWithString:startStr]; MZTimeCode* duration = [MZTimeCode timeCodeWithString:durationStr]; @@ -199,55 +183,3 @@ - (void)parseData } @end - - -/* -@implementation APReadOperationsController - -+ (id)controllerWithProvider:(id)provider - fromFileName:(NSString *)fileName - delegate:(id)delegate -{ - return [[[[self class] alloc] initWithProvider:provider fromFileName:fileName delegate:delegate] autorelease]; -} - -- (id)initWithProvider:(id)theProvider - fromFileName:(NSString *)theFileName - delegate:(id)theDelegate -{ - self = [super init]; - if(self) - { - provider = [theProvider retain]; - fileName = [theFileName retain]; - delegate = [theDelegate retain]; - tagdict = [[NSMutableDictionary alloc] init]; - } - return self; -} - -- (void)dealloc -{ - [provider release]; - [fileName release]; - [delegate release]; - [tagdict release]; - [super dealloc]; -} - -@synthesize tagdict; - -- (void)operationsFinished -{ - MetaLoaded* loaded = nil; - if(!self.error) - loaded = [MetaLoaded metaWithOwner:provider filename:fileName dictionary:tagdict]; - [delegate dataProvider:provider - controller:self - loadedMeta:loaded - fromFile:fileName - error:self.error]; -} - -@end -*/ diff --git a/Plugins/AtomicParsley/src/APWriteManager.h b/Plugins/AtomicParsley/src/APWriteManager.h index 2f108843..dbce4e2c 100644 --- a/Plugins/AtomicParsley/src/APWriteManager.h +++ b/Plugins/AtomicParsley/src/APWriteManager.h @@ -51,48 +51,3 @@ pictureFile:(NSString *)file; @end - -/* -@interface APWriteManager : NSOperation -{ - NSTask* task; - BOOL finished; - NSString* pictureFile; - NSString* chaptersFile; - MetaEdits* edits; - id delegate; - APDataProvider* provider; - NSPipe* err; -} -@property(readonly) NSTask* task; -@property(readonly) id delegate; -@property(readonly) MetaEdits* edits; -@property(readonly) APDataProvider* provider; -@property(getter=isFinished,assign) BOOL finished; - -+ (id)managerForProvider:(APDataProvider*)provider - task:(NSTask *)task - delegate:(id)delegate - edits:(MetaEdits *)edits - pictureFile:(NSString *)file - chaptersFile:(NSString *)chapterFile; -- (id)initForProvider:(APDataProvider*)provider - task:(NSTask *)task - delegate:(id)delegate - edits:(MetaEdits *)edits - pictureFile:(NSString *)file - chaptersFile:(NSString *)chapterFile; - -- (void)start; - -- (BOOL)isConcurrent; -- (BOOL)isExecuting; -//- (BOOL)isFinished; - -- (void)cancel; - -- (void)taskTerminated:(NSNotification *)note; -- (void)handlerGotData:(NSNotification *)note; - -@end -*/ \ No newline at end of file diff --git a/Plugins/AtomicParsley/src/APWriteManager.m b/Plugins/AtomicParsley/src/APWriteManager.m index 7678ba94..2dd4f845 100644 --- a/Plugins/AtomicParsley/src/APWriteManager.m +++ b/Plugins/AtomicParsley/src/APWriteManager.m @@ -166,241 +166,3 @@ - (void)standardOutputGotData:(NSNotification *)note } @end - -/* -@implementation APWriteManager - -+ (NSSet *)keyPathsForValuesAffectingIsFinished -{ - return [NSSet setWithObjects:@"finished", nil]; -} - -+ (id)managerForProvider:(id)provider - task:(NSTask *)task - delegate:(id)delegate - edits:(MetaEdits *)edits - pictureFile:(NSString *)file - chaptersFile:(NSString *)chapterFile -{ - return [[[self alloc] initForProvider:provider - task:task - delegate:delegate - edits:edits - pictureFile:file - chaptersFile:chapterFile] autorelease]; -} - -- (id)initForProvider:(id)theProvider - task:(NSTask *)theTask - delegate:(id)theDelegate - edits:(MetaEdits *)theEdits - pictureFile:(NSString *)file - chaptersFile:(NSString *)theChapterFile -{ - self = [super init]; - if(self) - { - provider = [theProvider retain]; - task = [theTask retain]; - delegate = [theDelegate retain]; - edits = [theEdits retain]; - pictureFile = [file retain]; - chaptersFile = [theChapterFile retain]; - NSPipe* out = [NSPipe pipe]; - [task setStandardOutput:out]; - } - return self; -} - -- (void)dealloc -{ - if([task isRunning]) - [task terminate]; - [provider release]; - [task release]; - [delegate release]; - [edits release]; - [pictureFile release]; - [err release]; - [super dealloc]; -} - -@synthesize provider; -@synthesize task; -@synthesize delegate; -@synthesize edits; -@synthesize finished; - -- (BOOL)isConcurrent -{ - return YES; -} - -- (BOOL)isExecuting -{ - return [task isRunning]; -} - -- (void)start -{ - if([self isCancelled]) - return; - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(handlerGotData:) - name:NSFileHandleReadCompletionNotification - object:[[task standardOutput] fileHandleForReading]]; - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(taskTerminated:) - name:NSTaskDidTerminateNotification - object:task]; - MZLoggerDebug(@"Starting write %@", [[task arguments] componentsJoinedByString:@" "]); - err = [[NSPipe alloc] init]; - [task setStandardError:err]; - [[[task standardOutput] fileHandleForReading] readInBackgroundAndNotify]; - [task launch]; - if([delegate respondsToSelector:@selector(dataProvider:controller:writeStartedForEdits:)]) - [delegate dataProvider:provider controller:self writeStartedForEdits:edits]; -} - -- (BOOL)isConcurrent -{ - return YES; -} - -- (BOOL)isExecuting -{ - return [task isRunning]; -} - -- (void)cancel -{ - [super cancel]; - if([task isRunning]) - [task terminate]; -} - -- (void)taskTerminated:(NSNotification *)note -{ - [APDataProvider logFromProgram:@"AtomicParsley" pipe:err]; - NSError* error = nil; - NSError* tempError = nil; - - int status = [task terminationStatus]; - if(status != 0) - { - MZLoggerError(@"Terminated bad %d", status); - NSDictionary* dict = [NSDictionary dictionaryWithObject: - [NSString stringWithFormat: - NSLocalizedString(@"AtomicParsley failed with exit code %d", @"Write failed error"), - status] - forKey:NSLocalizedDescriptionKey]; - error = [NSError errorWithDomain:@"AtomicParsleyPlugin" code:status userInfo:dict]; - } - - NSFileManager* mgr = [NSFileManager manager]; - if(pictureFile) - { - if(![mgr removeItemAtPath:pictureFile error:&tempError]) - { - MZLoggerError(@"Failed to remove temp picture file %@", [tempError localizedDescription]); - tempError = nil; - } - } - if([self isCancelled] || error) - { - if(chaptersFile && [chaptersFile length]>0) - { - if(![mgr removeItemAtPath:chaptersFile error:&tempError]) - { - MZLoggerError(@"Failed to remove temp chapters file %@", [tempError localizedDescription]); - tempError = nil; - } - } - if([delegate respondsToSelector:@selector(dataProvider:controller:writeCanceledForEdits:error:)]) - [delegate dataProvider:provider controller:self writeCanceledForEdits:edits error:error]; - } - else - { - NSString* fileName; - BOOL isDir = NO; - if([mgr fileExistsAtPath:[edits savedTempFileName] isDirectory:&isDir] && !isDir) - fileName = [edits savedTempFileName]; - else - fileName = [edits loadedFileName]; - - // Sometimes when writing to a network drive the file is left in a state - // (I think it is a cache flush issue) so that a subsequent chapter write - // breaks the file. I hope (have not encountered the issue in a long time) - // that this extra chapter read at least detects the issue. - status = [APDataProvider testReadFile:fileName]; - - if(chaptersFile && status == 0) - { - if([chaptersFile isEqualToString:@""]) - status = [APDataProvider removeChaptersFromFile:fileName]; - else - { - status = [APDataProvider importChaptersFromFile:chaptersFile toFile:fileName]; - if(![mgr removeItemAtPath:chaptersFile error:&tempError]) - { - MZLoggerError(@"Failed to remove temp chapters file %@", [tempError localizedDescription]); - tempError = nil; - } - } - } - if(status != 0) - { - NSDictionary* dict = [NSDictionary dictionaryWithObject: - [NSString stringWithFormat: - NSLocalizedString(@"mp4chaps failed with exit code %d", @"Write failed error"), - status] - forKey:NSLocalizedDescriptionKey]; - error = [NSError errorWithDomain:@"AtomicParsleyPlugin" code:status userInfo:dict]; - } - - if(error) - { - if([delegate respondsToSelector:@selector(dataProvider:controller:writeCanceledForEdits:error:)]) - [delegate dataProvider:provider controller:self writeCanceledForEdits:edits error:error]; - } - else - { - self.finished = YES; - if([delegate respondsToSelector:@selector(dataProvider:controller:writeFinishedForEdits:)]) - [delegate dataProvider:provider controller:self writeFinishedForEdits:edits]; - } - } - self.finished = YES; - [provider removeWriteManager:self]; -} - -- (void)handlerGotData:(NSNotification *)note -{ - if(self.finished) - return; - NSData* data = [[note userInfo] - objectForKey:NSFileHandleNotificationDataItem]; - NSString* str = [[[NSString alloc] - initWithData:data - encoding:NSUTF8StringEncoding] autorelease]; - NSString* origStr = str; - str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - if([str hasPrefix:@"Started writing to temp file."]) - str = [str substringFromIndex:29]; - str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - NSInteger percent = [str integerValue]; - MZLoggerDebug(@"Got data: %d '%@'", percent, origStr); - if(percent > 0 && [delegate respondsToSelector:@selector(dataProvider:controller:writeFinishedForEdits:percent:)]) - [delegate dataProvider:provider controller:self writeFinishedForEdits:edits percent:percent]; - - if([task isRunning]) - { - [[[task standardOutput] fileHandleForReading] - readInBackgroundAndNotify]; - } -} - -@end -*/ \ No newline at end of file From e00b9852701bb6c602e277c86e96d04468676325 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Sat, 3 Nov 2012 20:37:01 +0100 Subject: [PATCH 06/36] Switched usages of getBytes: in MZScriptingAdditions to getBytes:length: since that is not deprecated and safer --- App/src/MZScriptingAdditions.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/App/src/MZScriptingAdditions.m b/App/src/MZScriptingAdditions.m index 6dbbc18f..a4c33f77 100644 --- a/App/src/MZScriptingAdditions.m +++ b/App/src/MZScriptingAdditions.m @@ -419,7 +419,7 @@ - (SInt16)int16Value; { NSAppleEventDescriptor* coerced = [self coerceToDescriptorType:typeSInt16]; SInt16 val; - [[coerced data] getBytes:&val]; + [[coerced data] getBytes:&val length:sizeof(val)]; return val; } @@ -432,7 +432,7 @@ - (SInt64)int64Value; { NSAppleEventDescriptor* coerced = [self coerceToDescriptorType:typeSInt64]; SInt64 val; - [[coerced data] getBytes:&val]; + [[coerced data] getBytes:&val length:sizeof(val)]; return val; } @@ -445,7 +445,7 @@ - (UInt16)unsignedInt16Value; { NSAppleEventDescriptor* coerced = [self coerceToDescriptorType:typeUInt16]; UInt16 val; - [[coerced data] getBytes:&val]; + [[coerced data] getBytes:&val length:sizeof(val)]; return val; } @@ -458,7 +458,7 @@ - (UInt32)unsignedInt32Value; { NSAppleEventDescriptor* coerced = [self coerceToDescriptorType:typeUInt32]; UInt32 val; - [[coerced data] getBytes:&val]; + [[coerced data] getBytes:&val length:sizeof(val)]; return val; } @@ -471,7 +471,7 @@ - (UInt64)unsignedInt64Value; { NSAppleEventDescriptor* coerced = [self coerceToDescriptorType:typeUInt64]; UInt64 val; - [[coerced data] getBytes:&val]; + [[coerced data] getBytes:&val length:sizeof(val)]; return val; } @@ -484,7 +484,7 @@ - (Float32)float32Value; { NSAppleEventDescriptor* coerced = [self coerceToDescriptorType:typeIEEE32BitFloatingPoint]; Float32 val; - [[coerced data] getBytes:&val]; + [[coerced data] getBytes:&val length:sizeof(val)]; return val; } @@ -497,7 +497,7 @@ - (Float64)float64Value; { NSAppleEventDescriptor* coerced = [self coerceToDescriptorType:typeIEEE64BitFloatingPoint]; Float64 val; - [[coerced data] getBytes:&val]; + [[coerced data] getBytes:&val length:sizeof(val)]; return val; } @@ -510,7 +510,7 @@ - (NSDecimal)decimalValue; { NSAppleEventDescriptor* coerced = [self coerceToDescriptorType:typeDecimalStruct]; NSDecimal val; - [[coerced data] getBytes:&val]; + [[coerced data] getBytes:&val length:sizeof(val)]; return val; } @@ -523,7 +523,7 @@ - (LongDateTime)longDateTimeValue; { NSAppleEventDescriptor* coerced = [self coerceToDescriptorType:typeLongDateTime]; LongDateTime longDateTime; - [[coerced data] getBytes:&longDateTime]; + [[coerced data] getBytes:&longDateTime length:sizeof(longDateTime)]; return longDateTime; } From e344e1c1d6ce682790b4d9b79b8a1cce3cc77a99 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Sat, 3 Nov 2012 20:42:56 +0100 Subject: [PATCH 07/36] Added NSDecimal support to NSValue --- App/src/MZScriptingAdditions.h | 3 +++ App/src/MZScriptingAdditions.m | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/App/src/MZScriptingAdditions.h b/App/src/MZScriptingAdditions.h index 7ba4e310..84ec6c2d 100644 --- a/App/src/MZScriptingAdditions.h +++ b/App/src/MZScriptingAdditions.h @@ -11,6 +11,9 @@ @interface NSValue (MZScriptingAdditions) + (id)valueWithFourCharCode:(FourCharCode)code; - (FourCharCode)fourCharCode; + ++ (id)valueWithDecimal:(NSDecimal)decimal; +- (NSDecimal)decimalValue; @end @interface NSNumber (MZScriptingAdditions) diff --git a/App/src/MZScriptingAdditions.m b/App/src/MZScriptingAdditions.m index a4c33f77..ab936b30 100644 --- a/App/src/MZScriptingAdditions.m +++ b/App/src/MZScriptingAdditions.m @@ -25,6 +25,19 @@ - (FourCharCode)fourCharCode; return ret; } + ++ (id)valueWithDecimal:(NSDecimal)decimal; +{ + return [NSValue valueWithBytes:&decimal objCType:@encode(NSDecimal)]; +} + +- (NSDecimal)decimalValue; +{ + NSDecimal ret; + [self getValue:&ret]; + return ret; +} + @end From 5938265a43ecab90c058958d08ea3b06b55deafd Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Sat, 3 Nov 2012 20:44:36 +0100 Subject: [PATCH 08/36] Made NSDecimal support in scripting objectValue use decimalValue which coerces --- App/src/MZScriptingAdditions.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/App/src/MZScriptingAdditions.m b/App/src/MZScriptingAdditions.m index ab936b30..6b660172 100644 --- a/App/src/MZScriptingAdditions.m +++ b/App/src/MZScriptingAdditions.m @@ -564,9 +564,7 @@ - (id)objectValue; return [NSNumber scriptingNumberWithDescriptor:self]; case typeDecimalStruct: { - NSDecimal val; - [[self data] getBytes:&val]; - return [NSValue valueWithBytes:&val objCType:@encode(NSDecimal)]; + return [NSValue valueWithDecimal:[self decimalValue]]; } case typeEnumerated: { From 6e0b3e80c42fddbf8b746c872b552c9d90fc18a2 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Sat, 3 Nov 2012 20:45:34 +0100 Subject: [PATCH 09/36] Added support for alias to scripting objectValue --- App/src/MZScriptingAdditions.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/App/src/MZScriptingAdditions.m b/App/src/MZScriptingAdditions.m index 6b660172..bb0347ae 100644 --- a/App/src/MZScriptingAdditions.m +++ b/App/src/MZScriptingAdditions.m @@ -587,7 +587,18 @@ - (id)objectValue; return [NSArray scriptingListWithDescriptor:self]; case typeAERecord: return [NSDictionary scriptingRecordWithDescriptor:self]; - + case typeAlias: + { + const AEDesc* desc = [self aeDesc]; + HFSUniStr255 t,v; + CFStringRef path; + AliasHandle handle = (AliasHandle)desc->dataHandle; + OSStatus cpyErr = FSCopyAliasInfo(handle, &t, &v, &path, NULL, NULL); + if(cpyErr == 0) + return [NSString stringWithString:(NSString *)path]; + NSLog(@"FSCopyAliasInfo error %d", cpyErr); + return [NSNull null]; + } case typeObjectSpecifier: return [NSScriptObjectSpecifier objectSpecifierWithDescriptor:self]; From 9ce39196674f72c2ccf2cb2beaa48a947f94cf2a Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Mon, 5 Nov 2012 23:49:44 +0100 Subject: [PATCH 10/36] Added iTunesPersistentID tag --- Framework/src/MZConstants.h | 1 + Framework/src/MZConstants.m | 1 + Framework/src/MZTag.m | 1 + 3 files changed, 3 insertions(+) diff --git a/Framework/src/MZConstants.h b/Framework/src/MZConstants.h index 2aa76174..ec35981e 100644 --- a/Framework/src/MZConstants.h +++ b/Framework/src/MZConstants.h @@ -193,6 +193,7 @@ MZKIT_EXTERN NSString* const MZIMDBTagIdent; MZKIT_EXTERN NSString* const MZASINTagIdent; MZKIT_EXTERN NSString* const MZDVDSeasonTagIdent; MZKIT_EXTERN NSString* const MZDVDEpisodeTagIdent; +MZKIT_EXTERN NSString* const MZiTunesPersistentIDTagIdent; /* Notifications */ MZKIT_EXTERN NSString* const MZDataProviderLoadedNotification; diff --git a/Framework/src/MZConstants.m b/Framework/src/MZConstants.m index b50f4bbb..ef20e85e 100644 --- a/Framework/src/MZConstants.m +++ b/Framework/src/MZConstants.m @@ -70,6 +70,7 @@ NSString* const MZASINTagIdent = @"asin"; NSString* const MZDVDSeasonTagIdent = @"dvdSeason"; NSString* const MZDVDEpisodeTagIdent = @"dvdEpisode"; +NSString* const MZiTunesPersistentIDTagIdent = @"iTunesPersistentID"; /* Notifications */ NSString* const MZDataProviderLoadedNotification = @"MZDataProviderLoadedNotification"; diff --git a/Framework/src/MZTag.m b/Framework/src/MZTag.m index d0fbb19d..1292618c 100644 --- a/Framework/src/MZTag.m +++ b/Framework/src/MZTag.m @@ -99,6 +99,7 @@ + (void)initialize [self registerTag:[MZStringTag tagWithIdentifier:MZASINTagIdent]]; [self registerTag:[MZIntegerTag tagWithIdentifier:MZDVDSeasonTagIdent scriptName:@"dvd season"]]; [self registerTag:[MZIntegerTag tagWithIdentifier:MZDVDEpisodeTagIdent scriptName:@"dvd episode"]]; + [self registerTag:[MZStringTag tagWithIdentifier:MZiTunesPersistentIDTagIdent scriptName:@"itunes persistent id"]]; } From f8047b95ae51c04108fe3e04592dfce374ddc3aa Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Mon, 5 Nov 2012 23:50:14 +0100 Subject: [PATCH 11/36] Made allKnownTags return all registered tags --- Framework/src/MZTag.m | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Framework/src/MZTag.m b/Framework/src/MZTag.m index 1292618c..154d8f44 100644 --- a/Framework/src/MZTag.m +++ b/Framework/src/MZTag.m @@ -140,6 +140,17 @@ + (MZTag *)tagForScriptName:(NSString *)scriptName return ret; } ++ (NSArray*)allKnownTags +{ + NSArray* ret = [NSArray array]; + @synchronized(self) + { + if(sharedTags) + ret = [NSArray arrayWithArray:[sharedTags allValues]]; + } + return ret; +} + + (NSArray*)infoTags { return [NSArray arrayWithObjects: @@ -216,15 +227,6 @@ + (NSArray *)chapterTags nil]; } -+ (NSArray*)allKnownTags -{ - return [[[[[[self infoTags] arrayByAddingObjectsFromArray:[self videoTags]] - arrayByAddingObjectsFromArray:[self sortTags]] - arrayByAddingObjectsFromArray:[self advancedTags]] - arrayByAddingObjectsFromArray:[self chapterTags]] - arrayByAddingObject:[self tagForIdentifier:MZDurationTagIdent]]; -} - + (NSString *)localizedNameForKnownIdentifier:(NSString *)identifier { return NSLocalizedStringFromTableInBundle( From 2e4075292a05f47dca56acd4e010996acee6db25 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Mon, 5 Nov 2012 23:52:40 +0100 Subject: [PATCH 12/36] Switched CFBundleVersion of plugins to BUILDVERSION --- Plugins/Amazon/Info.plist | 4 +++- Plugins/AtomicParsley/Info.plist | 4 +++- Plugins/IMDB/Info.plist | 4 +++- Plugins/TagChimp/Info.plist | 4 +++- Plugins/TheMovieDb/Info.plist | 4 +++- Plugins/TheTVDB/Info.plist | 8 +++++--- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Plugins/Amazon/Info.plist b/Plugins/Amazon/Info.plist index cb039cff..9d2acd08 100644 --- a/Plugins/Amazon/Info.plist +++ b/Plugins/Amazon/Info.plist @@ -17,10 +17,12 @@ CFBundleSignature ???? CFBundleVersion - BUILDDATE + BUILDVERSION NSPrincipalClass AmazonPlugin BuildId BUILDID + BuildDate + BUILDDATE diff --git a/Plugins/AtomicParsley/Info.plist b/Plugins/AtomicParsley/Info.plist index c84e8a7d..9bc6c2a0 100644 --- a/Plugins/AtomicParsley/Info.plist +++ b/Plugins/AtomicParsley/Info.plist @@ -17,10 +17,12 @@ CFBundleSignature ???? CFBundleVersion - BUILDDATE + BUILDVERSION NSPrincipalClass AtomicParsleyPlugin BuildId BUILDID + BuildDate + BUILDDATE diff --git a/Plugins/IMDB/Info.plist b/Plugins/IMDB/Info.plist index b32e4c2a..cc4ea9d0 100644 --- a/Plugins/IMDB/Info.plist +++ b/Plugins/IMDB/Info.plist @@ -17,10 +17,12 @@ CFBundleSignature ???? CFBundleVersion - BUILDDATE + BUILDVERSION NSPrincipalClass IMDBPlugin BuildId BUILDID + BuildDate + BUILDDATE diff --git a/Plugins/TagChimp/Info.plist b/Plugins/TagChimp/Info.plist index 33603b92..870f1db7 100644 --- a/Plugins/TagChimp/Info.plist +++ b/Plugins/TagChimp/Info.plist @@ -17,10 +17,12 @@ CFBundleSignature ???? CFBundleVersion - BUILDDATE + BUILDVERSION NSPrincipalClass TagChimpPlugin BuildId BUILDID + BuildDate + BUILDDATE diff --git a/Plugins/TheMovieDb/Info.plist b/Plugins/TheMovieDb/Info.plist index ca3954d5..78d3a054 100644 --- a/Plugins/TheMovieDb/Info.plist +++ b/Plugins/TheMovieDb/Info.plist @@ -17,10 +17,12 @@ CFBundleSignature ???? CFBundleVersion - BUILDDATE + BUILDVERSION NSPrincipalClass TheMovieDbPlugin BuildId BUILDID + BuildDate + BUILDDATE diff --git a/Plugins/TheTVDB/Info.plist b/Plugins/TheTVDB/Info.plist index 125cff99..eb29ca12 100644 --- a/Plugins/TheTVDB/Info.plist +++ b/Plugins/TheTVDB/Info.plist @@ -2,6 +2,10 @@ + BuildDate + BUILDDATE + BuildId + BUILDID CFBundleDevelopmentRegion English CFBundleExecutable @@ -17,10 +21,8 @@ CFBundleSignature ???? CFBundleVersion - BUILDDATE + BUILDVERSION NSPrincipalClass TheTVDBPlugin - BuildId - BUILDID From 3be50debcbbc8c44b56ef8e25ee8f1a5d0712150 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 00:02:51 +0100 Subject: [PATCH 13/36] Added applescript access to documents in queue --- App/resources/MetaZ.sdef | 9 ++++++++- App/src/MZMetaDataDocument.h | 4 ++++ App/src/MZMetaDataDocument.m | 17 +++++++++++++++-- App/src/MetaZApplication.h | 1 + App/src/MetaZApplication.m | 15 +++++++++++++++ 5 files changed, 43 insertions(+), 3 deletions(-) diff --git a/App/resources/MetaZ.sdef b/App/resources/MetaZ.sdef index c26d43e5..0be104b6 100644 --- a/App/resources/MetaZ.sdef +++ b/App/resources/MetaZ.sdef @@ -14,7 +14,7 @@ - + @@ -166,6 +166,9 @@ + + + @@ -362,6 +365,10 @@ + + + + \ No newline at end of file diff --git a/App/src/MZMetaDataDocument.h b/App/src/MZMetaDataDocument.h index 60299c62..b1797779 100644 --- a/App/src/MZMetaDataDocument.h +++ b/App/src/MZMetaDataDocument.h @@ -28,11 +28,15 @@ @interface MZMetaDataDocument : NSObject { MetaEdits *data; NSArray* tags; + NSString* container; + BOOL saved; } @property(readonly) MetaEdits *data; + (id)documentWithEdit:(MetaEdits *)edit; ++ (id)documentWithEdit:(MetaEdits *)edit container:(NSString *)container saved:(BOOL)saved; - (id)initWithEdit:(MetaEdits *)edit; +- (id)initWithEdit:(MetaEdits *)edit container:(NSString *)container saved:(BOOL)saved; - (NSURL *)fileURL; - (NSString *)displayName; - (MZTimeCode *)duration; diff --git a/App/src/MZMetaDataDocument.m b/App/src/MZMetaDataDocument.m index 6a8bedd9..90c84e99 100644 --- a/App/src/MZMetaDataDocument.m +++ b/App/src/MZMetaDataDocument.m @@ -116,12 +116,24 @@ + (id)documentWithEdit:(MetaEdits *)edit; return [[[self alloc] initWithEdit:edit] autorelease]; } ++ (id)documentWithEdit:(MetaEdits *)edit container:(NSString *)container saved:(BOOL)saved; +{ + return [[[self alloc] initWithEdit:edit container:container saved:saved] autorelease]; +} + - (id)initWithEdit:(MetaEdits *)edit; +{ + return [self initWithEdit:edit container:@"orderedDocuments" saved:NO]; +} + +- (id)initWithEdit:(MetaEdits *)edit container:(NSString *)aContainer saved:(BOOL)theSaved; { self = [super init]; if(self) { data = [edit retain]; + container = [aContainer retain]; + saved = theSaved; } return self; } @@ -130,6 +142,7 @@ - (void)dealloc { [data release]; [tags release]; + [container release]; [super dealloc]; } @@ -137,7 +150,7 @@ - (void)dealloc - (NSURL *)fileURL; { - return [NSURL fileURLWithPath:[data loadedFileName]]; + return [NSURL fileURLWithPath:saved ? [data savedFileName] : [data loadedFileName]]; } - (NSString *)displayName; @@ -184,7 +197,7 @@ - (NSScriptObjectSpecifier *)objectSpecifier; [NSScriptClassDescription classDescriptionForClass:[MetaZApplication class]];// 1 return [[[NSNameSpecifier alloc] initWithContainerClassDescription:containerClassDesc - containerSpecifier:nil key:@"orderedDocuments" + containerSpecifier:nil key:container name:[self displayName]] autorelease]; } /* diff --git a/App/src/MetaZApplication.h b/App/src/MetaZApplication.h index ebe2cf3c..5aa94164 100644 --- a/App/src/MetaZApplication.h +++ b/App/src/MetaZApplication.h @@ -18,5 +18,6 @@ - (id)selectedDocuments; - (id)handleOpenScriptCommand:(id)command; +- (NSArray *)queueDocuments; @end diff --git a/App/src/MetaZApplication.m b/App/src/MetaZApplication.m index 50bf0bd1..61f1baeb 100644 --- a/App/src/MetaZApplication.m +++ b/App/src/MetaZApplication.m @@ -9,6 +9,8 @@ #import "MetaZApplication.h" #import "MZSelectedMetaDataDocument.h" #import "MZMetaLoader.h" +#import "MZWriteQueue.h" +#import "MZWriteQueueStatus.h" @implementation MetaZApplication @synthesize filesController; @@ -86,4 +88,17 @@ - (NSArray *)orderedDocuments return documents; } +- (NSArray *)queueDocuments +{ + NSMutableArray* queue = [NSMutableArray array]; + for(MZWriteQueueStatus* item in [[MZWriteQueue sharedQueue] queueItems]) + { + [queue addObject:[MZMetaDataDocument + documentWithEdit:[item edits] + container:@"queueDocuments" + saved:item.completed]]; + } + return queue; +} + @end From 77fb80bcd69a945d72c4817b22ddc7142df2366b Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 00:03:32 +0100 Subject: [PATCH 14/36] Added faster access to applescript tags --- App/src/MZMetaDataDocument.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/App/src/MZMetaDataDocument.m b/App/src/MZMetaDataDocument.m index 90c84e99..29a5bdf8 100644 --- a/App/src/MZMetaDataDocument.m +++ b/App/src/MZMetaDataDocument.m @@ -182,6 +182,14 @@ - (NSArray *)tags; return tags; } +- (id)valueInTagsWithName:(NSString *)name +{ + MZTag* tag = [MZTag tagForScriptName:[name lowercaseString]]; + if(tag) + return [MZTagItem itemWithTag:tag document:self]; + return nil; +} + /* - (id)scriptingValueForSpecifier:(id)specifier { From aaa2161f0a2a878fc8729ff57de09672b9551587 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 01:51:07 +0100 Subject: [PATCH 15/36] Removed some unused code --- App/src/AppController.m | 21 ------ App/src/FileViewBox.m | 17 ----- App/src/FilesTableView.m | 31 -------- App/src/ImageWindowController.m | 12 ---- App/src/MZFileNameTextStorage.m | 2 - App/src/MZMetaDataDocument.m | 16 ----- App/src/MZMetaLoader.m | 79 --------------------- App/src/MZPresets.m | 29 -------- App/src/MZWriteQueue.m | 22 ------ App/src/MyQueueCollectionView.m | 16 ----- App/src/PictureEditor.m | 38 ---------- App/src/PosterView.m | 10 --- App/src/QueueController.m | 34 --------- App/src/ResizeController.m | 48 ------------- App/src/SearchMeta.m | 7 -- App/src/Utilities.m | 13 ---- Framework/src/MZBaseSearchProvider.m | 17 ----- Framework/src/MZOperationsController.m | 12 ---- Framework/src/MZPluginController.m | 41 ----------- Framework/src/MZPriorObserverFix.m | 13 ---- Framework/src/MZTaskOperation.m | 38 ---------- Framework/src/MetaEdits.m | 18 ----- Plugins/Amazon/src/AmazonPlugin.m | 9 --- Plugins/Amazon/src/AmazonSearch.m | 4 -- Plugins/TagChimp/src/TCSearch.m | 14 ---- Plugins/TheTVDB/src/TheTVDBSearchProvider.m | 12 ---- 26 files changed, 573 deletions(-) diff --git a/App/src/AppController.m b/App/src/AppController.m index 4c9aed70..fc0cc973 100644 --- a/App/src/AppController.m +++ b/App/src/AppController.m @@ -232,10 +232,6 @@ - (void)updateSearchMenu profile = [SearchProfile unknownTypeProfile]; break; } - /* - if([activeProfile.identifier isEqual:profile.identifier]) - return; - */ [activeProfile removeObserver:self forKeyPath:@"searchTerms"]; [activeProfile release]; activeProfile = [profile retain]; @@ -245,15 +241,6 @@ - (void)updateSearchMenu NSMenu* menu = [[NSMenu alloc] initWithTitle: NSLocalizedString(@"Search terms", @"Search menu title")]; [menu addItemWithTitle:[menu title] action:nil keyEquivalent:@""]; - /* - if([profile mainTag]) - { - MZTag* tag = [MZTag tagForIdentifier:[profile mainTag]]; - NSMenuItem* mainItem = [menu addItemWithTitle:[tag localizedName] action:NULL keyEquivalent:@""]; - [mainItem setState:NSOnState]; - [mainItem setIndentationLevel:1]; - } - */ NSInteger i = 0; for(NSString* tagId in [profile tags]) { @@ -833,14 +820,6 @@ - (void)preferencesDidClose:(NSNotification *)note - (void)presetsDidClose:(NSNotification *)note { [[note object] saveFrameUsingName:@"presetsPanel"]; - /* - [[NSNotificationCenter defaultCenter] - removeObserver:self - name:NSWindowWillCloseNotification - object:[note object]]; - [presetsController release]; - presetsController = nil; - */ } - (void)removedEdit:(NSNotification *)note diff --git a/App/src/FileViewBox.m b/App/src/FileViewBox.m index ed774014..38948332 100644 --- a/App/src/FileViewBox.m +++ b/App/src/FileViewBox.m @@ -87,16 +87,6 @@ - (void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize [super resizeWithOldSuperviewSize:oldBoundsSize]; } -/* --(void)setFrameSize:(NSSize)newSize -{ - NSString* tab = [[tabView selectedTabViewItem] identifier]; - if([tab isEqual:@"pending"]) - newSize.height = 43; - [super setFrameSize:newSize]; -} -*/ - -(void)setFrame:(NSRect)newFrame { [super setFrame:newFrame]; @@ -115,13 +105,6 @@ - (void)setFrameRotation:(CGFloat)angle - (IBAction)switchDetails:(id)sender { - /* - NSTabViewItem * item = [tabView selectedTabViewItem]; - if([[item identifier] isEqual:@"pending"]) - [tabView selectTabViewItemWithIdentifier:@"action"]; - else - [tabView selectTabViewItemWithIdentifier:@"pending"]; - */ } - (IBAction)removeItem:(id)sender diff --git a/App/src/FilesTableView.m b/App/src/FilesTableView.m index 40d7f5f7..b8da66a8 100644 --- a/App/src/FilesTableView.m +++ b/App/src/FilesTableView.m @@ -110,14 +110,6 @@ -(IBAction)paste:(id)sender NSString *bestType = [pb availableTypeFromArray:types]; if (bestType != nil) { - /* - if([bestType isEqualToString:MZFilesTableRows]) - { - NSData* data = [pb dataForType:MZFilesTableRows]; - NSIndexSet* rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData:data]; - // TODO Support rowIndex paste?? - } - */ if([bestType isEqualToString:MZMetaEditsDataType]) { NSData* data = [pb dataForType:MZMetaEditsDataType]; @@ -234,14 +226,6 @@ - (id)validRequestorForSendType:(NSString *)sendType { return self; } - /* - if(returnType && - ([returnType isEqual:NSStringPboardType] || - [returnType isEqual:NSFilenamesPboardType])) - { - return self; - } - */ return [super validRequestorForSendType:sendType returnType:returnType]; } @@ -363,13 +347,6 @@ - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id )info [[MZMetaLoader sharedLoader] moveObjects:edits toIndex:row]; return YES; } - /* - if([bestType isEqualToString:MZMetaEditsDataType]) - { - NSData* data = [pb dataForType:MZMetaEditsDataType]; - NSArray* edits = [NSKeyedUnarchiver unarchiveObjectWithData:data]; - } - */ if([bestType isEqualToString:NSFilenamesPboardType]) { NSArray* filenames = [pboard propertyListForType:NSFilenamesPboardType]; @@ -378,11 +355,6 @@ - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id )info if(![[MZPluginController sharedInstance] dataProviderForPath:file]) return NO; } - /* Doesn't work - NSWindow* window = [self window]; - [window orderFront:self]; - [window makeMainWindow]; - */ if(![filesController commitEditing]) return NO; NSArray* params = [NSArray arrayWithObjects:filenames, [NSNumber numberWithInteger:row], nil]; @@ -398,7 +370,6 @@ - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id )info if([mgr fileExistsAtPath:filename isDirectory:&dir] && !dir && [[MZPluginController sharedInstance] dataProviderForPath:filename]) { - //[[self window] makeKeyAndOrderFront:self]; if(![filesController commitEditing]) return NO; NSArray* params = [NSArray arrayWithObjects:filename, [NSNumber numberWithInteger:row], nil]; @@ -493,13 +464,11 @@ - (void)keyDown:(NSEvent *)theEvent { if([ns length] == 1) { unichar ch = [ns characterAtIndex:0]; - //MZLoggerDebug(@"keyDown %x %x", ch, NSNewlineCharacter); switch(ch) { case NSBackspaceCharacter: case NSDeleteCharacter: if([self numberOfSelectedRows] > 0 && (modifierFlags & NSCommandKeyMask) == NSCommandKeyMask ) { - //MZLoggerDebug(@"Caught Cmd-Backspace"); [self delete:self]; return; } diff --git a/App/src/ImageWindowController.m b/App/src/ImageWindowController.m index cfb59179..a4a8c40a 100644 --- a/App/src/ImageWindowController.m +++ b/App/src/ImageWindowController.m @@ -72,19 +72,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N - (void)imageDidChange:(IKImageView *)aImageView imageState:(IKImageState*)state image:(CGImageRef)image { - //dumpMethods([aImageView class]); - /* - CGFloat rotationAngle = [state rotationAngle]; - int orientationTag = [state orientationTag]; - NSDictionary* imageProps = aImageView.imageProperties; - for(NSString* key in [imageProps allKeys]) - MZLoggerDebug(@"Key %@ Value %@", key, [imageProps objectForKey:key]); - */ [sourceImageView removeObserver:self forKeyPath:@"objectValue"]; - /* - [sourceImageView setObjectValue:[ImageWindowController rotateImage:[[NSBitmapImageRep alloc] initWithCGImage:[aImageView image]] - byDegrees:aImageView.rotationAngle]]; - */ NSBitmapImageRep* rep = [[[NSBitmapImageRep alloc] initWithCGImage:[aImageView image]] autorelease]; NSImage* nextImage = [[[NSImage alloc] initWithData:[rep TIFFRepresentation]] autorelease]; [sourceImageView setObjectValue:nextImage]; diff --git a/App/src/MZFileNameTextStorage.m b/App/src/MZFileNameTextStorage.m index 0fcd764e..84c45e04 100644 --- a/App/src/MZFileNameTextStorage.m +++ b/App/src/MZFileNameTextStorage.m @@ -11,8 +11,6 @@ @implementation MZFileNameTextStorage -/*************************** NSTextStorage Overrides ***************************/ - #pragma mark - #pragma mark NSTextStorage Overrides diff --git a/App/src/MZMetaDataDocument.m b/App/src/MZMetaDataDocument.m index 29a5bdf8..4b6f52d3 100644 --- a/App/src/MZMetaDataDocument.m +++ b/App/src/MZMetaDataDocument.m @@ -190,15 +190,6 @@ - (id)valueInTagsWithName:(NSString *)name return nil; } -/* -- (id)scriptingValueForSpecifier:(id)specifier -{ - NSLog(@"Bla Bla: %@ %@ %@ %@ %@", specifier, [specifier key], [[specifier childSpecifier] key], [[specifier containerSpecifier] key]); - id ret = [super scriptingValueForSpecifier:specifier]; - return ret; -} -*/ - - (NSScriptObjectSpecifier *)objectSpecifier; { NSScriptClassDescription *containerClassDesc = (NSScriptClassDescription *) @@ -208,13 +199,6 @@ - (NSScriptObjectSpecifier *)objectSpecifier; containerSpecifier:nil key:container name:[self displayName]] autorelease]; } -/* -- (NSArray *)indicesOfObjectsByEvaluatingObjectSpecifier:(NSScriptObjectSpecifier *)specifier -{ - NSLog(@"Bla Bla: %@ %@ %@", [specifier key], [[specifier childSpecifier] key], [[specifier containerSpecifier] key]); - return nil; -} -*/ - (id)handleCloseScriptCommand:(NSScriptCommand *)cmd; { diff --git a/App/src/MZMetaLoader.m b/App/src/MZMetaLoader.m index a7f4e68c..1db4a618 100644 --- a/App/src/MZMetaLoader.m +++ b/App/src/MZMetaLoader.m @@ -205,12 +205,6 @@ - (BOOL)loadFromFiles:(NSArray *)fileNames toIndexes:(NSIndexSet*)indexes NSLocalizedString(@"File \"%@\" is already loaded", @"Already loaded warning message"), basefile]]; } - /* - [alert setInformativeText:: - [NSString stringWithFormat: - NSLocalizedString(@"Do you wish to load it anyway?", @"Already loaded title prompt"), - [edits fileName]]]; - */ [alert setShowsSuppressionButton:YES]; [alert addButtonWithTitle:NSLocalizedString(@"OK", @"Button")]; @@ -223,11 +217,8 @@ - (BOOL)loadFromFiles:(NSArray *)fileNames toIndexes:(NSIndexSet*)indexes } [realFileNames removeObjectAtIndex:i]; [realIndexes removeIndex:index]; - //if(index>=[files count]) - //MZLoggerDebug(@"Shifting %d", [indexes lastIndex]); if([realIndexes countOfIndexesInRange:NSMakeRange(index, [indexes lastIndex]+1)] > 0) { - //MZLoggerDebug(@"Shifting %d", [indexes lastIndex]); [realIndexes shiftIndexesStartingAtIndex:[indexes indexGreaterThanIndex:index] by:-1]; } } @@ -242,11 +233,6 @@ - (BOOL)loadFromFiles:(NSArray *)fileNames toIndexes:(NSIndexSet*)indexes lastSelection = MZUnsetVideoType; } - /* - NSMutableArray* arr = [NSMutableArray arrayWithCapacity:[fileNames count]]; - int missingType = 0; - MZVideoType def = [[NSUserDefaults standardUserDefaults] integerForKey:@"incomingVideoType"]; - */ index = [indexes firstIndex]; for ( NSString* fileName in fileNames ) { @@ -264,71 +250,6 @@ - (BOOL)loadFromFiles:(NSArray *)fileNames toIndexes:(NSIndexSet*)indexes userInfo:nil]; index = [indexes indexGreaterThanIndex:index]; } - /* - if(missingType>0) - { - def = MZUnsetVideoType; - MZVideoType lastSelection = MZUnsetVideoType; - BOOL applyAll = NO; - for(MetaEdits* edits in arr) - { - if([edits videoType] == MZUnsetVideoType) - { - missingType--; - if(def == MZUnsetVideoType) - { - NSAlert* alert = [[NSAlert alloc] init]; - [alert setMessageText: - [NSString stringWithFormat: - NSLocalizedString(@"Video type for file \"%@\" could not be determined", @"Video type prompt"), - [edits fileName]]]; - NSPopUpButton* sel = [[NSPopUpButton alloc] - initWithFrame:NSMakeRect(0, 0, 145, 25) - pullsDown:NO]; - MZTag* tag = [MZTag tagForIdentifier:MZVideoTypeTagIdent]; - [sel setCell:[tag editorCell]]; - [sel setKeyEquivalent:@"t"]; - [sel setKeyEquivalentModifierMask:NSCommandKeyMask]; - - if(lastSelection!=MZUnsetVideoType) - [sel selectItemWithTag:lastSelection]; - - [alert setAccessoryView:sel]; - [alert addButtonWithTitle:NSLocalizedString(@"OK", @"Button")]; - [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"Button")]; - - if(missingType>0) - { - [alert setShowsSuppressionButton:YES]; - [[alert suppressionButton] setTitle: - NSLocalizedString(@"Apply to all", @"Confirmation text")]; - } - - NSInteger returnCode = [alert runModal]; - lastSelection = [[sel selectedItem] tag]; - if(missingType>0) - applyAll = [[alert suppressionButton] state] == NSOnState; - - [sel release]; - [alert release]; - - if(returnCode == NSAlertFirstButtonReturn) - { - def = lastSelection; - } else - return NO; - } - if(def!=MZUnsetVideoType) - [edits setVideoType:def]; - if(!applyAll) - def = MZUnsetVideoType; - } - } - } - [self willChangeValueForKey:@"files"]; - [files insertObjects:arr atIndexes:indexes]; - [self didChangeValueForKey:@"files"]; - */ return YES; } diff --git a/App/src/MZPresets.m b/App/src/MZPresets.m index aa91f946..0861aa0f 100644 --- a/App/src/MZPresets.m +++ b/App/src/MZPresets.m @@ -277,13 +277,6 @@ - (BOOL)saveWithError:(NSError **)error { NSFileManager *mgr = [NSFileManager manager]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); - /* - NSMutableArray* items = [NSMutableArray array]; - for(MZWriteQueueStatus* obj in queueItems) - if(![obj completed]) - [items addObject:[obj edits]]; - */ - //if([items count] > 0) { if ([paths count] > 0) { @@ -329,17 +322,6 @@ - (BOOL)saveWithError:(NSError **)error return NO; } } - /* - else - { - for(NSString * path in paths) - { - NSString *destinationPath = [path stringByAppendingPathComponent: fileName]; - if([mgr fileExistsAtPath:destinationPath] && ![mgr removeItemAtPath:destinationPath error:error]) - return NO; - } - } - */ return YES; } @@ -454,17 +436,6 @@ - (NSArray *)loadFromMetaXWithError:(NSError **)error return nil; } return [NSArray arrayWithArray:ret]; - /* - if(error != NULL) - { - //Make NSError; - NSDictionary* dict = [NSDictionary dictionaryWithObject: - NSLocalizedString(@"No presets found", @"No presets found error") - forKey:NSLocalizedDescriptionKey]; - *error = [NSError errorWithDomain:@"MetaZ" code:14 userInfo:dict]; - } - return nil; - */ } #pragma mark - observation callbacks diff --git a/App/src/MZWriteQueue.m b/App/src/MZWriteQueue.m index a124bd40..75b26ba2 100644 --- a/App/src/MZWriteQueue.m +++ b/App/src/MZWriteQueue.m @@ -100,28 +100,6 @@ -(void)start } } -/* --(void)pause -{ - if(status == QueueRunning) - { - [self willChangeValueForKey:@"status"]; - status = QueuePaused; - [self didChangeValueForKey:@"status"]; - } -} - --(void)resume -{ - if(status == QueuePaused) - { - [self willChangeValueForKey:@"status"]; - status = QueueRunning; - [self didChangeValueForKey:@"status"]; - } -} -*/ - -(void)stop { if(status != QueueStopped && status != QueueStopping ) diff --git a/App/src/MyQueueCollectionView.m b/App/src/MyQueueCollectionView.m index 44359abe..b80a406b 100644 --- a/App/src/MyQueueCollectionView.m +++ b/App/src/MyQueueCollectionView.m @@ -18,22 +18,6 @@ -(void)dealloc [super dealloc]; } -/* --(void)release -{ - NSUInteger count = [self retainCount]; - MZLoggerDebug(@"Releasing CollectionView %d", count); - [super release]; -} - -- (id)retain -{ - NSUInteger count = [self retainCount]; - MZLoggerDebug(@"Retaining CollectionView %d", count); - return [super retain]; -} -*/ - -(void)awakeFromNib { [self bind:NSContentBinding toObject:queues withKeyPath:@"arrangedObjects" options:nil]; diff --git a/App/src/PictureEditor.m b/App/src/PictureEditor.m index 1f768b86..36ceb3a9 100644 --- a/App/src/PictureEditor.m +++ b/App/src/PictureEditor.m @@ -59,26 +59,6 @@ - (MZPriorObserverFix* )observerFix - (void)awakeFromNib { [retryButton setHidden:YES]; - /* - NSArray* keys = [NSArray arrayWithObjects: - NSMultipleValuesPlaceholderBindingOption, - NSNoSelectionPlaceholderBindingOption, - NSNotApplicablePlaceholderBindingOption, - NSAllowsEditingMultipleValuesSelectionBindingOption, - NSAllowsNullArgumentBindingOption, - NSRaisesForNotApplicableKeysBindingOption, - nil]; - NSArray* values = [NSArray arrayWithObjects: - NSMultipleValuesMarker, - NSNoSelectionMarker, - NSNotApplicableMarker, - [NSNumber numberWithBool:YES], - [NSNumber numberWithBool:YES], - [NSNumber numberWithBool:NO], - nil]; - NSDictionary* dict = [NSDictionary dictionaryWithObjects:values forKeys:keys]; - [self bind:@"picture" toObject:filesController withKeyPath:@"selection.picture" options:dict]; - */ [picturesController gtm_addObserver:self forKeyPath:@"selection" selector:@selector(picturesUpdated:) userInfo:nil options:0]; } @@ -202,10 +182,6 @@ - (NSNumber*)dataChanged return NSNotApplicableMarker; } id changed = [self.observerFix valueForKeyPath:@"selection.pictureChanged"]; - /* - if(changed == NSMultipleValuesMarker) - MZLoggerDebug(@"Multiple"); - */ return changed; } @@ -251,20 +227,6 @@ - (void)setPicture:(id)newPicture [posterView setStatus:MZEmptyPosterImage]; else [posterView setStatus:MZOKPosterImage]; - /* - if(!newPicture) - { - id status = [filesController protectedValueForKeyPath:@"selection.picture"]; - if(status == NSMultipleValuesMarker) - [posterView setStatus:MZMultiplePosterImage]; - else if(status == NSNotApplicableMarker) - [posterView setStatus:MZNotApplicablePosterImage]; - else //if(status == NSNoSelectionMarker) - [posterView setStatus:MZEmptyPosterImage]; - } - else - [posterView setStatus:MZOKPosterImage]; - */ } [self didChangeValueForKey:@"data"]; diff --git a/App/src/PosterView.m b/App/src/PosterView.m index 3b552a80..77b68900 100644 --- a/App/src/PosterView.m +++ b/App/src/PosterView.m @@ -27,7 +27,6 @@ - (void)dealloc - (void)awakeFromNib { - //dumpMethods([self superclass]); actionHack = [self action]; [self setAction:NULL]; } @@ -127,20 +126,11 @@ - (NSString*)imageSize - (void)mouseDown:(NSEvent *)theEvent { - //MZLoggerDebug(@"Test Down %d %d", [theEvent clickCount], [self ignoresMultiClick]); if([theEvent clickCount] == 2 && [self isEnabled]) [NSApp sendAction:actionHack to:[self target] from:self]; [super mouseDown:theEvent]; } -/* -- (void)mouseUp:(NSEvent *)theEvent -{ - MZLoggerDebug(@"Test Up %d %d", [theEvent clickCount], [self ignoresMultiClick]); - [super mouseUp:theEvent]; -} -*/ - - (void)moveLeft:(id)sender { if([leftButton isHidden]) diff --git a/App/src/QueueController.m b/App/src/QueueController.m index d2a4515e..f75a58f1 100644 --- a/App/src/QueueController.m +++ b/App/src/QueueController.m @@ -128,13 +128,6 @@ - (void)unregisterAsObserver [writeQueue removeObserver:self forKeyPath:@"completedItems.@count"]; } -/* -- (void)setTargetProgress:(NSInteger)val -{ - targetProgress = val; -} -*/ - - (void)updateUI { RunStatus status = [writeQueue status]; @@ -253,18 +246,6 @@ - (void)applicationDidFinishLaunching:(NSNotification *)note NSString* title = [NSString stringWithFormat: NSLocalizedString(@"MetaZ Has Detected %d Pending Item(s) In Your Queue", @"Loaded queue message box text"), count]; - /* - NSAlert* alert = [[NSAlert alloc] init]; - [alert setMessageText:title]; - [alert setInformativeText:NSLocalizedString(@"Do you want to reload them ?", @"Loaded queue message question")]; - [alert setAlertStyle:NSCriticalAlertStyle]; - [alert addButtonWithTitle:NSLocalizedString(@"Reload Queue", @"Button text for reload queue action")]; - [alert addButtonWithTitle:NSLocalizedString(@"Empty Queue", @"Button text for empty queue action")]; - [alert setShowsSuppressionButton:YES]; - [[alert suppressionButton] setTitle:@"Apply to all in queue"]; - NSInteger returnCode = [alert runModal]; - [alert release]; - */ NSInteger returnCode = NSRunCriticalAlertPanel(title, NSLocalizedString(@"Do you want to reload them ?", @"Loaded queue message question"), NSLocalizedString(@"Reload Queue", @"Button text for reload queue action"), nil, @@ -272,15 +253,6 @@ - (void)applicationDidFinishLaunching:(NSNotification *)note ); if(returnCode == NSAlertOtherReturn) [writeQueue removeAllQueueItems]; - /* - NSBeginCriticalAlertSheet(title, - NSLocalizedString(@"Reload Queue", @"Button text for reload queue action"), nil, - NSLocalizedString(@"Empty Queue", @"Button text for empty queue action"), - mainWindow, - self, nil, @selector(didDismissReload:returnCode:contextInfo:), nil, - NSLocalizedString(@"Do you want to reload them ?", @"Loaded queue message question") - ); - */ } } @@ -506,12 +478,6 @@ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem - (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem { - /* - if([anItem action] == @selector(showQueue:)) - { - return [[writeQueue queueItems] count] > 0; - } - */ if([anItem action] == @selector(startEncoding:)) { return [writeQueue status] == QueueStopped && diff --git a/App/src/ResizeController.m b/App/src/ResizeController.m index 8c134947..5db75cfe 100644 --- a/App/src/ResizeController.m +++ b/App/src/ResizeController.m @@ -50,18 +50,6 @@ - (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:(NSSize)oldSiz return; } - /* - [sender adjustSubviews]; - NSRect bounds = [sender bounds]; - MZLoggerDebug(@"SplitView {{%f, %f},{%f,%f}}", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); - for ( NSView* view in [sender subviews] ) - { - bounds = [view frame]; - MZLoggerDebug(@" Subview {{%f, %f},{%f,%f}}", bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); - } - return; - */ - CGFloat widths[3]; widths[0] = [searchBox frame].size.width; widths[1] = [tabView frame].size.width; @@ -128,31 +116,6 @@ - (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:(NSSize)oldSiz if(w>0) MZLoggerDebug(@"More width"); - - /* - while(amount != 0.0) - { - amount = 0.0; - for(int i=0; i<3; i++) - { - if(widths[i] < mins[i]) - { - amount += mins[i]-widths[i]; - widths[i] = mins[i]; - count -= amounts[i]; - amounts[i] = 0; - } - } - if(newSize.width==minWidth) - amount=0; - if(amount != 0.0) - { - if(count==0) - MZLoggerDebug(@"Bad Count"); - for(int i=0; i<3; i++) widths[i] -= amounts[i]*amount/count; - } - } - */ CGFloat newWidth = 2*divider; if(![splitView isSubviewCollapsed:searchBox]) newWidth+=widths[0]; @@ -264,17 +227,6 @@ - (BOOL)splitView:(NSSplitView *)sender shouldCollapseSubview:(NSView *)subview if(width provider = [self dataProviderForPath:path]; - if(!provider) - return nil; - MetaLoaded* loaded = [provider loadFromFile:path]; - if(!loaded) - return nil; - id next = nil; - if([[self delegate] respondsToSelector:@selector(pluginController:extraMetaDataForProvider:loaded:)]) - { - next = [[self delegate] pluginController:self - extraMetaDataForProvider:provider - loaded:loaded]; - } - if(!next) - next = loaded; - MetaEdits* edits = [[MetaEdits alloc] initWithProvider:next]; - NSAssert([[edits fileName] isKindOfClass:[NSString class]], @"Bad file name"); - NSAssert([[edits title] isKindOfClass:[NSString class]], @"Bad title"); - NSDictionary* userInfo = [NSDictionary dictionaryWithObject:edits forKey:MZMetaEditsNotificationKey]; - [[NSNotificationCenter defaultCenter] - postNotificationName:MZDataProviderLoadedNotification - object:provider - userInfo:userInfo]; - return [edits autorelease]; -} -*/ - - (id)loadFromFile:(NSString *)fileName delegate:(id)theDelegate { @@ -437,12 +407,6 @@ - (MetaEdits *)loadDataFromFile:(NSString *)path - (id)saveChanges:(MetaEdits *)data delegate:(id)theDelegate { - /* - NSFileManager* mgr = [NSFileManager manager]; - BOOL isDir; - if(![mgr fileExistsAtPath:[data loadedFileName] isDirectory:&isDir] || isDir ) - return nil; - */ id provider = [data owner]; id otherDelegate = [MZWriteNotification notifierWithDelegate:theDelegate]; return [provider saveChanges:data delegate:otherDelegate queue:saveQueue]; @@ -664,11 +628,6 @@ - (void) searchFinished finishedSearches++; if(finishedSearches==performedSearches) { - /* - NSArray* keys = [NSArray arrayWithObjects:MZMetaEditsNotificationKey, MZDataControllerNotificationKey, nil]; - NSArray* values = [NSArray arrayWithObjects:edits, controller, nil]; - NSDictionary* userInfo = [NSDictionary dictionaryWithObjects:values forKeys:keys]; - */ if([delegate respondsToSelector:@selector(searchFinished)]) [delegate searchFinished]; [[NSNotificationCenter defaultCenter] diff --git a/Framework/src/MZPriorObserverFix.m b/Framework/src/MZPriorObserverFix.m index 1af6d802..c60a90f0 100644 --- a/Framework/src/MZPriorObserverFix.m +++ b/Framework/src/MZPriorObserverFix.m @@ -77,10 +77,6 @@ - (void)addObserver:(NSObject *)observer { NSString* newPrefix = [key stringByAppendingString:@"."]; if(!prefix) - /* - { - newPrefix = [prefix stringByAppendingString:newPrefix]; - } else*/ oldValue = [MZPriorObserverFix fixWithOther:other prefix:newPrefix]; } if(oldValue) @@ -136,9 +132,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N else key = shortPath; - if(prefix) - MZLoggerDebug(@"%@ path %@ changed", object, keyPath); - [self retain]; id oldValue = [[oldData objectForKey:key] retain]; id newValue = [other valueForKeyPath:keyPath]; @@ -147,14 +140,8 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N [self willChangeValueForKey:key]; if(newValue == NSMultipleValuesMarker) { - //newValue = [other valueForKey:key]; NSString* newPrefix = [key stringByAppendingString:@"."]; if(!prefix) - /* - { - newPrefix = [prefix stringByAppendingString:newPrefix]; - } - else*/ newValue = [MZPriorObserverFix fixWithOther:other prefix:newPrefix]; } if(newValue) diff --git a/Framework/src/MZTaskOperation.m b/Framework/src/MZTaskOperation.m index 668369f1..ece7d7af 100644 --- a/Framework/src/MZTaskOperation.m +++ b/Framework/src/MZTaskOperation.m @@ -59,44 +59,6 @@ - (void)dealloc @synthesize executing; @synthesize finished; -/* -- (BOOL)isExecuting -{ - @synchronized(self) - { - return isExecuting; - } -} - -- (void)setIsExecuting:(BOOL)newVal -{ - [self willChangeValueForKey:@"isExecuting"]; - @synchronized(self) - { - isExecuting = newVal; - } - [self didChangeValueForKey:@"isExecuting"]; -} - -- (BOOL)isFinished -{ - @synchronized(self) - { - return isFinished; - } -} - -- (void)setIsFinished:(BOOL)newVal -{ - [self willChangeValueForKey:@"isFinished"]; - @synchronized(self) - { - isFinished = newVal; - } - [self didChangeValueForKey:@"isFinished"]; -} -*/ - - (void)start { self.executing = YES; diff --git a/Framework/src/MetaEdits.m b/Framework/src/MetaEdits.m index d119a27c..b38589d4 100644 --- a/Framework/src/MetaEdits.m +++ b/Framework/src/MetaEdits.m @@ -112,10 +112,6 @@ - (void)prepareFromQueue -(BOOL)changed { - /* - int count = [changes objectForKey:MZFileNameTag] != nil ? 1 : 0; - return [changes count] > count; - */ return [changes count] > 0; } @@ -218,20 +214,6 @@ -(void)setterValue:(id)aValue forKey:(NSString *)aKey BOOL pureModified = (pureValue != aValue) && !(pureValue && aValue && [pureValue isEqual:aValue]); - /* - id currentValue = [provider valueForKey:aKey]; - currentValue = [tag convertObjectForStorage:currentValue]; - - // If reverted to old value - if([aValue isEqual:currentValue]) - { - if(oldValue == nil) - return; - [self setterChanged:NO forKey:aKey]; - return; - } - */ - if(oldValue==nil) { [[[self undoManager] prepareWithInvocationTarget:self] setterChanged:NO forKey:aKey]; diff --git a/Plugins/Amazon/src/AmazonPlugin.m b/Plugins/Amazon/src/AmazonPlugin.m index 4700b811..3e70fc9e 100644 --- a/Plugins/Amazon/src/AmazonPlugin.m +++ b/Plugins/Amazon/src/AmazonPlugin.m @@ -28,15 +28,6 @@ - (void)dealloc [super dealloc]; } -/* -- (void)didLoad -{ - [MZTag registerTag:[MZStringTag tagWithIdentifier:ASINTagIdent]]; - [super didLoad]; -} -*/ - - - (BOOL)isBuiltIn { return YES; diff --git a/Plugins/Amazon/src/AmazonSearch.m b/Plugins/Amazon/src/AmazonSearch.m index 6cd054f1..ff2b0cf6 100644 --- a/Plugins/Amazon/src/AmazonSearch.m +++ b/Plugins/Amazon/src/AmazonSearch.m @@ -249,10 +249,6 @@ - (void)requestFinished:(ASIHTTPRequest *)theRequest; NSString* coverArtLarge = [item stringForXPath:@"LargeImage/URL" error:NULL]; if([coverArtLarge length] > 0) { - /* - MZLoggerDebug(@"ASIN %@", asin); - MZLoggerDebug(@"Image large url: %@", coverArtLarge); - */ NSURL* url = [NSURL URLWithString:coverArtLarge]; MZRemoteData* data = [MZRemoteData dataWithURL:url]; [dict setObject:data forKey:MZPictureTagIdent]; diff --git a/Plugins/TagChimp/src/TCSearch.m b/Plugins/TagChimp/src/TCSearch.m index 78dda2f9..5379390b 100644 --- a/Plugins/TagChimp/src/TCSearch.m +++ b/Plugins/TagChimp/src/TCSearch.m @@ -186,10 +186,6 @@ - (void)requestFinished:(ASIHTTPRequest *)theRequest; } */ - /* - NSString* releaseYearStr = [item stringForXPath:@"movieTags/info/releaseDateY" error:NULL]; - MZLoggerDebug(@"Release Year '%@'", releaseYearStr); - */ NSInteger releaseYear = [[item stringForXPath:@"movieTags/info/releaseDateY" error:NULL] integerValue]; if(releaseYear > 0) { @@ -261,14 +257,8 @@ - (void)requestFinished:(ASIHTTPRequest *)theRequest; } NSString* coverArtLarge = [item stringForXPath:@"movieTags/coverArtLarge" error:NULL]; - //NSString* coverArtSmall = [item stringForXPath:@"movieTags/coverArtSmall" error:NULL]; if([coverArtLarge length] > 0) { - /* - MZLoggerDebug(@"TagChimp id %@", tagChimpId); - MZLoggerDebug(@"Image small url: %@", coverArtSmall); - MZLoggerDebug(@"Image large url: %@", coverArtLarge); - */ NSURL* url = [NSURL URLWithString: [coverArtLarge stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; MZRemoteData* data = [MZRemoteData dataWithURL:url]; @@ -329,10 +319,6 @@ - (void)requestFinished:(ASIHTTPRequest *)theRequest; i++; } NSString* key = hasTime ? MZChaptersTagIdent : MZChapterNamesTagIdent; - /* - if(hasTime) - MZLoggerDebug(@"Chapters with time %d", [chapters count]); - */ [dict setObject:[NSArray arrayWithArray:chapters] forKey:key]; } diff --git a/Plugins/TheTVDB/src/TheTVDBSearchProvider.m b/Plugins/TheTVDB/src/TheTVDBSearchProvider.m index 2ce384ed..9d28575f 100644 --- a/Plugins/TheTVDB/src/TheTVDBSearchProvider.m +++ b/Plugins/TheTVDB/src/TheTVDBSearchProvider.m @@ -64,18 +64,6 @@ - (NSMenu *)menuForResult:(MZSearchResult *)result return menu; } -/* -- (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem -{ - SEL action = [anItem action]; - if(action == @selector(imdb:)) - { - return - } - return action == @selector(view:); -} -*/ - - (void)view:(id)sender { MZSearchResult* result = [sender representedObject]; From 0e8cb51d21e8c6287c4e7cdc098f156dd5ae01d0 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 01:55:21 +0100 Subject: [PATCH 16/36] Added support for passing initial metadata along when loading files --- App/src/MZMetaLoader.h | 9 +++- App/src/MZMetaLoader.m | 53 ++++++++++++++++++++-- Framework/src/MZDataProvider.h | 3 +- Framework/src/MZPluginController.h | 3 +- Framework/src/MZPluginController.m | 3 +- Framework/src/MZReadOperationsController.h | 6 ++- Framework/src/MZReadOperationsController.m | 19 +++++++- Plugins/AtomicParsley/src/APDataProvider.m | 9 +++- 8 files changed, 89 insertions(+), 16 deletions(-) diff --git a/App/src/MZMetaLoader.h b/App/src/MZMetaLoader.h index 0f16dc44..bf7c798b 100644 --- a/App/src/MZMetaLoader.h +++ b/App/src/MZMetaLoader.h @@ -23,8 +23,8 @@ MZKIT_EXTERN NSString* const MZMetaLoaderFinishedNotification; NSScriptCommand* scriptCommand; } -+ (id)loadWithFilePath:(NSString *)filePath atIndex:(NSUInteger )index; -- (id)initWithFilePath:(NSString *)filePath atIndex:(NSUInteger )index; ++ (id)loadWithFilePath:(NSString *)filePath atIndex:(NSUInteger )index extra:(NSDictionary *)extra; +- (id)initWithFilePath:(NSString *)filePath atIndex:(NSUInteger )index extra:(NSDictionary *)extra; @property (readonly) NSString* filePath; @property (readonly) NSUInteger index; @@ -55,6 +55,11 @@ MZKIT_EXTERN NSString* const MZMetaLoaderFinishedNotification; - (BOOL)loadFromFile:(NSString *)fileName toIndex:(NSUInteger)index; - (BOOL)loadFromFiles:(NSArray *)fileNames toIndex:(NSUInteger)index; - (BOOL)loadFromFiles:(NSArray *)fileNames toIndexes:(NSIndexSet*)indexes; +- (BOOL)loadFromFile:(NSString *)fileName withMetaData:(NSDictionary *)metaData; +- (BOOL)loadFromFiles:(NSArray *)fileNames withMetaData:(NSArray *)metaData; +- (BOOL)loadFromFile:(NSString *)fileName toIndex:(NSUInteger)index withMetaData:(NSDictionary *)metaData; +- (BOOL)loadFromFiles:(NSArray *)fileNames toIndex:(NSUInteger)index withMetaData:(NSArray *)metaData; +- (BOOL)loadFromFiles:(NSArray *)fileNames toIndexes:(NSIndexSet*)indexes withMetaData:(NSArray *)metaData; - (void)moveObjects:(NSArray *)objects toIndex:(NSUInteger)index; - (void)reloadEdits:(MetaEdits *)edits; diff --git a/App/src/MZMetaLoader.m b/App/src/MZMetaLoader.m index 1db4a618..79c7a724 100644 --- a/App/src/MZMetaLoader.m +++ b/App/src/MZMetaLoader.m @@ -132,11 +132,48 @@ - (BOOL)loadFromFiles:(NSArray *)fileNames toIndex:(NSUInteger)index } - (BOOL)loadFromFiles:(NSArray *)fileNames toIndexes:(NSIndexSet*)indexes +{ + return [self loadFromFiles:fileNames toIndexes:indexes withMetaData:nil]; +} + + +- (BOOL)loadFromFile:(NSString *)fileName withMetaData:(NSDictionary *)metaData; +{ + return [self loadFromFile:fileName toIndex:[files count] withMetaData:metaData]; +} + +- (BOOL)loadFromFiles:(NSArray *)fileNames withMetaData:(NSArray *)metaData; +{ + return [self loadFromFiles:fileNames toIndex:[files count] withMetaData:metaData]; +} + +- (BOOL)loadFromFile:(NSString *)fileName toIndex:(NSUInteger)index withMetaData:(NSDictionary *)metaData; +{ + NSAssert(fileName, @"Provided fileName"); + return [self loadFromFiles:[NSArray arrayWithObject:fileName] + toIndex:index + withMetaData:(metaData ? [NSArray arrayWithObject:metaData] : nil)]; +} + +- (BOOL)loadFromFiles:(NSArray *)fileNames toIndex:(NSUInteger)index withMetaData:(NSArray *)metaData; +{ + NSAssert(fileNames, @"Provided filenames"); + if([fileNames count]==0) + return YES; + return [self loadFromFiles:fileNames + toIndexes:[NSIndexSet indexSetWithIndexesInRange: + NSMakeRange(index, [fileNames count])] + withMetaData:metaData]; +} + +- (BOOL)loadFromFiles:(NSArray *)fileNames toIndexes:(NSIndexSet*)indexes withMetaData:(NSArray *)metaData { NSAssert(fileNames, @"Provided filenames"); if([fileNames count]==0) return YES; NSAssert([fileNames count]==[indexes count], @"Count of indexes and filenames"); + if(metaData) + NSAssert([fileNames count]==[metaData count], @"Count of metaData and filenames"); BOOL suppressAlreadyLoadedWarning = [[NSUserDefaults standardUserDefaults] boolForKeyPath:MZDataProviderFileAlreadyLoadedWarningKey]; @@ -234,9 +271,15 @@ - (BOOL)loadFromFiles:(NSArray *)fileNames toIndexes:(NSIndexSet*)indexes } index = [indexes firstIndex]; + NSEnumerator* md = nil; + if(metaData) + md = [metaData objectEnumerator]; for ( NSString* fileName in fileNames ) { - MZLoadOperation* operation = [MZLoadOperation loadWithFilePath:fileName atIndex:index]; + NSDictionary* extra = nil; + if(md) + extra = [md nextObject]; + MZLoadOperation* operation = [MZLoadOperation loadWithFilePath:fileName atIndex:index extra:extra]; NSScriptCommand* cmd = [NSScriptCommand currentCommand]; if(cmd) { @@ -409,12 +452,12 @@ - (void)reloadEdits:(MetaEdits *)edits @implementation MZLoadOperation -+ (id)loadWithFilePath:(NSString *)filePath atIndex:(NSUInteger )index ++ (id)loadWithFilePath:(NSString *)filePath atIndex:(NSUInteger )index extra:(NSDictionary *)extra { - return [[[self alloc] initWithFilePath:filePath atIndex:index] autorelease]; + return [[[self alloc] initWithFilePath:filePath atIndex:index extra:extra] autorelease]; } -- (id)initWithFilePath:(NSString *)theFilePath atIndex:(NSUInteger )theIndex +- (id)initWithFilePath:(NSString *)theFilePath atIndex:(NSUInteger )theIndex extra:(NSDictionary *)extra { self = [super init]; if(self) @@ -422,7 +465,7 @@ - (id)initWithFilePath:(NSString *)theFilePath atIndex:(NSUInteger )theIndex filePath = [theFilePath retain]; index = theIndex; delegate = [[MZLoadOperationDelegate alloc] initWithOwner:self]; - controller = [[[MZPluginController sharedInstance] loadFromFile:filePath delegate:delegate] retain]; + controller = [[[MZPluginController sharedInstance] loadFromFile:filePath delegate:delegate extra:extra] retain]; } return self; } diff --git a/Framework/src/MZDataProvider.h b/Framework/src/MZDataProvider.h index b4f6da3d..b620bc70 100644 --- a/Framework/src/MZDataProvider.h +++ b/Framework/src/MZDataProvider.h @@ -59,7 +59,8 @@ */ - (id)loadFromFile:(NSString *)fileName delegate:(id)deledate - queue:(NSOperationQueue *)queue; + queue:(NSOperationQueue *)queue + extra:(NSDictionary *)extra; /*! diff --git a/Framework/src/MZPluginController.h b/Framework/src/MZPluginController.h index ed39eb02..5ba2aa6d 100644 --- a/Framework/src/MZPluginController.h +++ b/Framework/src/MZPluginController.h @@ -66,7 +66,8 @@ - (id)dataProviderForType:(NSString *)uti; - (id)searchProviderWithIdentifier:(NSString *)identifier; - (id)loadFromFile:(NSString *)fileName - delegate:(id)deledate; + delegate:(id)deledate + extra:(NSDictionary *)extra; - (id)saveChanges:(MetaEdits *)data delegate:(id)delegate; - (void)searchAllWithData:(NSDictionary *)data diff --git a/Framework/src/MZPluginController.m b/Framework/src/MZPluginController.m index 0180a177..d7209505 100644 --- a/Framework/src/MZPluginController.m +++ b/Framework/src/MZPluginController.m @@ -395,13 +395,14 @@ - (NSArray *)dataProviderTypes - (id)loadFromFile:(NSString *)fileName delegate:(id)theDelegate + extra:(NSDictionary *)extra { id provider = [self dataProviderForPath:fileName]; if(!provider) return nil; id otherDelegate = [MZReadNotification notifierWithController:self delegate:theDelegate]; - return [provider loadFromFile:fileName delegate:otherDelegate queue:loadQueue]; + return [provider loadFromFile:fileName delegate:otherDelegate queue:loadQueue extra:extra]; } - (id)saveChanges:(MetaEdits *)data diff --git a/Framework/src/MZReadOperationsController.h b/Framework/src/MZReadOperationsController.h index 3910b4f8..69ceda99 100644 --- a/Framework/src/MZReadOperationsController.h +++ b/Framework/src/MZReadOperationsController.h @@ -20,11 +20,13 @@ + (id)controllerWithProvider:(id)provider fromFileName:(NSString *)fileName - delegate:(id)delegate; + delegate:(id)delegate + extra:(NSDictionary *)extra; - (id)initWithProvider:(id)provider fromFileName:(NSString *)fileName - delegate:(id)delegate; + delegate:(id)delegate + extra:(NSDictionary *)extra; - (void)operationsFinished; diff --git a/Framework/src/MZReadOperationsController.m b/Framework/src/MZReadOperationsController.m index 51b296fc..f105c372 100644 --- a/Framework/src/MZReadOperationsController.m +++ b/Framework/src/MZReadOperationsController.m @@ -7,20 +7,22 @@ // #import "MZReadOperationsController.h" - +#import "MZTag.h" @implementation MZReadOperationsController + (id)controllerWithProvider:(id)provider fromFileName:(NSString *)fileName delegate:(id)delegate + extra:(NSDictionary *)extra { - return [[[[self class] alloc] initWithProvider:provider fromFileName:fileName delegate:delegate] autorelease]; + return [[[[self class] alloc] initWithProvider:provider fromFileName:fileName delegate:delegate extra:extra] autorelease]; } - (id)initWithProvider:(id)theProvider fromFileName:(NSString *)theFileName delegate:(id)theDelegate + extra:(NSDictionary *)extra { self = [super init]; if(self) @@ -29,6 +31,19 @@ - (id)initWithProvider:(id)theProvider fileName = [theFileName retain]; delegate = [theDelegate retain]; tagdict = [[NSMutableDictionary alloc] init]; + if(extra) + { + for(NSString* key in [extra allKeys]) + { + MZTag* tag = [MZTag tagForIdentifier:key]; + if(tag) + { + id value = [extra objectForKey:key]; + value = [tag convertObjectForRetrival:value]; + [tagdict setObject:[tag convertObjectForStorage:value] forKey:key]; + } + } + } } return self; } diff --git a/Plugins/AtomicParsley/src/APDataProvider.m b/Plugins/AtomicParsley/src/APDataProvider.m index be3843da..91df1d54 100644 --- a/Plugins/AtomicParsley/src/APDataProvider.m +++ b/Plugins/AtomicParsley/src/APDataProvider.m @@ -425,11 +425,13 @@ -(NSArray *)providedTags - (id)loadFromFile:(NSString *)fileName delegate:(id)delegate queue:(NSOperationQueue *)queue + extra:(NSDictionary *)extra { MZReadOperationsController* op = [MZReadOperationsController controllerWithProvider:self fromFileName:fileName - delegate:delegate]; + delegate:delegate + extra:extra]; APReadDataTask* dataRead = [APReadDataTask taskWithProvider:self fromFileName:fileName dictionary:op.tagdict]; [dataRead setLaunchPath:[self launchPath]]; @@ -471,7 +473,10 @@ - (void)parseData:(NSData *)data withFileName:(NSString *)fileName dict:(NSMutab // Initialize a null value for all known keys for(MZTag* tag in tags) - [tagdict setObject:[NSNull null] forKey:[tag identifier]]; + { + if(![tagdict objectForKey:[tag identifier]]) + [tagdict setObject:[NSNull null] forKey:[tag identifier]]; + } // Store real parsed values using a simple key -> key mapping for(NSString* map in [read_mapping allKeys]) From 2a92ab15e90a895bd342d63dbbcf5b6d1974fa7a Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 02:01:12 +0100 Subject: [PATCH 17/36] Added some paths to Xcode groups --- MetaZ.xcodeproj/project.pbxproj | 38 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/MetaZ.xcodeproj/project.pbxproj b/MetaZ.xcodeproj/project.pbxproj index 31845577..762d25e1 100644 --- a/MetaZ.xcodeproj/project.pbxproj +++ b/MetaZ.xcodeproj/project.pbxproj @@ -469,7 +469,7 @@ /* Begin PBXFileReference section */ 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; - 1B032F5A10B0BE1A00B28E3A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Plugins/Amazon/Info.plist; sourceTree = ""; }; + 1B032F5A10B0BE1A00B28E3A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Amazon/Info.plist; sourceTree = ""; }; 1B032F6710B0C12100B28E3A /* AmazonPlugin.mzplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AmazonPlugin.mzplugin; sourceTree = BUILT_PRODUCTS_DIR; }; 1B032FD910B0C5FE00B28E3A /* hmac_sha2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hmac_sha2.c; path = Externals/hmac/hmac_sha2.c; sourceTree = ""; }; 1B032FDA10B0C5FE00B28E3A /* hmac_sha2.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.c.preprocessed; fileEncoding = 4; name = hmac_sha2.c; path = Externals/hmac/hmac_sha2.c; sourceTree = ""; }; @@ -490,7 +490,7 @@ 1B03325110B1592D00B28E3A /* StopProgress.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = StopProgress.png; path = App/resources/StopProgress.png; sourceTree = ""; }; 1B03325310B15CB200B28E3A /* StopProgressHover.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = StopProgressHover.png; path = App/resources/StopProgressHover.png; sourceTree = ""; }; 1B03325510B15FF100B28E3A /* StopProgressOn.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = StopProgressOn.png; path = App/resources/StopProgressOn.png; sourceTree = ""; }; - 1B040C13107F9DA20027FA0D /* mp4chaps */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = mp4chaps; path = Plugins/AtomicParsley/resources/mp4chaps; sourceTree = ""; }; + 1B040C13107F9DA20027FA0D /* mp4chaps */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = mp4chaps; sourceTree = ""; }; 1B040C3C107FC7480027FA0D /* MZTimeCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZTimeCode.h; sourceTree = ""; }; 1B040C3D107FC7480027FA0D /* MZTimeCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MZTimeCode.m; sourceTree = ""; }; 1B040C40107FD1110027FA0D /* MZTimedTextItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZTimedTextItem.h; sourceTree = ""; }; @@ -502,10 +502,10 @@ 1B040DC2108176A70027FA0D /* UndoTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UndoTableView.h; sourceTree = ""; }; 1B040DC3108176A70027FA0D /* UndoTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UndoTableView.m; sourceTree = ""; }; 1B040EBE1081B3C00027FA0D /* TagChimp.mzplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TagChimp.mzplugin; sourceTree = BUILT_PRODUCTS_DIR; }; - 1B040EDA1081B4980027FA0D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Plugins/TagChimp/Info.plist; sourceTree = ""; }; + 1B040EDA1081B4980027FA0D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../Info.plist; sourceTree = ""; }; 1B040EDB1081B4DC0027FA0D /* TagChimpPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagChimpPlugin.h; sourceTree = ""; }; 1B040EDC1081B4DC0027FA0D /* TagChimpPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TagChimpPlugin.m; sourceTree = ""; }; - 1B040EDE1081B53F0027FA0D /* tagChimp.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = tagChimp.png; path = Plugins/TagChimp/resources/tagChimp.png; sourceTree = ""; }; + 1B040EDE1081B53F0027FA0D /* tagChimp.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tagChimp.png; sourceTree = ""; }; 1B040EE01081B5550027FA0D /* TCSearchProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TCSearchProvider.h; sourceTree = ""; }; 1B040EE11081B5550027FA0D /* TCSearchProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TCSearchProvider.m; sourceTree = ""; }; 1B0604AB1199E24700589ACE /* MZBaseSearchProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZBaseSearchProvider.h; sourceTree = ""; }; @@ -590,10 +590,10 @@ 1B42F21B10DD5D5D00AFEBF6 /* UKDockProgressIndicator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UKDockProgressIndicator.m; path = Externals/UKDockProgressIndicator/UKDockProgressIndicator.m; sourceTree = ""; }; 1B42F21E10DD5D6D00AFEBF6 /* English */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = English; path = Externals/UKDockProgressIndicator/English.lproj/MiniProgressGradient.png; sourceTree = ""; }; 1B42F25810DEB0D300AFEBF6 /* IMDBPlugin.mzplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = IMDBPlugin.mzplugin; sourceTree = BUILT_PRODUCTS_DIR; }; - 1B42F25910DEB0D300AFEBF6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Plugins/IMDB/Info.plist; sourceTree = ""; }; + 1B42F25910DEB0D300AFEBF6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../Info.plist; sourceTree = ""; }; 1B42F2B510DEB4A200AFEBF6 /* IMDBPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IMDBPlugin.h; sourceTree = ""; }; 1B42F2B610DEB4A200AFEBF6 /* IMDBPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IMDBPlugin.m; sourceTree = ""; }; - 1B44949810D57D6900B9C751 /* AtomicParsley */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = AtomicParsley; path = Plugins/AtomicParsley/resources/AtomicParsley; sourceTree = ""; }; + 1B44949810D57D6900B9C751 /* AtomicParsley */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = AtomicParsley; sourceTree = ""; }; 1B4494BC10D584E000B9C751 /* next_release.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = next_release.txt; path = Release/next_release.txt; sourceTree = ""; }; 1B44956C10D6118F00B9C751 /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Growl.framework; path = Externals/Growl.framework; sourceTree = ""; }; 1B44958410D6128700B9C751 /* Growl Registration Ticket.growlRegDict */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = "Growl Registration Ticket.growlRegDict"; path = "App/resources/Growl Registration Ticket.growlRegDict"; sourceTree = ""; }; @@ -876,10 +876,10 @@ 1B4AF829116F0AFD00E5C969 /* DebugSnowLeopardOrLater.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = DebugSnowLeopardOrLater.xcconfig; path = "Externals/google-toolbox-for-mac/XcodeConfig/Project/DebugSnowLeopardOrLater.xcconfig"; sourceTree = ""; }; 1B4AF8391170CFCC00E5C969 /* TheTVDBSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TheTVDBSearch.h; sourceTree = ""; }; 1B4AF83A1170CFCC00E5C969 /* TheTVDBSearch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TheTVDBSearch.m; sourceTree = ""; }; - 1B4AF84411715C8400E5C969 /* languages.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = languages.xml; path = Plugins/TheTVDB/resources/languages.xml; sourceTree = ""; }; + 1B4AF84411715C8400E5C969 /* languages.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = languages.xml; sourceTree = ""; }; 1B4CFF8F161CDF0100B12009 /* AEVTBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AEVTBuilder.h; sourceTree = ""; }; 1B4CFF90161CDF0100B12009 /* AEVTBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AEVTBuilder.m; sourceTree = ""; }; - 1B4F5394116E9EFC003221B1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Plugins/TheTVDB/Info.plist; sourceTree = ""; }; + 1B4F5394116E9EFC003221B1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../Info.plist; sourceTree = ""; }; 1B4F53C9116E9F44003221B1 /* TheTVDBPlugin.mzplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TheTVDBPlugin.mzplugin; sourceTree = BUILT_PRODUCTS_DIR; }; 1B4F53DD116EA1B5003221B1 /* TheTVDBPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TheTVDBPlugin.h; sourceTree = ""; }; 1B4F53DE116EA1B5003221B1 /* TheTVDBPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TheTVDBPlugin.m; sourceTree = ""; }; @@ -968,7 +968,7 @@ 1B8CB5E014AA31C500F859F7 /* modified_selected.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = modified_selected.tiff; path = App/resources/modified_selected.tiff; sourceTree = ""; }; 1B8CB5E114AA31C500F859F7 /* modified.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = modified.tiff; path = App/resources/modified.tiff; sourceTree = ""; }; 1B8CB90B14ACD62000F859F7 /* TheMovieDb.mzplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TheMovieDb.mzplugin; sourceTree = BUILT_PRODUCTS_DIR; }; - 1B8CB95014ACD77800F859F7 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Plugins/TheMovieDb/Info.plist; sourceTree = ""; }; + 1B8CB95014ACD77800F859F7 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = TheMovieDb/Info.plist; sourceTree = ""; }; 1B8CB96214AE3B2000F859F7 /* TheMovieDbPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TheMovieDbPlugin.m; sourceTree = ""; }; 1B8CB97F14AE3C1800F859F7 /* Access.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Access.h; path = Plugins/TheMovieDb/Access.h; sourceTree = SOURCE_ROOT; }; 1B92BB1A10876FBA0057EFD7 /* PureMetaEdits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PureMetaEdits.h; sourceTree = ""; }; @@ -1086,7 +1086,7 @@ 1BEA6E72106EF2A0004B1A7F /* AtomicParsleyPlugin.mzplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AtomicParsleyPlugin.mzplugin; sourceTree = BUILT_PRODUCTS_DIR; }; 1BEA6E8A106EF4CD004B1A7F /* APDataProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APDataProvider.h; sourceTree = ""; }; 1BEA6E8B106EF4CD004B1A7F /* APDataProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APDataProvider.m; sourceTree = ""; }; - 1BEA6E8D106EF522004B1A7F /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Plugins/AtomicParsley/Info.plist; sourceTree = ""; }; + 1BEA6E8D106EF522004B1A7F /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../Info.plist; sourceTree = ""; }; 1BEA6E8F106EF534004B1A7F /* AtomicParsleyPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AtomicParsleyPlugin.h; sourceTree = ""; }; 1BEA6E90106EF534004B1A7F /* AtomicParsleyPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AtomicParsleyPlugin.m; sourceTree = ""; }; 1BEA718D10712A17004B1A7F /* NSArray+Mapping.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+Mapping.h"; sourceTree = ""; }; @@ -1340,7 +1340,7 @@ 1B15A60D10B608D100EC0FBF /* AmazonSearch.m */, ); name = Classes; - path = Plugins/Amazon/src; + path = Amazon/src; sourceTree = ""; }; 1B032F5910B0BDFD00B28E3A /* Resources */ = { @@ -1378,7 +1378,7 @@ 1B6E43C710845F8200DFE165 /* TCSearch.m */, ); name = Classes; - path = Plugins/TagChimp/src; + path = TagChimp/src; sourceTree = ""; }; 1B040EAA1081B3950027FA0D /* Resources */ = { @@ -1388,6 +1388,7 @@ 1B040EDA1081B4980027FA0D /* Info.plist */, ); name = Resources; + path = TagChimp/resources; sourceTree = ""; }; 1B069665149BD32D00B5FA90 /* MGViewAnimation */ = { @@ -1441,7 +1442,7 @@ 1B060DF810E267810009D847 /* imdb_plugin.rb */, ); name = Classes; - path = Plugins/IMDB/src; + path = IMDB/src; sourceTree = ""; }; 1B42F23D10DEB08300AFEBF6 /* Resources */ = { @@ -1450,6 +1451,7 @@ 1B42F25910DEB0D300AFEBF6 /* Info.plist */, ); name = Resources; + path = IMDB/resources; sourceTree = ""; }; 1B449CEE10DCCAD500B9C751 /* External Sources */ = { @@ -1807,6 +1809,7 @@ 1B4F5394116E9EFC003221B1 /* Info.plist */, ); name = Resources; + path = TheTVDB/resources; sourceTree = ""; }; 1B4F538F116E9E33003221B1 /* Classes */ = { @@ -1821,7 +1824,7 @@ 1B4AF83A1170CFCC00E5C969 /* TheTVDBSearch.m */, ); name = Classes; - path = Plugins/TheTVDB/src; + path = TheTVDB/src; sourceTree = ""; }; 1B523B4813F4B24E00C20B7D /* asi-http-request */ = { @@ -1936,7 +1939,7 @@ 1B299D7214AE43900048B7C0 /* TheMovieDbSearch.m */, ); name = Classes; - path = Plugins/TheMovieDb/src; + path = TheMovieDb/src; sourceTree = ""; }; 1B92BB711087884C0057EFD7 /* Views */ = { @@ -2127,7 +2130,7 @@ 1B040EA81081B3860027FA0D /* TagChimp */, 1BEA6E69106EF251004B1A7F /* AtomicParsley */, ); - name = Plugins; + path = Plugins; sourceTree = ""; }; 1BEA6E69106EF251004B1A7F /* AtomicParsley */ = { @@ -2152,7 +2155,7 @@ 1B3AD7E11105884800B33F85 /* APReadDataTask.m */, ); name = Classes; - path = Plugins/AtomicParsley/src; + path = AtomicParsley/src; sourceTree = ""; }; 1BEA6E87106EF40C004B1A7F /* Resources */ = { @@ -2163,6 +2166,7 @@ 1BEA6E8D106EF522004B1A7F /* Info.plist */, ); name = Resources; + path = AtomicParsley/resources; sourceTree = ""; }; 29B97314FDCFA39411CA2CEA /* MetaZ */ = { From 919b7c15ae8287d06b0789cbc2eed87045a27393 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 02:05:05 +0100 Subject: [PATCH 18/36] Fixed problem with plugin label was prefixed with a whitespace --- Framework/src/MZPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/src/MZPlugin.m b/Framework/src/MZPlugin.m index 4ea13efc..12dbbb97 100644 --- a/Framework/src/MZPlugin.m +++ b/Framework/src/MZPlugin.m @@ -61,7 +61,7 @@ - (NSString *)label while(range.location != NSNotFound) { sub = [className substringWithRange:NSMakeRange(oldloc, range.location-oldloc)]; - if(sub.length > 1) + if(sub.length > 1 && ret.length > 0) [ret appendString:@" "]; [ret appendString:sub]; NSUInteger max = NSMaxRange(range); From 38c84a50157063513fead13c12966020d476c2c8 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 02:05:34 +0100 Subject: [PATCH 19/36] Retained the bundle for the plugin --- Framework/src/MZPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/src/MZPlugin.m b/Framework/src/MZPlugin.m index 12dbbb97..9db83936 100644 --- a/Framework/src/MZPlugin.m +++ b/Framework/src/MZPlugin.m @@ -16,7 +16,7 @@ - (id)init self = [super init]; if(self) { - bundle = [NSBundle bundleForClass:[self class]]; + bundle = [[NSBundle bundleForClass:[self class]] retain]; } return self; } From c8ca22a6e33131115915a26244bf6297a31765b3 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 02:07:08 +0100 Subject: [PATCH 20/36] Added an identifier property to MZPlugin --- Framework/src/MZPlugin+Private.m | 6 +++--- Framework/src/MZPlugin.h | 7 +++++++ Framework/src/MZPlugin.m | 5 +++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Framework/src/MZPlugin+Private.m b/Framework/src/MZPlugin+Private.m index 4c6cdfa1..215180c3 100644 --- a/Framework/src/MZPlugin+Private.m +++ b/Framework/src/MZPlugin+Private.m @@ -14,7 +14,7 @@ @implementation MZPlugin (Private) - (BOOL)isEnabled { NSArray* disabled = [[NSUserDefaults standardUserDefaults] arrayForKey:DISABLED_KEY]; - return ![disabled containsObject:[[self bundle] bundleIdentifier]]; + return ![disabled containsObject:self.identifier]; } - (void)setEnabled:(BOOL)enabled @@ -26,9 +26,9 @@ - (void)setEnabled:(BOOL)enabled else disabled = [NSMutableSet set]; if(enabled) - [disabled removeObject:[[self bundle] bundleIdentifier]]; + [disabled removeObject:self.identifier]; else - [disabled addObject:[[self bundle] bundleIdentifier]]; + [disabled addObject:self.identifier]; [[NSUserDefaults standardUserDefaults] setObject:[disabled allObjects] forKey:DISABLED_KEY]; } diff --git a/Framework/src/MZPlugin.h b/Framework/src/MZPlugin.h index c893aea4..d6db6466 100644 --- a/Framework/src/MZPlugin.h +++ b/Framework/src/MZPlugin.h @@ -25,6 +25,13 @@ */ @property(readonly) NSBundle* bundle; +/*! + @abstract The identifier for this plugin. + @discussion Defaults to the bundleIdentifier of the bundle + @see bundle bundle + */ +@property(readonly) NSString* identifier; + /*! * @name Loading and Unloading Plug-in Resources * @methodgroup Loading and Unloading Plug-in Resources diff --git a/Framework/src/MZPlugin.m b/Framework/src/MZPlugin.m index 9db83936..62fd5866 100644 --- a/Framework/src/MZPlugin.m +++ b/Framework/src/MZPlugin.m @@ -32,6 +32,11 @@ - (void)dealloc @synthesize bundle; +- (NSString *)identifier +{ + return [bundle bundleIdentifier]; +} + - (void)didLoad {} - (void)willUnload {} From 8c950b426e36496479c3168d5d9373e6cf3527f2 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 02:08:04 +0100 Subject: [PATCH 21/36] Removed whitespace --- App/src/AppController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/App/src/AppController.m b/App/src/AppController.m index fc0cc973..652274af 100644 --- a/App/src/AppController.m +++ b/App/src/AppController.m @@ -914,7 +914,7 @@ - (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { [window makeKeyAndOrderFront:sender]; - if([[MZMetaLoader sharedLoader] loadFromFiles: filenames]) + if([[MZMetaLoader sharedLoader] loadFromFiles:filenames]) [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; else [sender replyToOpenOrPrint:NSApplicationDelegateReplyCancel]; From d6c6bcf6e9fa6e2baa61ec1694e5d56dafb5d5e1 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 02:40:44 +0100 Subject: [PATCH 22/36] Added category to create NSError from apple script error dictionary --- Framework/src/MetaZKit.h | 1 + Framework/src/NSError+MZScriptError.h | 17 +++++++++++++++ Framework/src/NSError+MZScriptError.m | 30 +++++++++++++++++++++++++++ MetaZ.xcodeproj/project.pbxproj | 8 +++++++ 4 files changed, 56 insertions(+) create mode 100644 Framework/src/NSError+MZScriptError.h create mode 100644 Framework/src/NSError+MZScriptError.m diff --git a/Framework/src/MetaZKit.h b/Framework/src/MetaZKit.h index b05e9d51..3b78e703 100644 --- a/Framework/src/MetaZKit.h +++ b/Framework/src/MetaZKit.h @@ -41,6 +41,7 @@ #import #import #import +#import #import #import diff --git a/Framework/src/NSError+MZScriptError.h b/Framework/src/NSError+MZScriptError.h new file mode 100644 index 00000000..074556f8 --- /dev/null +++ b/Framework/src/NSError+MZScriptError.h @@ -0,0 +1,17 @@ +// +// NSError+MZScriptError.h +// MetaZ +// +// Created by Brian Olsen on 05/11/12. +// Copyright 2012 Maven-Group. All rights reserved. +// + +#import + + +@interface NSError (MZScriptError) + ++ (id)errorWithAppleScriptError:(NSDictionary *)errDict; +- (id)initWithAppleScriptError:(NSDictionary *)errDict; + +@end diff --git a/Framework/src/NSError+MZScriptError.m b/Framework/src/NSError+MZScriptError.m new file mode 100644 index 00000000..cbf40140 --- /dev/null +++ b/Framework/src/NSError+MZScriptError.m @@ -0,0 +1,30 @@ +// +// NSError+MZScriptError.m +// MetaZ +// +// Created by Brian Olsen on 05/11/12. +// Copyright 2012 Maven-Group. All rights reserved. +// + +#import "NSError+MZScriptError.h" + + +@implementation NSError (MZScriptError) + ++ (id)errorWithAppleScriptError:(NSDictionary *)errDict +{ + return [[[self alloc] errorWithAppleScriptError:errDict] autorelease]; +} + +- (id)initWithAppleScriptError:(NSDictionary *)errDict +{ + NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithDictionary:errDict]; + NSInteger code = [[errDict objectForKey:NSAppleScriptErrorNumber] integerValue]; + NSString* msg = [errDict objectForKey:NSAppleScriptErrorMessage]; + + if(msg) + [dict setObject:msg forKey:NSLocalizedDescriptionKey]; + return [self initWithDomain:@"NSAppleScriptError" code:code userInfo:dict]; +} + +@end diff --git a/MetaZ.xcodeproj/project.pbxproj b/MetaZ.xcodeproj/project.pbxproj index 762d25e1..99e8f516 100644 --- a/MetaZ.xcodeproj/project.pbxproj +++ b/MetaZ.xcodeproj/project.pbxproj @@ -220,6 +220,8 @@ 1BD3D3FE108E694100BE6943 /* faded_cow_error.png in Resources */ = {isa = PBXBuildFile; fileRef = 1BD3D3FB108E694100BE6943 /* faded_cow_error.png */; }; 1BD3D3FF108E694100BE6943 /* faded_cow_fatal.png in Resources */ = {isa = PBXBuildFile; fileRef = 1BD3D3FC108E694100BE6943 /* faded_cow_fatal.png */; }; 1BD3D400108E694100BE6943 /* faded_cow_multiple.png in Resources */ = {isa = PBXBuildFile; fileRef = 1BD3D3FD108E694100BE6943 /* faded_cow_multiple.png */; }; + 1BD55C661648466700F9C579 /* NSError+MZScriptError.h in Headers */ = {isa = PBXBuildFile; fileRef = 1BD55C641648466700F9C579 /* NSError+MZScriptError.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1BD55C671648466700F9C579 /* NSError+MZScriptError.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BD55C651648466700F9C579 /* NSError+MZScriptError.m */; }; 1BD6E752105DADCC00E40151 /* AddToQueue.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1BD6E74D105DADCC00E40151 /* AddToQueue.tiff */; }; 1BD6E753105DADCC00E40151 /* Pause.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1BD6E74E105DADCC00E40151 /* Pause.tiff */; }; 1BD6E754105DADCC00E40151 /* Play.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1BD6E74F105DADCC00E40151 /* Play.tiff */; }; @@ -1055,6 +1057,8 @@ 1BD3D3FB108E694100BE6943 /* faded_cow_error.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = faded_cow_error.png; path = App/resources/faded_cow_error.png; sourceTree = ""; }; 1BD3D3FC108E694100BE6943 /* faded_cow_fatal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = faded_cow_fatal.png; path = App/resources/faded_cow_fatal.png; sourceTree = ""; }; 1BD3D3FD108E694100BE6943 /* faded_cow_multiple.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = faded_cow_multiple.png; path = App/resources/faded_cow_multiple.png; sourceTree = ""; }; + 1BD55C641648466700F9C579 /* NSError+MZScriptError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSError+MZScriptError.h"; sourceTree = ""; }; + 1BD55C651648466700F9C579 /* NSError+MZScriptError.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSError+MZScriptError.m"; sourceTree = ""; }; 1BD6E601105B355800E40151 /* MetaChangeNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MetaChangeNotification.m; sourceTree = ""; }; 1BD6E74D105DADCC00E40151 /* AddToQueue.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = AddToQueue.tiff; path = App/resources/AddToQueue.tiff; sourceTree = ""; }; 1BD6E74E105DADCC00E40151 /* Pause.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Pause.tiff; path = App/resources/Pause.tiff; sourceTree = ""; }; @@ -1270,6 +1274,8 @@ 1BAC91BC13F060300022D625 /* NSString+MZAllInCharacterSet.m */, 1B0696D5149BFB2D00B5FA90 /* NSString+MZQueryString.h */, 1B0696D6149BFB2D00B5FA90 /* NSString+MZQueryString.m */, + 1BD55C641648466700F9C579 /* NSError+MZScriptError.h */, + 1BD55C651648466700F9C579 /* NSError+MZScriptError.m */, ); name = Classes; path = Framework/src; @@ -2314,6 +2320,7 @@ 1B36E78C14066727009F542A /* MZASISearch.h in Headers */, 1B0696D7149BFB2D00B5FA90 /* NSString+MZQueryString.h in Headers */, 1BDEC5ED1620DE160051D656 /* AEVTBuilder.h in Headers */, + 1BD55C661648466700F9C579 /* NSError+MZScriptError.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2865,6 +2872,7 @@ 1B36E78D14066727009F542A /* MZASISearch.m in Sources */, 1B0696D8149BFB2D00B5FA90 /* NSString+MZQueryString.m in Sources */, 1B4CFFE8161CE0ED00B12009 /* AEVTBuilder.m in Sources */, + 1BD55C671648466700F9C579 /* NSError+MZScriptError.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 5e9b1d439bf0cf1cca00d66cc62d1390e79889d1 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 02:42:08 +0100 Subject: [PATCH 23/36] Maded selectedDocuments always return an array --- App/src/MetaZApplication.m | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/App/src/MetaZApplication.m b/App/src/MetaZApplication.m index 61f1baeb..ce32f15d 100644 --- a/App/src/MetaZApplication.m +++ b/App/src/MetaZApplication.m @@ -52,21 +52,20 @@ - (void)setSelectedDocuments:(id)sel - (id)selectedDocuments; { - NSArray* sel = [filesController selectedObjects]; - if([sel count]==0) - return nil; - if([sel count]==1) - return [MZSelectedMetaDataDocument documentWithEdit:[sel objectAtIndex:0]]; - NSMutableArray* arr = [NSMutableArray array]; - for(MetaEdits* edit in sel) + for(MetaEdits* edit in [filesController selectedObjects]) [arr addObject:[MZSelectedMetaDataDocument documentWithEdit:edit]]; return arr; } - (id)selection; { - return [self selectedDocuments]; + NSArray* sel = [self selectedDocuments]; + if([sel count] == 0) + return nil; + if([sel count]==1) + return [sel objectAtIndex:0]; + return sel; } - (void)setSelection:(id)sel; From 62f12c9ffe0ff4bb79090d24e476a2ba4cccbece Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 02:49:00 +0100 Subject: [PATCH 24/36] Added support for apple script and action only plugins --- Framework/src/MZActionsPlugin.h | 39 +++++ Framework/src/MZActionsPlugin.m | 70 +++++++++ Framework/src/MZConstants.h | 6 + Framework/src/MZConstants.m | 6 + Framework/src/MZPluginController.m | 81 +++++++---- Framework/src/MZScriptActionsPlugin.h | 25 ++++ Framework/src/MZScriptActionsPlugin.m | 197 ++++++++++++++++++++++++++ Framework/src/MetaZKit.h | 2 + MetaZ.xcodeproj/project.pbxproj | 41 +++++- Plugins/Example Actions.applescript | 19 +++ 10 files changed, 459 insertions(+), 27 deletions(-) create mode 100644 Framework/src/MZActionsPlugin.h create mode 100644 Framework/src/MZActionsPlugin.m create mode 100644 Framework/src/MZScriptActionsPlugin.h create mode 100644 Framework/src/MZScriptActionsPlugin.m create mode 100644 Plugins/Example Actions.applescript diff --git a/Framework/src/MZActionsPlugin.h b/Framework/src/MZActionsPlugin.h new file mode 100644 index 00000000..5b7ee364 --- /dev/null +++ b/Framework/src/MZActionsPlugin.h @@ -0,0 +1,39 @@ +// +// MZActionsPlugin.h +// MetaZ +// +// Created by Brian Olsen on 05/11/12. +// Copyright 2012 Maven-Group. All rights reserved. +// + +#import +#import + +/*! @class MZActionsPlugin + @abstract Base class for plugins that only respond and take action on events + */ +@interface MZActionsPlugin : MZPlugin { +} + +/*! + @abstract Notifies your plug-in that it should register observers + environment. + @discussion You can override this method to register for any notifications + you might be interested in. This method is called as part of didLoad if it + is enabled and will also be called when this plugin is enabled. + @see didLoad didLoad + @see unregisterObservers unregisterObservers + */ +- (void)registerObservers; + +/*! + @abstract Notifies your plug-in that it should unregister observers + @discussion You can override this method to unregister for any notifications + you are setup to receive. This method is called from both willUnload and + dealloc as well as when this plugin is disabled. If you do override this + method, you must call super at some point in your implementation. + @see didLoad didLoad + */ +- (void)unregisterObservers; + +@end diff --git a/Framework/src/MZActionsPlugin.m b/Framework/src/MZActionsPlugin.m new file mode 100644 index 00000000..bc187494 --- /dev/null +++ b/Framework/src/MZActionsPlugin.m @@ -0,0 +1,70 @@ +// +// MZActionsPlugin.m +// MetaZ +// +// Created by Brian Olsen on 05/11/12. +// Copyright 2012 Maven-Group. All rights reserved. +// + +#import "MZActionsPlugin.h" +#import "MZPlugin+Private.h" + +#define ENABLED_ACTIONS_KEY @"enabledActionPlugins" + +@implementation MZActionsPlugin + +- (void)dealloc +{ + [self unregisterObservers]; + [super dealloc]; +} + +- (void)didLoad +{ + if([self isEnabled]) + [self registerObservers]; +} + +- (void)willUnload +{ + [self unregisterObservers]; +} + +- (BOOL)isEnabled +{ + NSArray* enabled = [[NSUserDefaults standardUserDefaults] arrayForKey:ENABLED_ACTIONS_KEY]; + return [enabled containsObject:self.identifier] && [super isEnabled]; +} + +- (void)setEnabled:(BOOL)enabledValue +{ + NSArray* enabledA = [[NSUserDefaults standardUserDefaults] arrayForKey:ENABLED_ACTIONS_KEY]; + NSMutableSet* enabled; + if(enabledA) + enabled = [NSMutableSet setWithArray:enabledA]; + else + enabled = [NSMutableSet set]; + + BOOL old = [enabled containsObject:self.identifier]; + + if(enabledValue) + [enabled removeObject:self.identifier]; + else + [enabled addObject:self.identifier]; + [[NSUserDefaults standardUserDefaults] setObject:[enabled allObjects] forKey:ENABLED_ACTIONS_KEY]; + + if(!old && enabledValue) + [self registerObservers]; + else if (old && !enabledValue) + [self unregisterObservers]; +} + +- (void)registerObservers {} + +- (void)unregisterObservers +{ + [[NSNotificationCenter defaultCenter] + removeObserver:self]; +} + +@end diff --git a/Framework/src/MZConstants.h b/Framework/src/MZConstants.h index ec35981e..2a5576c5 100644 --- a/Framework/src/MZConstants.h +++ b/Framework/src/MZConstants.h @@ -212,4 +212,10 @@ MZKIT_EXTERN NSString* const MZDataControllerErrorKey; // Standard alert ids MZKIT_EXTERN NSString* const MZDataProviderFileAlreadyLoadedWarningKey; +// Plugin UTI +MZKIT_EXTERN const CFStringRef kMZUTMetaZPlugin; +MZKIT_EXTERN const CFStringRef kMZUTMetaZActionsPlugin; +MZKIT_EXTERN const CFStringRef kMZUTAppleScriptText; +MZKIT_EXTERN const CFStringRef kMZUTAppleScript; + #endif // MZKIT_EXTERN diff --git a/Framework/src/MZConstants.m b/Framework/src/MZConstants.m index ef20e85e..80eb88dc 100644 --- a/Framework/src/MZConstants.m +++ b/Framework/src/MZConstants.m @@ -88,3 +88,9 @@ // Standard alert ids NSString* const MZDataProviderFileAlreadyLoadedWarningKey = @"alerts.warnings.fileAlreadyLoaded"; + +// Plugin UTI +const CFStringRef kMZUTMetaZPlugin = CFSTR("org.maven-group.MetaZ.plugin"); +const CFStringRef kMZUTMetaZActionsPlugin = CFSTR("org.maven-group.MetaZ.plugin.actions"); +const CFStringRef kMZUTAppleScriptText = CFSTR("com.apple.applescript.text"); +const CFStringRef kMZUTAppleScript = CFSTR("com.apple.applescript.script"); diff --git a/Framework/src/MZPluginController.m b/Framework/src/MZPluginController.m index d7209505..aa4fa383 100644 --- a/Framework/src/MZPluginController.m +++ b/Framework/src/MZPluginController.m @@ -9,6 +9,8 @@ #import #import #import +#import +#import #import "MZPlugin+Private.h" @interface MZWriteNotification : NSObject @@ -165,6 +167,7 @@ - (NSArray *)plugins NSFileManager* mgr = [NSFileManager manager]; for(NSString* path in paths) { + NSURL* pathURL = [NSURL fileURLWithPath:path]; BOOL isDir = NO; NSError* error = nil; if([mgr fileExistsAtPath:path isDirectory:&isDir] && isDir) @@ -178,11 +181,24 @@ - (NSArray *)plugins for(NSString* pluginDir in pluginPaths) { NSString* pluginPath = [path stringByAppendingPathComponent:pluginDir]; - NSBundle* plugin = [NSBundle bundleWithPath:pluginPath]; - if(plugin) + CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (CFStringRef)[pluginPath pathExtension], NULL); + MZLoggerDebug(@"Loading plugin at path '%@'", pluginPath); + if(UTTypeConformsTo(uti, kMZUTMetaZPlugin)) + { + NSBundle* plugin = [NSBundle bundleWithPath:pluginPath]; + if(plugin) + [thePlugins addObject:plugin]; + else + MZLoggerError(@"Failed to load plugin at path '%@'", pluginPath); + } + else if(UTTypeEqual(uti, kMZUTAppleScriptText) || UTTypeConformsTo(uti, kMZUTAppleScriptText) || + UTTypeEqual(uti, kMZUTAppleScript) || UTTypeConformsTo(uti, kMZUTAppleScript)) + { + NSURL* url = [NSURL URLWithString:[pluginDir gtm_stringByEscapingForURLArgument] relativeToURL:pathURL]; + MZScriptActionsPlugin* plugin = [MZScriptActionsPlugin pluginWithURL:url]; [thePlugins addObject:plugin]; - else - MZLoggerError(@"Failed to load plugin at path '%@'", pluginPath); + } + CFRelease(uti); } } } @@ -199,42 +215,59 @@ - (NSArray *)loadedPlugins loadedPlugins = [[NSMutableArray alloc] init]; NSMutableSet* loadedBundles = [NSMutableSet set]; NSArray* thePlugins = [self plugins]; - for(NSBundle* bundle in thePlugins) + for(id source in thePlugins) { + NSString* identifier; + if([source isKindOfClass:[NSBundle class]]) + identifier = [source bundleIdentifier]; + else if([source isKindOfClass:[MZScriptActionsPlugin class]]) + identifier = [source identifier]; + else + MZLoggerError(@"Unknown plugin %@ of type %@", source, NSStringFromClass([source class])); + // the plugins are in the order they should be loaded // so if the same identifier is allready loaded we can skib to // next - if([loadedBundles containsObject:[bundle bundleIdentifier]]) + if([loadedBundles containsObject:identifier]) continue; + MZPlugin* plugin; NSError* error = nil; - if(![bundle loadAndReturnError:&error]) + if(![source loadAndReturnError:&error]) { MZLoggerError(@"Failed to load code for '%@' because: %@", - [bundle bundleIdentifier], + identifier, [error localizedDescription]); continue; } - Class cls = [bundle principalClass]; - if(cls == Nil) - { - MZLoggerError(@"Error loading principal class for '%@'", - [bundle bundleIdentifier]); - continue; - } - MZPlugin* plugin = [[cls alloc] init]; - if(!plugin) + + if([source isKindOfClass:[NSBundle class]]) { - MZLoggerError(@"Failed to create principal class '%@' for '%@'", - NSStringFromClass(cls), - [bundle bundleIdentifier]); - [bundle unload]; - continue; + Class cls = [source principalClass]; + if(cls == Nil) + { + MZLoggerError(@"Error loading principal class for '%@'", + identifier); + continue; + } + + plugin = [[cls alloc] init]; + if(!plugin) + { + MZLoggerError(@"Failed to create principal class '%@' for '%@'", + NSStringFromClass(cls), + identifier); + [source unload]; + continue; + } } - [loadedBundles addObject:[bundle bundleIdentifier]]; + else + plugin = [source retain]; + + [loadedBundles addObject:identifier]; [loadedPlugins addObject:plugin]; [plugin release]; - MZLoggerInfo(@"Loaded plugin '%@'", [bundle bundleIdentifier]); + MZLoggerInfo(@"Loaded plugin '%@'", identifier); [plugin didLoad]; if([[self delegate] respondsToSelector:@selector(pluginController:loadedPlugin:)]) [[self delegate] pluginController:self loadedPlugin:plugin]; diff --git a/Framework/src/MZScriptActionsPlugin.h b/Framework/src/MZScriptActionsPlugin.h new file mode 100644 index 00000000..8a191de2 --- /dev/null +++ b/Framework/src/MZScriptActionsPlugin.h @@ -0,0 +1,25 @@ +// +// MZScriptActionsPlugin.h +// MetaZ +// +// Created by Brian Olsen on 05/11/12. +// Copyright 2012 Maven-Group. All rights reserved. +// + +#import +#import + +@interface MZScriptActionsPlugin : MZActionsPlugin { + NSString* identifier; + NSURL* url; + NSAppleScript* script; +} +@property(readonly) NSURL* url; +@property(readonly) NSAppleScript* script; + ++ (id)pluginWithURL:(NSURL *)url; +- (id)initWithURL:(NSURL *)url; +- (NSString *)label; +- (BOOL)loadAndReturnError:(NSError **)error; + +@end diff --git a/Framework/src/MZScriptActionsPlugin.m b/Framework/src/MZScriptActionsPlugin.m new file mode 100644 index 00000000..850850c1 --- /dev/null +++ b/Framework/src/MZScriptActionsPlugin.m @@ -0,0 +1,197 @@ +// +// MZScriptActionsPlugin.m +// MetaZ +// +// Created by Brian Olsen on 05/11/12. +// Copyright 2012 Maven-Group. All rights reserved. +// + +#import +#import "MZScriptActionsPlugin.h" +#import "NSError+MZScriptError.h" +#import "AEVTBuilder.h" +#import "MetaEdits.h" +#import "MZLogger.h" +#import "MZPlugin+Private.h" + +#define MZQueueStarted @"MZQueueStarted" +#define MZQueueCompletedPercent @"MZQueueCompletedPercent" +#define MZQueueItemCompleted @"MZQueueItemCompleted" +#define MZQueueItemFailed @"MZQueueItemFailed" +#define MZQueueCompleted @"MZQueueCompleted" + +@implementation MZScriptActionsPlugin + ++ (id)pluginWithURL:(NSURL *)url; +{ + return [[[self alloc] initWithURL:url] autorelease]; +} + +- (id)initWithURL:(NSURL *)theURL; +{ + self = [super init]; + if(self) + { + url = [theURL retain]; + identifier = [[[[url path] lastPathComponent] stringByDeletingPathExtension] retain]; + } + return self; +} + +- (void)dealloc +{ + [url release]; + [identifier release]; + [script release]; + [super dealloc]; +} + +@synthesize url; +@synthesize script; + +- (NSString *)identifier +{ + return identifier; +} + +- (NSString *)label +{ + return self.identifier; +} + +- (NSString *)preferencesNibName +{ + return @"ScriptActionsPluginView"; +} + +- (BOOL)isBuiltIn +{ + NSURL* urlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] builtInPlugInsPath]]; + BOOL ret = [[url baseURL] isEqualTo:urlPath]; + return ret; +} + +- (BOOL)loadAndReturnError:(NSError **)error +{ + if(!script) + { + NSDictionary* errDict = nil; + script = [[NSAppleScript alloc] initWithContentsOfURL:self.url error:&errDict]; + if(!script || ![script compileAndReturnError:&errDict]) + { + if(errDict && error) + *error = [NSError errorWithAppleScriptError:errDict]; + return NO; + } + } + return YES; +} + +- (void)registerObservers +{ + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(queueStarted:) + name:MZQueueStarted + object:nil]; + + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(queueItemCompleted:) + name:MZQueueItemCompleted + object:nil]; + + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(queueItemFailed:) + name:MZQueueItemFailed + object:nil]; + + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(queueCompleted:) + name:MZQueueCompleted + object:nil]; +} + +- (void)executeEvent:(NSAppleEventDescriptor *)event +{ + NSDictionary* errDict = nil; + NSAppleEventDescriptor* ret = [script executeAppleEvent:event error:&errDict]; + if(!ret) + { + NSInteger code = [[errDict objectForKey:NSAppleScriptErrorNumber] integerValue]; + NSString* msg = [errDict objectForKey:NSAppleScriptErrorMessage]; + NSString* app = [errDict objectForKey:NSAppleScriptErrorAppName]; + if(code != -1708 || msg || app) + MZLoggerError(@"Notification failed %@ %d %@", app, code, msg); + } +} + +- (void)queueStarted:(NSNotification *)note +{ + ProcessSerialNumber psn = {0, kCurrentProcess}; + NSAppleEventDescriptor* event = [AEVT class:kASAppleScriptSuite id:kASSubroutineEvent target:psn, + [KEY : keyASSubroutineName], + [STRING : @"queue_started"], + nil + ]; + [self executeEvent:event]; +} + +- (void)queueItemCompleted:(NSNotification *)note +{ + MetaEdits* edits = [[note userInfo] objectForKey:MZMetaEditsNotificationKey]; + NSString* displayName = [[[edits loadedFileName] lastPathComponent] stringByDeletingPathExtension]; + NSScriptClassDescription *containerClassDesc = (NSScriptClassDescription *) + [NSScriptClassDescription classDescriptionForClass:[NSApplication class]];// 1 + NSScriptObjectSpecifier* spec = [[[NSNameSpecifier alloc] + initWithContainerClassDescription:containerClassDesc + containerSpecifier:nil key:@"queueDocuments" + name:displayName] autorelease]; + + ProcessSerialNumber psn = {0, kCurrentProcess}; + NSAppleEventDescriptor* event = [AEVT class:kASAppleScriptSuite id:kASSubroutineEvent target:psn, + [KEY : keyASSubroutineName], + [STRING : @"queue_completed"], + [KEY : keyASPrepositionOn], + [spec descriptor], + nil + ]; + [self executeEvent:event]; +} + +- (void)queueItemFailed:(NSNotification *)note +{ + MetaEdits* edits = [[note userInfo] objectForKey:MZMetaEditsNotificationKey]; + NSString* displayName = [[[edits loadedFileName] lastPathComponent] stringByDeletingPathExtension]; + NSScriptClassDescription *containerClassDesc = (NSScriptClassDescription *) + [NSScriptClassDescription classDescriptionForClass:[NSApplication class]];// 1 + NSScriptObjectSpecifier* spec = [[[NSNameSpecifier alloc] + initWithContainerClassDescription:containerClassDesc + containerSpecifier:nil key:@"queueDocuments" + name:displayName] autorelease]; + + ProcessSerialNumber psn = {0, kCurrentProcess}; + NSAppleEventDescriptor* event = [AEVT class:kASAppleScriptSuite id:kASSubroutineEvent target:psn, + [KEY : keyASSubroutineName], + [STRING : @"queue_failed"], + [KEY : keyASPrepositionOn], + [spec descriptor], + nil + ]; + [self executeEvent:event]; +} + +- (void)queueCompleted:(NSNotification *)note +{ + ProcessSerialNumber psn = {0, kCurrentProcess}; + NSAppleEventDescriptor* event = [AEVT class:kASAppleScriptSuite id:kASSubroutineEvent target:psn, + [KEY : keyASSubroutineName], + [STRING : @"queue_finished"], + nil + ]; + [self executeEvent:event]; +} + +@end diff --git a/Framework/src/MetaZKit.h b/Framework/src/MetaZKit.h index 3b78e703..106d8e8d 100644 --- a/Framework/src/MetaZKit.h +++ b/Framework/src/MetaZKit.h @@ -18,6 +18,8 @@ #import #import #import +#import +#import #import #import #import diff --git a/MetaZ.xcodeproj/project.pbxproj b/MetaZ.xcodeproj/project.pbxproj index 99e8f516..b797e3a6 100644 --- a/MetaZ.xcodeproj/project.pbxproj +++ b/MetaZ.xcodeproj/project.pbxproj @@ -220,6 +220,10 @@ 1BD3D3FE108E694100BE6943 /* faded_cow_error.png in Resources */ = {isa = PBXBuildFile; fileRef = 1BD3D3FB108E694100BE6943 /* faded_cow_error.png */; }; 1BD3D3FF108E694100BE6943 /* faded_cow_fatal.png in Resources */ = {isa = PBXBuildFile; fileRef = 1BD3D3FC108E694100BE6943 /* faded_cow_fatal.png */; }; 1BD3D400108E694100BE6943 /* faded_cow_multiple.png in Resources */ = {isa = PBXBuildFile; fileRef = 1BD3D3FD108E694100BE6943 /* faded_cow_multiple.png */; }; + 1BD55C5E16483F5E00F9C579 /* MZActionsPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1BD55C5C16483F5E00F9C579 /* MZActionsPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1BD55C5F16483F5E00F9C579 /* MZActionsPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BD55C5D16483F5E00F9C579 /* MZActionsPlugin.m */; }; + 1BD55C621648431D00F9C579 /* MZScriptActionsPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1BD55C601648431D00F9C579 /* MZScriptActionsPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1BD55C631648431D00F9C579 /* MZScriptActionsPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BD55C611648431D00F9C579 /* MZScriptActionsPlugin.m */; }; 1BD55C661648466700F9C579 /* NSError+MZScriptError.h in Headers */ = {isa = PBXBuildFile; fileRef = 1BD55C641648466700F9C579 /* NSError+MZScriptError.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1BD55C671648466700F9C579 /* NSError+MZScriptError.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BD55C651648466700F9C579 /* NSError+MZScriptError.m */; }; 1BD6E752105DADCC00E40151 /* AddToQueue.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 1BD6E74D105DADCC00E40151 /* AddToQueue.tiff */; }; @@ -943,6 +947,7 @@ 1B5AC76E10532E5200F9CE36 /* MetaEditPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MetaEditPanel.m; sourceTree = ""; }; 1B63A1D11644D8D100461FC9 /* MZArrayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZArrayController.h; sourceTree = ""; }; 1B63A1D21644D8D100461FC9 /* MZArrayController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MZArrayController.m; sourceTree = ""; }; + 1B63A889164823FE00461FC9 /* Example Actions.applescript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.applescript; path = "Example Actions.applescript"; sourceTree = ""; }; 1B6E43C610845F8200DFE165 /* TCSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TCSearch.h; sourceTree = ""; }; 1B6E43C710845F8200DFE165 /* TCSearch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TCSearch.m; sourceTree = ""; }; 1B6E43C9108468B100DFE165 /* MZSearchResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZSearchResult.h; sourceTree = ""; }; @@ -1057,6 +1062,10 @@ 1BD3D3FB108E694100BE6943 /* faded_cow_error.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = faded_cow_error.png; path = App/resources/faded_cow_error.png; sourceTree = ""; }; 1BD3D3FC108E694100BE6943 /* faded_cow_fatal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = faded_cow_fatal.png; path = App/resources/faded_cow_fatal.png; sourceTree = ""; }; 1BD3D3FD108E694100BE6943 /* faded_cow_multiple.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = faded_cow_multiple.png; path = App/resources/faded_cow_multiple.png; sourceTree = ""; }; + 1BD55C5C16483F5E00F9C579 /* MZActionsPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZActionsPlugin.h; sourceTree = ""; }; + 1BD55C5D16483F5E00F9C579 /* MZActionsPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MZActionsPlugin.m; sourceTree = ""; }; + 1BD55C601648431D00F9C579 /* MZScriptActionsPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZScriptActionsPlugin.h; sourceTree = ""; }; + 1BD55C611648431D00F9C579 /* MZScriptActionsPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MZScriptActionsPlugin.m; sourceTree = ""; }; 1BD55C641648466700F9C579 /* NSError+MZScriptError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSError+MZScriptError.h"; sourceTree = ""; }; 1BD55C651648466700F9C579 /* NSError+MZScriptError.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSError+MZScriptError.m"; sourceTree = ""; }; 1BD6E601105B355800E40151 /* MetaChangeNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MetaChangeNotification.m; sourceTree = ""; }; @@ -1230,6 +1239,10 @@ 1BEA6E49106EEF34004B1A7F /* MZPlugin+Private.m */, 1BEA6DAC106EC632004B1A7F /* MZPluginController.h */, 1BEA6DAD106EC632004B1A7F /* MZPluginController.m */, + 1BD55C5C16483F5E00F9C579 /* MZActionsPlugin.h */, + 1BD55C5D16483F5E00F9C579 /* MZActionsPlugin.m */, + 1BD55C601648431D00F9C579 /* MZScriptActionsPlugin.h */, + 1BD55C611648431D00F9C579 /* MZScriptActionsPlugin.m */, 1BBB39A71087083600C9E17F /* MZPriorObserverFix.h */, 1BBB39A81087083600C9E17F /* MZPriorObserverFix.m */, 1B3AD7A111055DF300B33F85 /* MZQueueOperation.h */, @@ -2129,6 +2142,7 @@ 1BEA6E68106EF248004B1A7F /* Plugins */ = { isa = PBXGroup; children = ( + 1B63A889164823FE00461FC9 /* Example Actions.applescript */, 1B8CB8FA14ACD5C700F859F7 /* TheMovieDb */, 1B4F538D116E9E1F003221B1 /* TheTVDB */, 1B42F23B10DEB05000AFEBF6 /* IMDB */, @@ -2320,6 +2334,8 @@ 1B36E78C14066727009F542A /* MZASISearch.h in Headers */, 1B0696D7149BFB2D00B5FA90 /* NSString+MZQueryString.h in Headers */, 1BDEC5ED1620DE160051D656 /* AEVTBuilder.h in Headers */, + 1BD55C5E16483F5E00F9C579 /* MZActionsPlugin.h in Headers */, + 1BD55C621648431D00F9C579 /* MZScriptActionsPlugin.h in Headers */, 1BD55C661648466700F9C579 /* NSError+MZScriptError.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2483,14 +2499,15 @@ isa = PBXNativeTarget; buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "MetaZ" */; buildPhases = ( - 1BEA6F2F106EF6D5004B1A7F /* Copy Plugins */, - 1BB6C11E1052B199001D3D1D /* Copy Frameworks */, 8D1107290486CEB800E47090 /* Resources */, + 1BB6C11E1052B199001D3D1D /* Copy Frameworks */, + 1BEA6F2F106EF6D5004B1A7F /* Copy Plugins */, + 1B29A05A14C5C5B40048B7C0 /* Copy Growl frameworks */, + 1B74B569164826980017E013 /* Compile Plugin Scripts */, 8D11072C0486CEB800E47090 /* Sources */, 8D11072E0486CEB800E47090 /* Frameworks */, 1B8262A710B39DE400DF101B /* Make Disk Image */, 1BB6BF3B1050ED38001D3D1D /* Sparkle Sign */, - 1B29A05A14C5C5B40048B7C0 /* Copy Growl frameworks */, ); buildRules = ( ); @@ -2705,6 +2722,22 @@ shellPath = /bin/sh; shellScript = "set -o errexit\n\nPATH=$PATH:/usr/local/bin:/usr/bin:/sw/bin:/opt/local/bin\nbuildid=`git log -n1 --pretty=oneline --format=%h`\nrelease=`cat $SCRIPT_INPUT_FILE_0`\nbuilddate=`date +%y.%m.%d.%H`\n\necho \"#define BUILDID $buildid\" > $SCRIPT_OUTPUT_FILE_0\necho \"#define BUILDDATE $builddate\" >> $SCRIPT_OUTPUT_FILE_0\necho \"#define BUILDVERSION $builddate.$buildid\" >> $SCRIPT_OUTPUT_FILE_0\necho \"#define WHOAMI `whoami`\" >> $SCRIPT_OUTPUT_FILE_0\necho \"#define RELEASE $release\" >> $SCRIPT_OUTPUT_FILE_0 \ncat $SCRIPT_INPUT_FILE_1 >> $SCRIPT_OUTPUT_FILE_0 \n\n# Delete the intermediate Info.plist so that Xcode re-preprocesses the Info.plist with our updated macros.\n# Use -f because after a clean build, this file doesn't exist yet, so a plain rm would fail and stop the build.\nrm -f \"${CONFIGURATION_TEMP_DIR}/MetaZ.build/Preprocessed-Info.plist\"\n"; }; + 1B74B569164826980017E013 /* Compile Plugin Scripts */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(SRCROOT)/Plugins/*.applescript", + ); + name = "Compile Plugin Scripts"; + outputPaths = ( + "$BUILT_PRODUCTS_DIR/$PLUGINS_FOLDER_PATH/*.scpt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cd \"$PROJECT_DIR\"\nfor k in Plugins/*.applescript ; do\n BASE=`basename \"$k\" .applescript`\n\n $OSAC -l AppleScript -i \"$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME\" -d -o \"$BUILT_PRODUCTS_DIR/$PLUGINS_FOLDER_PATH/$BASE.scpt\" \"$k\"\ndone"; + }; 1B8262A710B39DE400DF101B /* Make Disk Image */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -2872,6 +2905,8 @@ 1B36E78D14066727009F542A /* MZASISearch.m in Sources */, 1B0696D8149BFB2D00B5FA90 /* NSString+MZQueryString.m in Sources */, 1B4CFFE8161CE0ED00B12009 /* AEVTBuilder.m in Sources */, + 1BD55C5F16483F5E00F9C579 /* MZActionsPlugin.m in Sources */, + 1BD55C631648431D00F9C579 /* MZScriptActionsPlugin.m in Sources */, 1BD55C671648466700F9C579 /* NSError+MZScriptError.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Plugins/Example Actions.applescript b/Plugins/Example Actions.applescript new file mode 100644 index 00000000..ea8f1232 --- /dev/null +++ b/Plugins/Example Actions.applescript @@ -0,0 +1,19 @@ +on queue_started() + display dialog "Wheee Started" +end queue_started + +on queue_writing on the_document + display dialog "Wheee Writing " & (name of the_document) +end queue_writing + +on queue_completed on the_document + display dialog "Wheee Item Completed " & (name of the_document) +end queue_completed + +on queue_failed on the_document + display dialog "Wheee Item Failed " & (name of the_document) +end queue_failed + +on queue_finished() + display dialog "Wheee Finished" +end queue_finished From 0639a3c643bb9175a11a70462896d5c16ead15eb Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 03:45:16 +0100 Subject: [PATCH 25/36] Added support for receiving drag and drop and pasting from iTunes as well as refreshing iTunes metadata after write --- App/Info.plist | 47 ++++++++ App/resources/FactorySettings.plist | 4 + .../Return iTunes selected.applescript | 1 + App/src/AppController.m | 98 ++++++++++++++++ App/src/FilesTableView.m | 111 ++++++++++++++++-- Framework/src/MZConstants.h | 3 + Framework/src/MZConstants.m | 3 + MetaZ.xcodeproj/project.pbxproj | 6 + Plugins/Update iTunes.applescript | 20 ++++ Update iTunes.scpt | Bin 1942 -> 0 bytes 10 files changed, 283 insertions(+), 10 deletions(-) create mode 100644 App/resources/Return iTunes selected.applescript create mode 100644 Plugins/Update iTunes.applescript delete mode 100644 Update iTunes.scpt diff --git a/App/Info.plist b/App/Info.plist index ed26ee1c..4deeb7bc 100644 --- a/App/Info.plist +++ b/App/Info.plist @@ -160,10 +160,57 @@ MetaZ.sdef NSPrincipalClass MetaZApplication + NSServices + + + NSMessage + doiTunesMetadata + NSSendTypes + + org.liscio.itun + com.apple.itunes.metadata + + NSMenuItem + + default + Open in MetaZ + + + + NSMessage + doiTunes + NSRequiredContext + + NSApplicationIdentifier + com.apple.iTunes + + NSMenuItem + + default + Open selected tracks in MetaZ + + + SUEnableAutomaticChecks YES SUFeedURL http://maven-group.org/metaz/appcast.xml + UTImportedTypeDeclarations + + + UTTypeConformsTo + + public.data + + UTTypeIdentifier + org.liscio.itun + UTTypeTagSpecification + + com.apple.ostype + itun + + + SUEnableSystemProfiling YES SUPublicDSAKeyFile diff --git a/App/resources/FactorySettings.plist b/App/resources/FactorySettings.plist index aab23d49..fda50751 100644 --- a/App/resources/FactorySettings.plist +++ b/App/resources/FactorySettings.plist @@ -32,5 +32,9 @@ 1 autoSearch + enabledActionPlugins + + Update iTunes + diff --git a/App/resources/Return iTunes selected.applescript b/App/resources/Return iTunes selected.applescript new file mode 100644 index 00000000..47e0d734 --- /dev/null +++ b/App/resources/Return iTunes selected.applescript @@ -0,0 +1 @@ +tell application "iTunes" set sel to selection set ret to {} set retRef to a reference to ret set len to length of sel repeat with n from 1 to len set obj to item n of sel set i to {mylocation:location of obj, myid:persistent ID of obj} copy i to the end of retRef end repeat end tell return ret \ No newline at end of file diff --git a/App/src/AppController.m b/App/src/AppController.m index 652274af..6bdee702 100644 --- a/App/src/AppController.m +++ b/App/src/AppController.m @@ -16,6 +16,7 @@ #import "FilesTableView.h" #import "Resources.h" #import "MZMetaDataDocument.h" +#import "MZScriptingAdditions.h" #define MaxShortDescription 256 @@ -922,6 +923,8 @@ - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames - (void)applicationWillFinishLaunching:(NSNotification *)notification; { + [NSApp setServicesProvider:self]; + // Load scriptability early to allow sdef open handler to override default AppKit handler. [NSScriptSuiteRegistry sharedScriptSuiteRegistry]; } @@ -976,4 +979,99 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende return NSTerminateCancel; } +-(void)doiTunesMetadata:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error { + NSDictionary* prop = [pboard propertyListForType:iTunesMetadataPboardType]; + if(!prop) + prop = [pboard propertyListForType:iTunesPboardType]; + + if(prop) + { + NSMutableArray* names = [NSMutableArray array]; + NSMutableArray* dataDicts = [NSMutableArray array]; + NSDictionary* tracks = [prop objectForKey:@"Tracks"]; + for(id track in [tracks allValues]) + { + NSURL* location = [NSURL URLWithString:[track objectForKey:@"Location"]]; + [names addObject:[location path]]; + + NSString* persistentId = [track objectForKey:@"Persistent ID"]; + NSDictionary* data = [NSDictionary dictionaryWithObject:persistentId forKey:MZiTunesPersistentIDTagIdent]; + [dataDicts addObject:data]; + } + [[MZMetaLoader sharedLoader] loadFromFiles:names withMetaData:dataDicts]; + } +} + +-(void)doiTunes:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error { + NSString* path = [[NSBundle mainBundle] pathForResource:@"Return iTunes selected" ofType:@"scpt"]; + NSURL* url = [NSURL fileURLWithPath:path]; + NSDictionary* errDict = nil; + NSAppleScript* script = [[[NSAppleScript alloc] initWithContentsOfURL:url error:&errDict] autorelease]; + if(errDict) + { + NSError* err = [NSError errorWithAppleScriptError:errDict]; + if(error) + *error = [err localizedDescription]; + GTMLoggerError(@"Error loading script %d %d", path, [err localizedDescription]); + return; + } + if(script) + { + NSAppleEventDescriptor* ret = [script executeAndReturnError:&errDict]; + if(!ret) + { + NSError* err = [NSError errorWithAppleScriptError:errDict]; + if(error) + *error = [err localizedDescription]; + GTMLoggerError(@"Error running script %d %d", path, [err localizedDescription]); + } + else + { + id obj = [ret objectValue]; + if([obj isKindOfClass:[NSArray class]]) + { + NSMutableArray* names = [NSMutableArray array]; + NSMutableArray* dataDicts = nil; + for(id o in obj) + { + if([o isKindOfClass:[NSString class]]) + { + [names addObject:o]; + } + else if([o isKindOfClass:[NSDictionary class]]) + { + [names addObject:[o objectForKey:@"mylocation"]]; + if(!dataDicts) + dataDicts = [NSMutableArray array]; + [dataDicts addObject:[NSDictionary dictionaryWithObject:[o objectForKey:@"myid"] forKey:MZiTunesPersistentIDTagIdent]]; + } + else + { + NSString* err = [NSString stringWithFormat:@"Unsupported return type %@", o]; + if(error) + *error = err; + else + GTMLoggerError(@"Selection array: %@", err); + return; + } + } + [[MZMetaLoader sharedLoader] loadFromFiles:names withMetaData:dataDicts]; + } + else if([obj isKindOfClass:[NSString class]]) + [[MZMetaLoader sharedLoader] loadFromFile:obj]; + else if([obj isKindOfClass:[NSDictionary class]]) + [[MZMetaLoader sharedLoader] loadFromFile:[obj objectForKey:@"mylocation"] + withMetaData:[NSDictionary dictionaryWithObject:[obj objectForKey:@"myid"] + forKey:MZiTunesPersistentIDTagIdent]]; + else { + NSString* err = [NSString stringWithFormat:@"Unsupported return type %@", obj]; + if(error) + *error = err; + else + GTMLoggerError(@"Selection: %@", err); + } + } + } +} + @end diff --git a/App/src/FilesTableView.m b/App/src/FilesTableView.m index b8da66a8..a4592cbf 100644 --- a/App/src/FilesTableView.m +++ b/App/src/FilesTableView.m @@ -46,7 +46,8 @@ - (id)initWithFrame:(NSRect)frame { [self registerForDraggedTypes: [NSArray arrayWithObjects:MZFilesTableRows, - MZMetaEditsDataType, NSFilenamesPboardType, + MZMetaEditsDataType, iTunesMetadataPboardType, + iTunesPboardType, NSFilenamesPboardType, NSStringPboardType, nil] ]; } return self; @@ -59,7 +60,8 @@ - (id)initWithCoder:(NSCoder*)decoder { [self registerForDraggedTypes: [NSArray arrayWithObjects:MZFilesTableRows, - MZMetaEditsDataType, NSFilenamesPboardType, + MZMetaEditsDataType, iTunesMetadataPboardType, + iTunesPboardType, NSFilenamesPboardType, NSStringPboardType, nil] ]; } return self; @@ -106,7 +108,8 @@ -(IBAction)paste:(id)sender { NSPasteboard *pb = [NSPasteboard generalPasteboard]; NSArray *types = [NSArray arrayWithObjects:MZMetaEditsDataType, - NSFilenamesPboardType, NSStringPboardType, nil]; + iTunesMetadataPboardType, iTunesPboardType, NSFilenamesPboardType, + NSStringPboardType, nil]; NSString *bestType = [pb availableTypeFromArray:types]; if (bestType != nil) { @@ -137,6 +140,29 @@ -(IBAction)paste:(id)sender for(MetaEdits* edit in edits) [self registerUndoName:edit.undoManager]; } + if([bestType isEqualToString:iTunesMetadataPboardType] || [bestType isEqualToString:iTunesMetadataPboardType]) + { + NSDictionary* prop = [pb propertyListForType:iTunesMetadataPboardType]; + if(!prop) + prop = [pb propertyListForType:iTunesPboardType]; + + if(prop) + { + NSMutableArray* names = [NSMutableArray array]; + NSMutableArray* dataDicts = [NSMutableArray array]; + NSDictionary* tracks = [prop objectForKey:@"Tracks"]; + for(id track in [tracks allValues]) + { + NSURL* location = [NSURL URLWithString:[track objectForKey:@"Location"]]; + [names addObject:[location path]]; + + NSString* persistentId = [track objectForKey:@"Persistent ID"]; + NSDictionary* data = [NSDictionary dictionaryWithObject:persistentId forKey:MZiTunesPersistentIDTagIdent]; + [dataDicts addObject:data]; + } + [[MZMetaLoader sharedLoader] loadFromFiles:names withMetaData:dataDicts]; + } + } if([bestType isEqualToString:NSFilenamesPboardType]) { NSArray* filenames = [pb propertyListForType:NSFilenamesPboardType]; @@ -157,7 +183,8 @@ -(IBAction)paste:(id)sender - (BOOL)pasteboardHasTypes { NSPasteboard *pb = [NSPasteboard generalPasteboard]; NSArray *types = [NSArray arrayWithObjects:MZMetaEditsDataType, - NSFilenamesPboardType, NSStringPboardType, nil]; + iTunesMetadataPboardType, iTunesPboardType, NSFilenamesPboardType, + NSStringPboardType, nil]; NSString *bestType = [pb availableTypeFromArray:types]; if(bestType != nil && [bestType isEqualToString:MZMetaEditsDataType]) return [self numberOfSelectedRows] > 0; @@ -179,6 +206,26 @@ - (BOOL)pasteboardHasTypes { return NO; } } + if(bestType != nil && ([bestType isEqualToString:iTunesMetadataPboardType] || + [bestType isEqualToString:iTunesPboardType])) + { + NSDictionary* prop = [pboard propertyListForType:iTunesMetadataPboardType]; + if(!prop) + prop = [pboard propertyListForType:iTunesPboardType]; + + if(prop) + { + NSDictionary* tracks = [prop objectForKey:@"Tracks"]; + for(id track in [tracks allValues]) + { + NSURL* location = [NSURL URLWithString:[track objectForKey:@"Location"]]; + if(![[MZPluginController sharedInstance] dataProviderForPath:[location path]]) + return NO; + } + return YES; + } + return NO; + } return bestType != nil; } @@ -283,7 +330,6 @@ - (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexe return YES; } - - (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id )info proposedRow:(NSInteger)row @@ -294,8 +340,8 @@ - (NSDragOperation)tableView:(NSTableView*)tv NSPasteboard* pboard = [info draggingPasteboard]; NSArray *types = [NSArray arrayWithObjects:MZFilesTableRows, - MZMetaEditsDataType, NSFilenamesPboardType, - NSStringPboardType, nil]; + MZMetaEditsDataType, iTunesMetadataPboardType, iTunesPboardType, + NSFilenamesPboardType, NSStringPboardType, nil]; //NSDragOperation operation = [info draggingSourceOperationMask]; NSString *bestType = [pboard availableTypeFromArray:types]; if(bestType != nil) @@ -323,6 +369,11 @@ - (NSDragOperation)tableView:(NSTableView*)tv } return NSDragOperationGeneric; } + if([bestType isEqualToString:iTunesMetadataPboardType] || + [bestType isEqualToString:iTunesPboardType]) + { + return NSDragOperationGeneric; + } return NSDragOperationMove; } return NSDragOperationNone; @@ -333,8 +384,8 @@ - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id )info { NSPasteboard* pboard = [info draggingPasteboard]; NSArray *types = [NSArray arrayWithObjects:MZFilesTableRows, - MZMetaEditsDataType, NSFilenamesPboardType, - NSStringPboardType, nil]; + MZMetaEditsDataType, iTunesMetadataPboardType, iTunesPboardType, + NSFilenamesPboardType, NSStringPboardType, nil]; NSString *bestType = [pboard availableTypeFromArray:types]; if (bestType != nil) { @@ -347,6 +398,29 @@ - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id )info [[MZMetaLoader sharedLoader] moveObjects:edits toIndex:row]; return YES; } + if([bestType isEqualToString:iTunesMetadataPboardType] || [bestType isEqualToString:iTunesMetadataPboardType]) + { + NSDictionary* prop = [pboard propertyListForType:iTunesMetadataPboardType]; + if(!prop) + prop = [pboard propertyListForType:iTunesPboardType]; + + if(prop) + { + NSDictionary* tracks = [prop objectForKey:@"Tracks"]; + for(id track in [tracks allValues]) + { + NSURL* location = [NSURL URLWithString:[track objectForKey:@"Location"]]; + if(![[MZPluginController sharedInstance] dataProviderForPath:[location path]]) + return NO; + } + if(![filesController commitEditing]) + return NO; + NSArray* params = [NSArray arrayWithObjects:prop, [NSNumber numberWithInteger:row], nil]; + [self performSelector:@selector(loadFiles:) withObject:params afterDelay:1]; + return YES; + } + return NO; + } if([bestType isEqualToString:NSFilenamesPboardType]) { NSArray* filenames = [pboard propertyListForType:NSFilenamesPboardType]; @@ -385,7 +459,24 @@ - (void)loadFiles:(NSArray *)params { id first = [params objectAtIndex:0]; NSInteger row = [[params objectAtIndex:1] integerValue]; - if([first isKindOfClass:[NSArray class]]) + + if([first isKindOfClass:[NSDictionary class]]) + { + NSMutableArray* names = [NSMutableArray array]; + NSMutableArray* dataDicts = [NSMutableArray array]; + NSDictionary* tracks = [first objectForKey:@"Tracks"]; + for(id track in [tracks allValues]) + { + NSURL* location = [NSURL URLWithString:[track objectForKey:@"Location"]]; + [names addObject:[location path]]; + + NSString* persistentId = [track objectForKey:@"Persistent ID"]; + NSDictionary* data = [NSDictionary dictionaryWithObject:persistentId forKey:MZiTunesPersistentIDTagIdent]; + [dataDicts addObject:data]; + } + [[MZMetaLoader sharedLoader] loadFromFiles:names toIndex:row withMetaData:dataDicts]; + } + else if([first isKindOfClass:[NSArray class]]) [[MZMetaLoader sharedLoader] loadFromFiles:first toIndex:row]; else [[MZMetaLoader sharedLoader] loadFromFile:first toIndex:row]; diff --git a/Framework/src/MZConstants.h b/Framework/src/MZConstants.h index 2a5576c5..025bec49 100644 --- a/Framework/src/MZConstants.h +++ b/Framework/src/MZConstants.h @@ -212,6 +212,9 @@ MZKIT_EXTERN NSString* const MZDataControllerErrorKey; // Standard alert ids MZKIT_EXTERN NSString* const MZDataProviderFileAlreadyLoadedWarningKey; +MZKIT_EXTERN NSString* const iTunesMetadataPboardType; +MZKIT_EXTERN NSString* const iTunesPboardType; + // Plugin UTI MZKIT_EXTERN const CFStringRef kMZUTMetaZPlugin; MZKIT_EXTERN const CFStringRef kMZUTMetaZActionsPlugin; diff --git a/Framework/src/MZConstants.m b/Framework/src/MZConstants.m index 80eb88dc..e9b2d948 100644 --- a/Framework/src/MZConstants.m +++ b/Framework/src/MZConstants.m @@ -89,6 +89,9 @@ // Standard alert ids NSString* const MZDataProviderFileAlreadyLoadedWarningKey = @"alerts.warnings.fileAlreadyLoaded"; +NSString* const iTunesMetadataPboardType = @"com.apple.itunes.metadata"; +NSString* const iTunesPboardType = @"CorePasteboardFlavorType 0x6974756E"; + // Plugin UTI const CFStringRef kMZUTMetaZPlugin = CFSTR("org.maven-group.MetaZ.plugin"); const CFStringRef kMZUTMetaZActionsPlugin = CFSTR("org.maven-group.MetaZ.plugin.actions"); diff --git a/MetaZ.xcodeproj/project.pbxproj b/MetaZ.xcodeproj/project.pbxproj index b797e3a6..c93f0365 100644 --- a/MetaZ.xcodeproj/project.pbxproj +++ b/MetaZ.xcodeproj/project.pbxproj @@ -220,6 +220,7 @@ 1BD3D3FE108E694100BE6943 /* faded_cow_error.png in Resources */ = {isa = PBXBuildFile; fileRef = 1BD3D3FB108E694100BE6943 /* faded_cow_error.png */; }; 1BD3D3FF108E694100BE6943 /* faded_cow_fatal.png in Resources */ = {isa = PBXBuildFile; fileRef = 1BD3D3FC108E694100BE6943 /* faded_cow_fatal.png */; }; 1BD3D400108E694100BE6943 /* faded_cow_multiple.png in Resources */ = {isa = PBXBuildFile; fileRef = 1BD3D3FD108E694100BE6943 /* faded_cow_multiple.png */; }; + 1BD55BED16482D7600F9C579 /* Return iTunes selected.applescript in Sources */ = {isa = PBXBuildFile; fileRef = 1B63A36616458A1C00461FC9 /* Return iTunes selected.applescript */; }; 1BD55C5E16483F5E00F9C579 /* MZActionsPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1BD55C5C16483F5E00F9C579 /* MZActionsPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1BD55C5F16483F5E00F9C579 /* MZActionsPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BD55C5D16483F5E00F9C579 /* MZActionsPlugin.m */; }; 1BD55C621648431D00F9C579 /* MZScriptActionsPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 1BD55C601648431D00F9C579 /* MZScriptActionsPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -947,6 +948,7 @@ 1B5AC76E10532E5200F9CE36 /* MetaEditPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MetaEditPanel.m; sourceTree = ""; }; 1B63A1D11644D8D100461FC9 /* MZArrayController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MZArrayController.h; sourceTree = ""; }; 1B63A1D21644D8D100461FC9 /* MZArrayController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MZArrayController.m; sourceTree = ""; }; + 1B63A36616458A1C00461FC9 /* Return iTunes selected.applescript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.applescript; name = "Return iTunes selected.applescript"; path = "App/resources/Return iTunes selected.applescript"; sourceTree = ""; }; 1B63A889164823FE00461FC9 /* Example Actions.applescript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.applescript; path = "Example Actions.applescript"; sourceTree = ""; }; 1B6E43C610845F8200DFE165 /* TCSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TCSearch.h; sourceTree = ""; }; 1B6E43C710845F8200DFE165 /* TCSearch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TCSearch.m; sourceTree = ""; }; @@ -1068,6 +1070,7 @@ 1BD55C611648431D00F9C579 /* MZScriptActionsPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MZScriptActionsPlugin.m; sourceTree = ""; }; 1BD55C641648466700F9C579 /* NSError+MZScriptError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSError+MZScriptError.h"; sourceTree = ""; }; 1BD55C651648466700F9C579 /* NSError+MZScriptError.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSError+MZScriptError.m"; sourceTree = ""; }; + 1BD55D4516485AE700F9C579 /* Update iTunes.applescript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.applescript; path = "Update iTunes.applescript"; sourceTree = ""; }; 1BD6E601105B355800E40151 /* MetaChangeNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MetaChangeNotification.m; sourceTree = ""; }; 1BD6E74D105DADCC00E40151 /* AddToQueue.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = AddToQueue.tiff; path = App/resources/AddToQueue.tiff; sourceTree = ""; }; 1BD6E74E105DADCC00E40151 /* Pause.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Pause.tiff; path = App/resources/Pause.tiff; sourceTree = ""; }; @@ -2143,6 +2146,7 @@ isa = PBXGroup; children = ( 1B63A889164823FE00461FC9 /* Example Actions.applescript */, + 1BD55D4516485AE700F9C579 /* Update iTunes.applescript */, 1B8CB8FA14ACD5C700F859F7 /* TheMovieDb */, 1B4F538D116E9E1F003221B1 /* TheTVDB */, 1B42F23B10DEB05000AFEBF6 /* IMDB */, @@ -2217,6 +2221,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 1B63A36616458A1C00461FC9 /* Return iTunes selected.applescript */, 1B8CB5DF14AA31C500F859F7 /* modified_header.tiff */, 1B8CB5E014AA31C500F859F7 /* modified_selected.tiff */, 1B8CB5E114AA31C500F859F7 /* modified.tiff */, @@ -2978,6 +2983,7 @@ 1B89073116420437008C5C8B /* MZScriptingEnums.m in Sources */, 1B8908E416424790008C5C8B /* MZSelectedMetaDataDocument.m in Sources */, 1B63A1D31644D8D100461FC9 /* MZArrayController.m in Sources */, + 1BD55BED16482D7600F9C579 /* Return iTunes selected.applescript in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Plugins/Update iTunes.applescript b/Plugins/Update iTunes.applescript new file mode 100644 index 00000000..5086ec8d --- /dev/null +++ b/Plugins/Update iTunes.applescript @@ -0,0 +1,20 @@ +on queue_completed on the_document + tell application "MetaZ" + set myid to content of tag "iTunes persistent ID" of the_document + set loc to file of the_document + end tell + if myid is not missing value then + tell application "iTunes" + set trk to missing value + try + set trk to first track whose persistent ID is equal to myid + on error errMsg number errNum + -- your error handler code goes here + end try + if trk is not missing value then + set location of trk to loc + refresh trk + end if + end tell + end if +end queue_completed \ No newline at end of file diff --git a/Update iTunes.scpt b/Update iTunes.scpt deleted file mode 100644 index 3eb5c98090b8f0d96d31f1b081216f329393b488..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1942 zcmb_dO-xi*6#m`=VR&!u3#@?J@1_J zj(NG!)BVHYSVt_XM*u)^Py`li6j@}T$XgTK*H5vHVxH_ki6SXVk_RFvl{fNQp%nIz z5sScwGDTt(i?JV$4Tr)m{EEcRYFm_72q^7g(yVtN7(fu#G|EFLM;M>r5C+hTn4w)< zA4MOc=*JP#7`0)gjYr5US6;yvMe*eM#3<;?&k;g}A~F7as757rDiXWL0?~cIw@Q)N z-Mpj^e)$L04oR^SAIVNADi~xATv;oUHCPH&us^1-!cNqnR*_gSA_$;dUOMuUs+m*A zhZSnqk%dqxFI;(1fK01yp?>blbCgC=l+QB8HYzxFp-zz)&^6eN53yU3*m3%)K^^MR zphyffVn8^+P%&tGLfC^9CZ$o)2mI*Q^xuPca9iD z8FI&IU*pYlWO z+Yz+GPOVn~gVL!;Oinh_`~ycG=zyF^#}&VkG1G)*x$nyTw|VEMTR%#&W4Wnhp0JqC ztvaKkA(ok+ao2e?#hl99@=&*gvh_QIuwy~Qte<=v{{P2mJe{6^Z9zv)r&uVGuUc2FF1*jsnl4m!^>p0NxkQ?>bsvWPhXnblomcfS$K23 zG5h;7nPejFtjy;QUxO(wh<`=sT`ODKk{6^klvjZ*=|K39QhYOVt7XS{h%{WZ; z5e7YFg5SZU&+rYhG5B%Plz=XUJWD3WVhLlAy|Dt-g(f=-OtR})ozQo%yi;>&=lHJknX|%Jpqk?Z`E)#%c@60$OJ)&@wmh`%q+lqI2Q%#kMa# q`=u{7@W;@drRIS@hpsF)4_qI*^6N_5vC}~>7tb Date: Tue, 6 Nov 2012 09:52:22 +0100 Subject: [PATCH 26/36] Fixed enabling of actions plugins --- Framework/src/MZActionsPlugin.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/src/MZActionsPlugin.m b/Framework/src/MZActionsPlugin.m index bc187494..d66dc608 100644 --- a/Framework/src/MZActionsPlugin.m +++ b/Framework/src/MZActionsPlugin.m @@ -48,9 +48,9 @@ - (void)setEnabled:(BOOL)enabledValue BOOL old = [enabled containsObject:self.identifier]; if(enabledValue) - [enabled removeObject:self.identifier]; - else [enabled addObject:self.identifier]; + else + [enabled removeObject:self.identifier]; [[NSUserDefaults standardUserDefaults] setObject:[enabled allObjects] forKey:ENABLED_ACTIONS_KEY]; if(!old && enabledValue) From f10a578e8b5e8be0d8b9dba2a39ece7417f9825f Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 09:52:49 +0100 Subject: [PATCH 27/36] Fixed wrong variable name --- App/src/FilesTableView.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/App/src/FilesTableView.m b/App/src/FilesTableView.m index a4592cbf..9d8eee67 100644 --- a/App/src/FilesTableView.m +++ b/App/src/FilesTableView.m @@ -209,9 +209,9 @@ - (BOOL)pasteboardHasTypes { if(bestType != nil && ([bestType isEqualToString:iTunesMetadataPboardType] || [bestType isEqualToString:iTunesPboardType])) { - NSDictionary* prop = [pboard propertyListForType:iTunesMetadataPboardType]; + NSDictionary* prop = [pb propertyListForType:iTunesMetadataPboardType]; if(!prop) - prop = [pboard propertyListForType:iTunesPboardType]; + prop = [pb propertyListForType:iTunesPboardType]; if(prop) { From 997d0f2789e652a486b2a21c04b15f478a906c8e Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 09:54:24 +0100 Subject: [PATCH 28/36] Changed queue so status is stopping until notifications have been sent --- App/src/MZWriteQueue.m | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/App/src/MZWriteQueue.m b/App/src/MZWriteQueue.m index 75b26ba2..d3f34edf 100644 --- a/App/src/MZWriteQueue.m +++ b/App/src/MZWriteQueue.m @@ -100,7 +100,7 @@ -(void)start } } --(void)stop +-(BOOL)doStopToStopping:(BOOL)stopping { if(status != QueueStopped && status != QueueStopping ) { @@ -112,19 +112,28 @@ -(void)stop if([sts stopWriting]) stopWaitCount++; } - if(stopWaitCount==0) + if(stopWaitCount == 0) { - status = QueueStopped; + if(!stopping) + status = QueueStopped; for(MZWriteQueueStatus* sts in queueItems) { if(sts.hasRun && !sts.completed) sts.hasRun = NO; } - [self saveQueueWithError:NULL]; } + [self saveQueueWithError:NULL]; [self resetTrashHandling]; [self didChangeValueForKey:@"status"]; + if(stopWaitCount == 0) + return YES; } + return NO; +} + +-(void)stop +{ + [self doStopToStopping:NO]; } - (BOOL)hasNextItem @@ -151,11 +160,17 @@ - (void)startNextItem return; } } - [self stop]; + BOOL stopping = [self doStopToStopping:YES]; [self saveQueueWithError:NULL]; [[NSNotificationCenter defaultCenter] postNotificationName:MZQueueCompleted object:self]; + if(stopping) + { + [self willChangeValueForKey:@"status"]; + status = QueueStopped; + [self didChangeValueForKey:@"status"]; + } } - (void)itemStopped From 32eacb4d39f25563a533b4dade761b92b9b5eb1d Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 09:55:28 +0100 Subject: [PATCH 29/36] Prevented app from quitting while queue is stopping --- App/src/AppController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/App/src/AppController.m b/App/src/AppController.m index 6bdee702..69f65b67 100644 --- a/App/src/AppController.m +++ b/App/src/AppController.m @@ -968,7 +968,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende if( result == NSAlertDefaultReturn ) { - if([[MZWriteQueue sharedQueue] status] == QueueRunning) + if([[MZWriteQueue sharedQueue] status] == QueueRunning || [[MZWriteQueue sharedQueue] status] == QueueStopping) { [[MZWriteQueue sharedQueue] gtm_addObserver:self forKeyPath:@"status" selector:@selector(queueStatusChanged:) userInfo:nil options:0]; [[MZWriteQueue sharedQueue] stop]; From 342e0d60fbaf6283749765ad2410a0ddb9471142 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 09:56:59 +0100 Subject: [PATCH 30/36] Moved enabled property in MZPlugin from private to public API --- Framework/src/MZPlugin+Private.h | 2 -- Framework/src/MZPlugin+Private.m | 21 --------------------- Framework/src/MZPlugin.h | 4 ++++ Framework/src/MZPlugin.m | 27 +++++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Framework/src/MZPlugin+Private.h b/Framework/src/MZPlugin+Private.h index 2a942a87..eb63f8b8 100644 --- a/Framework/src/MZPlugin+Private.h +++ b/Framework/src/MZPlugin+Private.h @@ -12,8 +12,6 @@ #define DISABLED_KEY @"disabledPlugins" @interface MZPlugin (Private) -@property(getter=isEnabled) BOOL enabled; - - (BOOL)isBuiltIn; - (BOOL)canUnload; @end diff --git a/Framework/src/MZPlugin+Private.m b/Framework/src/MZPlugin+Private.m index 215180c3..2f84db88 100644 --- a/Framework/src/MZPlugin+Private.m +++ b/Framework/src/MZPlugin+Private.m @@ -11,27 +11,6 @@ @implementation MZPlugin (Private) -- (BOOL)isEnabled -{ - NSArray* disabled = [[NSUserDefaults standardUserDefaults] arrayForKey:DISABLED_KEY]; - return ![disabled containsObject:self.identifier]; -} - -- (void)setEnabled:(BOOL)enabled -{ - NSArray* disabledA = [[NSUserDefaults standardUserDefaults] arrayForKey:DISABLED_KEY]; - NSMutableSet* disabled; - if(disabledA) - disabled = [NSMutableSet setWithArray:disabledA]; - else - disabled = [NSMutableSet set]; - if(enabled) - [disabled removeObject:self.identifier]; - else - [disabled addObject:self.identifier]; - [[NSUserDefaults standardUserDefaults] setObject:[disabled allObjects] forKey:DISABLED_KEY]; -} - - (BOOL)isBuiltIn { return NO; diff --git a/Framework/src/MZPlugin.h b/Framework/src/MZPlugin.h index d6db6466..63df0a09 100644 --- a/Framework/src/MZPlugin.h +++ b/Framework/src/MZPlugin.h @@ -32,6 +32,10 @@ */ @property(readonly) NSString* identifier; +@property(getter=isEnabled) BOOL enabled; + +- (BOOL)canEnable; + /*! * @name Loading and Unloading Plug-in Resources * @methodgroup Loading and Unloading Plug-in Resources diff --git a/Framework/src/MZPlugin.m b/Framework/src/MZPlugin.m index 62fd5866..aa48bef4 100644 --- a/Framework/src/MZPlugin.m +++ b/Framework/src/MZPlugin.m @@ -8,6 +8,7 @@ #import +#define DISABLED_KEY @"disabledPlugins" @implementation MZPlugin @@ -37,6 +38,32 @@ - (NSString *)identifier return [bundle bundleIdentifier]; } +- (BOOL)isEnabled +{ + NSArray* disabled = [[NSUserDefaults standardUserDefaults] arrayForKey:DISABLED_KEY]; + return ![disabled containsObject:self.identifier]; +} + +- (void)setEnabled:(BOOL)enabled +{ + NSArray* disabledA = [[NSUserDefaults standardUserDefaults] arrayForKey:DISABLED_KEY]; + NSMutableSet* disabled; + if(disabledA) + disabled = [NSMutableSet setWithArray:disabledA]; + else + disabled = [NSMutableSet set]; + if(enabled) + [disabled removeObject:self.identifier]; + else + [disabled addObject:self.identifier]; + [[NSUserDefaults standardUserDefaults] setObject:[disabled allObjects] forKey:DISABLED_KEY]; +} + +- (BOOL)canEnable; +{ + return YES; +} + - (void)didLoad {} - (void)willUnload {} From cffa0420909a8d4b4f3c839a0e6a446278abefd3 Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 09:58:03 +0100 Subject: [PATCH 31/36] Fixed plugin label prepending a whitespace when class name is only one word --- Framework/src/MZPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/src/MZPlugin.m b/Framework/src/MZPlugin.m index aa48bef4..3a713e28 100644 --- a/Framework/src/MZPlugin.m +++ b/Framework/src/MZPlugin.m @@ -103,7 +103,7 @@ - (NSString *)label range:NSMakeRange(max, length-max)]; } sub = [className substringWithRange:NSMakeRange(oldloc, length-oldloc)]; - if(sub.length > 1) + if(sub.length > 1 && ret.length > 0) [ret appendString:@" "]; [ret appendString:sub]; return [NSString stringWithString:ret]; From 2bc9f5cbb0af0510d68a497367fed7e681e1a9bc Mon Sep 17 00:00:00 2001 From: Brian Olsen Date: Tue, 6 Nov 2012 09:58:37 +0100 Subject: [PATCH 32/36] Added a delayed quit to scripting dictionary --- App/resources/MetaZ.sdef | 5 +++++ App/src/MetaZApplication.m | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/App/resources/MetaZ.sdef b/App/resources/MetaZ.sdef index 0be104b6..b32fc5b0 100644 --- a/App/resources/MetaZ.sdef +++ b/App/resources/MetaZ.sdef @@ -72,6 +72,8 @@ --> + +