Permalink
Browse files

fixed addTrack when no playlist is specified

  • Loading branch information...
1 parent d5d5638 commit 2383515783134bcfc25c682cd645d585a3af8352 Kaspars committed May 2, 2011
Showing with 34 additions and 27 deletions.
  1. +34 −27 ETEyeTunes.m
View
@@ -479,55 +479,62 @@ - (id)addTrack:(NSURL *)fromLocation toPlaylist:(ETPlaylist *)playlist;
NSMutableArray *trackList = nil;
AliasHandle alias = [EyeTunes newAliasHandleWithPath:[fromLocation path]];
+
+ AEBuildError buildError;
- if (!playlist)
- {
- gizmo = @"'----':@@";
- }
- else
- {
+ if (!playlist) {
+ gizmo = @"'----':alis(@@)";
+ err = AEBuildAppleEvent(iTunesSignature, // class
+ ET_ADD_FILE, // ID
+ typeApplSignature, // address type
+ &iTunesSignature, // address data
+ sizeof(iTunesSignature), // address length
+ kAutoGenerateReturnID, // return ID
+ kAnyTransactionID, //transaction ID
+ &getEvent, // result
+ &buildError, // error
+ [gizmo UTF8String], // params format
+ alias);
+ } else {
gizmo = [NSString stringWithFormat:@"'----':alis(@@), insh:(@)"];
+ err = AEBuildAppleEvent(iTunesSignature, // class
+ ET_ADD_FILE, // ID
+ typeApplSignature, // address type
+ &iTunesSignature, // address data
+ sizeof(iTunesSignature), // address length
+ kAutoGenerateReturnID, // return ID
+ kAnyTransactionID, //transaction ID
+ &getEvent, // result
+ &buildError, // error
+ [gizmo UTF8String], // params format
+ alias, // ... (var args)
+ [playlist descriptor]);
}
- AEBuildError buildError;
-
- err = AEBuildAppleEvent(iTunesSignature, // class
- ET_ADD_FILE, // ID
- typeApplSignature, // address type
- &iTunesSignature, // address data
- sizeof(iTunesSignature), // address length
- kAutoGenerateReturnID, // return ID
- kAnyTransactionID, //transaction ID
- &getEvent, // result
- &buildError, // error
- [gizmo UTF8String], // params format
- alias, // ... (var args)
- [playlist descriptor]);
-
DisposeHandle((Handle)alias);
- if (err != noErr) {
- ETLog(@"Error creating Apple Event: %d", err);
+ if (err != noErr) {
+ ETLog(@"Error creating AppleEvent: %d | %s | %s", err, GetMacOSStatusErrorString(err), GetMacOSStatusCommentString(err));
return nil;
}
err = AESendMessage(&getEvent, &replyEvent, kAEWaitReply + kAENeverInteract, kAEDefaultTimeout);
if (err != noErr) {
- ETLog(@"Error sending AppleEvent: %d", err);
+ ETLog(@"Error sending AppleEvent: %d | %s | %s", err, GetMacOSStatusErrorString(err), GetMacOSStatusCommentString(err));
goto cleanup_get_event;
}
/* Read Results */
err = AEGetParamDesc(&replyEvent, keyDirectObject, typeAEList, &replyList);
if (err != noErr) {
- ETLog(@"Error extracting from reply event: %d", err);
+ ETLog(@"Error extracting from reply event: %d | %s | %s", err, GetMacOSStatusErrorString(err), GetMacOSStatusCommentString(err));
goto cleanup_reply_event;
}
long items, i;
err = AECountItems(&replyList, &items);
if (err != noErr) {
- ETLog(@"Unable to access Reply List: %d", err);
+ ETLog(@"Unable to access Reply List: %d | %s | %s", err, GetMacOSStatusErrorString(err), GetMacOSStatusCommentString(err));
goto cleanup_reply_list;
}
@@ -540,7 +547,7 @@ - (id)addTrack:(NSURL *)fromLocation toPlaylist:(ETPlaylist *)playlist;
0,
&trackDesc);
if (err != noErr) {
- ETLog(@"Error rextracting from List: %d", err);
+ ETLog(@"Error rextracting from List: %d | %s | %s", err, GetMacOSStatusErrorString(err), GetMacOSStatusCommentString(err));
goto cleanup_reply_list;
}
[trackList addObject:[[[ETTrack alloc] initWithDescriptor:&trackDesc] autorelease]];

0 comments on commit 2383515

Please sign in to comment.