Skip to content

Commit

Permalink
Add patch to workaround itunes 7.7.1 changed track format when using …
Browse files Browse the repository at this point in the history
…persistentId
  • Loading branch information
alastairtse committed Aug 2, 2008
1 parent 903db98 commit 726d682
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,3 +1,7 @@
03 Aug 08; Alastair Tse <alastair@liquidx.net>
* Workaround changed track descriptor returned from iTunes 7.7.1.
Thanks to Simon Haertel for the patch.

06 Jul 07; EyeTunes-1.3.3; Alastair Tse <alastair@liquidx.net>
* Fix persistentID support AGAIN for iTunes 7.3 as they reverted their
previous changes. Patch thanks to Andy Kim of Potion Factory.
Expand Down
21 changes: 14 additions & 7 deletions ETTrack.m
Expand Up @@ -47,6 +47,13 @@ @implementation ETTrack

- (id) initWithDescriptor:(AEDesc *)desc
{
// iTunes 7.7.1 returns a list with one track item rather than the track directly.
if (desc->descriptorType == typeAEList) {
AEDesc trackDesc;
if (noErr == AEGetNthDesc((AEDescList*)desc, 1, typeWildCard, NULL, &trackDesc)) {
desc = &trackDesc;
}
}
self = [super initWithDescriptor:desc applCode:ET_APPLE_EVENT_OBJECT_DEFAULT_APPL];
return self;
}
Expand Down Expand Up @@ -93,8 +100,8 @@ - (BOOL)setArtwork:(NSImage *)artwork atIndex:(int)index
}

err = AEBuildDesc(&pictDesc, NULL, "'PICT'(@)",
[pictData length],
[pictData bytes]);
[pictData length],
[pictData bytes]);

if (err != noErr) {
ETLog(@"Error with constructing PICT: %d", err);
Expand All @@ -104,9 +111,9 @@ - (BOOL)setArtwork:(NSImage *)artwork atIndex:(int)index
/* execute send command */
BOOL success = NO;
success = [self setProperty:ET_ARTWORK_PROP_DATA
OfElementOfClass:ET_CLASS_ARTWORK
OfElementOfClass:ET_CLASS_ARTWORK
atIndex:index
withValue:&pictDesc];
withValue:&pictDesc];
AEDisposeDesc(&pictDesc);

return success;
Expand All @@ -126,7 +133,7 @@ - (NSArray *)artwork
NSMutableArray *artworkArray = [NSMutableArray array];
int i;
DescType resultType;
Size resultSize;
Size resultSize;

/* count the number of artworks */
int elementCount = [self getCountOfElementsOfClass:ET_CLASS_ARTWORK];
Expand Down Expand Up @@ -374,7 +381,7 @@ - (long long int) persistentId

if ([[EyeTunes sharedInstance] versionGreaterThan:ITUNES_7_2_1] ||
[[EyeTunes sharedInstance] versionLessThan:ITUNES_7_2])
return [self getPropertyAsLongIntegerForDesc:ET_ITEM_PROP_PERSISTENT_ID];
return [self getPropertyAsLongIntegerForDesc:ET_ITEM_PROP_PERSISTENT_ID];
else {
NSString *persistentId = [NSString stringWithFormat:@"0x%@",[self getPropertyAsStringForDesc:ET_ITEM_PROP_PERSISTENT_ID]];
return [persistentId longlongValue];
Expand All @@ -386,7 +393,7 @@ - (NSString *) persistentIdAsString
// Trying a different way of doing version comparison:
//
// - The newer versions are checked for first because it's most likely that the user is running
// the latest version of iTunes
// the latest version of iTunes
//
// - Direct integer comparison is used for efficiency and to make reading the code easier
//
Expand Down
8 changes: 5 additions & 3 deletions EyeTunes.xcodeproj/project.pbxproj
Expand Up @@ -97,7 +97,7 @@
035B70B70885537800D0B89E /* ETTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ETTrack.h; sourceTree = "<group>"; };
035B70B80885537800D0B89E /* ETTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ETTrack.m; sourceTree = "<group>"; };
03748E7A099D8AD4002F09C3 /* EyeTunesDebug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EyeTunesDebug.app; sourceTree = BUILT_PRODUCTS_DIR; };
03748E7C099D8AD4002F09C3 /* EyeTunesDebug-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "EyeTunesDebug-Info.plist"; sourceTree = "<group>"; };
03748E7C099D8AD4002F09C3 /* EyeTunesDebug-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "EyeTunesDebug-Info.plist"; sourceTree = "<group>"; };
03749077099D8B48002F09C3 /* debug_main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = debug_main.m; sourceTree = "<group>"; };
03749090099D8BEB002F09C3 /* MainMenu.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; path = MainMenu.nib; sourceTree = "<group>"; };
0374909A099D8CDE002F09C3 /* DebugController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebugController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -350,10 +350,12 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 031B4820088429A70086F24B /* Build configuration list for PBXProject "EyeTunes" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 0867D691FE84028FC02AAC07 /* EyeTunes */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
8DC2EF4F0486A6940098B216 /* EyeTunes */,
031B484508843C940086F24B /* TestEyeTunes */,
Expand Down Expand Up @@ -530,12 +532,12 @@
COPY_PHASE_STRIP = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
GCC_PREPROCESSOR_DEFINITIONS = "";
INSTALL_PATH = /usr/local/bin;
KEEP_PRIVATE_EXTERNS = YES;
OPTIMIZATION_CFLAGS = "-O0";
OTHER_CFLAGS = "";
OTHER_LDFLAGS = (
"-framework",
Expand All @@ -561,11 +563,11 @@
COPY_PHASE_STRIP = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
GCC_PREPROCESSOR_DEFINITIONS = "";
INSTALL_PATH = /usr/local/bin;
OPTIMIZATION_CFLAGS = "-O0";
OTHER_CFLAGS = "";
OTHER_LDFLAGS = (
"-framework",
Expand Down
14 changes: 8 additions & 6 deletions main.m
Expand Up @@ -87,6 +87,8 @@ void test_track_persistent_id(EyeTunes *e) {
while (t = [iter nextObject]) {
long long int persistentId = [t persistentId];
NSLog(@"Track Persistent ID (%016llX): %@", persistentId, [t name]);
ETTrack *testTrack = [e trackWithPersistentId:persistentId];
NSLog(@"Track: %@", [testTrack name]);
}
}

Expand Down Expand Up @@ -158,15 +160,15 @@ int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
EyeTunes *e = [EyeTunes sharedInstance];

//test_get_playlists(e);
//test_get_track(e);
//test_get_tracks_by_search(e);
//test_get_selected(e);
test_get_playlists(e);
test_get_track(e);
test_get_tracks_by_search(e);
test_get_selected(e);
//test_dupe_selected_image(e);
//test_set_track_details(e);
//test_playlist_persistent_id(e);
test_playlist_persistent_id(e);
//test_select_playlist_by_persistent_id(e);
//test_track_persistent_id(e);
test_track_persistent_id(e);

//rename_chinese_tracks(e);

Expand Down

0 comments on commit 726d682

Please sign in to comment.