Removed Audioscrobbler NSLog debug
[MenuTunes.git] / iTunesRemote.m
index b5365b2..dbd21fb 100755 (executable)
                                                newParent = test;
                                        }
                                }
                                                newParent = test;
                                        }
                                }
+                               [[[nextNode parent] children] removeObject:nextNode];
                                [nextNode setParent:newParent];
                                [[newParent children] addObject:nextNode];
                                [newParent setType:ITMTFolderNode];
                                [nextNode setParent:newParent];
                                [[newParent children] addObject:nextNode];
                                [newParent setType:ITMTFolderNode];
                NSEnumerator *nestEnumerator = [nested objectEnumerator];
                while ( (nextNode = [nestEnumerator nextObject]) ) {
                        [[sourceNode children] removeObject:nextNode];
                NSEnumerator *nestEnumerator = [nested objectEnumerator];
                while ( (nextNode = [nestEnumerator nextObject]) ) {
                        [[sourceNode children] removeObject:nextNode];
+                       [nested removeObject:nextNode];
                }
                [nested release];
                
                }
                [nested release];
                
                enumerator = [[sourceNode children] reverseObjectEnumerator];
                while ( (nextNode = [enumerator nextObject]) ) {
                        if ([nextNode type] == ITMTPodcastsNode) {
                enumerator = [[sourceNode children] reverseObjectEnumerator];
                while ( (nextNode = [enumerator nextObject]) ) {
                        if ([nextNode type] == ITMTPodcastsNode) {
-                               [nextNode retain];
                                [[sourceNode children] removeObject:nextNode];
                                [[sourceNode children] insertObject:nextNode atIndex:1];
                                movedPodcasts = YES;
                        } else if ([nextNode type] == ITMTFolderNode) {
                                [[sourceNode children] removeObject:nextNode];
                                [[sourceNode children] insertObject:nextNode atIndex:1];
                                movedPodcasts = YES;
                        } else if ([nextNode type] == ITMTFolderNode) {
-                               [nextNode retain];
                                [[sourceNode children] removeObject:nextNode];
                                [[sourceNode children] insertObject:nextNode atIndex:1 + movedPodcasts];
                        }
                                [[sourceNode children] removeObject:nextNode];
                                [[sourceNode children] insertObject:nextNode atIndex:1 + movedPodcasts];
                        }
 
 - (NSArray *)artists
 {
 
 - (NSArray *)artists
 {
-    NSAppleEventDescriptor *rawr = ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pArt'), from:obj { form:'indx', want:type('cTrk'), seld:abso($616C6C20$), from:obj { form:'indx', want:type('cPly'), seld:long(1), from:obj { form:'indx', want:type('cSrc'), seld:long(1), from:() } } } }", 'core', 'getd', &savedPSN);
+    NSAppleEventDescriptor *rawr = ITSendAEWithStringAndTimeout(@"'----':obj { form:'prop', want:type('prop'), seld:type('pArt'), from:obj { form:'indx', want:type('cTrk'), seld:abso($616C6C20$), from:obj { form:'indx', want:type('cPly'), seld:long(1), from:obj { form:'indx', want:type('cSrc'), seld:long(1), from:() } } } }", 'core', 'getd', &savedPSN, 600);
     int i;
     NSMutableArray *array = [[NSMutableArray alloc] init];
     NSArray *returnArray;
     int i;
     NSMutableArray *array = [[NSMutableArray alloc] init];
     NSArray *returnArray;
 
 - (NSArray *)albums
 {
 
 - (NSArray *)albums
 {
-    NSAppleEventDescriptor *rawr = ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pAlb'), from:obj { form:'indx', want:type('cTrk'), seld:abso($616C6C20$), from:obj { form:'indx', want:type('cPly'), seld:long(1), from:obj { form:'indx', want:type('cSrc'), seld:long(1), from:() } } } }", 'core', 'getd', &savedPSN);
+    NSAppleEventDescriptor *rawr = ITSendAEWithStringAndTimeout(@"'----':obj { form:'prop', want:type('prop'), seld:type('pAlb'), from:obj { form:'indx', want:type('cTrk'), seld:abso($616C6C20$), from:obj { form:'indx', want:type('cPly'), seld:long(1), from:obj { form:'indx', want:type('cSrc'), seld:long(1), from:() } } } }", 'core', 'getd', &savedPSN, 600);
     int i;
     NSMutableArray *array = [[NSMutableArray alloc] init];
     NSArray *returnArray;
     int i;
     NSMutableArray *array = [[NSMutableArray alloc] init];
     NSArray *returnArray;
     return temp2;
 }
 
     return temp2;
 }
 
+- (int)currentSongPlayed
+{
+       UInt32 final;
+    ITDebugLog(@"Getting current song played time.");
+       final = [ITSendAEWithKey('pPos', 'core', 'getd', &savedPSN) int32Value];
+    ITDebugLog(@"Getting current song played time done.");
+    return final;
+}
+
+- (int)currentSongDuration
+{
+    SInt32 temp1;
+    ITDebugLog(@"Getting current song duration.");
+    temp1 = [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pDur'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value];
+    ITDebugLog(@"Getting current song duration done.");
+    return temp1;
+}
+
 - (NSString *)currentSongRemaining
 {
     SInt32 duration, current, final;
 - (NSString *)currentSongRemaining
 {
     SInt32 duration, current, final;
 {
     ITDebugLog(@"Getting current song album art.");
     NSData *data = ([self isPlaying]) ? [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pPCT'), from:obj { form:'indx', want:type('cArt'), seld:long(1), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } } }", 'core', 'getd', &savedPSN) data] : nil;
 {
     ITDebugLog(@"Getting current song album art.");
     NSData *data = ([self isPlaying]) ? [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pPCT'), from:obj { form:'indx', want:type('cArt'), seld:long(1), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } } }", 'core', 'getd', &savedPSN) data] : nil;
-    ITDebugLog(@"Getting current song album art done.");    
+    ITDebugLog(@"Getting current song album art done.");
     if (data) {
         return [[[NSImage alloc] initWithData:data] autorelease];
     } else {
     if (data) {
         return [[[NSImage alloc] initWithData:data] autorelease];
     } else {
                 ITDebugLog(@"iTunes' highLPongOfPSN: %lu.", number.highLongOfPSN);
                 ITDebugLog(@"iTunes' lowLongOfPSN: %lu.", number.lowLongOfPSN);
                 ITDebugLog(@"Done getting iTunes' PSN.");
                 ITDebugLog(@"iTunes' highLPongOfPSN: %lu.", number.highLongOfPSN);
                 ITDebugLog(@"iTunes' lowLongOfPSN: %lu.", number.lowLongOfPSN);
                 ITDebugLog(@"Done getting iTunes' PSN.");
+                               [(NSString *)name release];
                 return number;
             }
             [(NSString *)name release];
                 return number;
             }
             [(NSString *)name release];