1 /*****************************************************************************
2 * playlist.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2007 the VideoLAN team
7 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8 * Derk-Jan Hartman <hartman at videola/n dot org>
9 * Benjamin Pracht <bigben at videolab dot org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
27 * add 'icons' for different types of nodes? (http://www.cocoadev.com/index.pl?IconAndTextInTableCell)
28 * create toggle buttons for the shuffle, repeat one, repeat all functions.
29 * reimplement enable/disable item
30 * create a new 'tool' button (see the gear button in the Finder window) for 'actions'
31 (adding service discovery, other views, new node/playlist, save node/playlist) stuff like that
35 /*****************************************************************************
37 *****************************************************************************/
38 #include <stdlib.h> /* malloc(), free() */
39 #include <sys/param.h> /* for MAXPATHLEN */
42 #include <sys/mount.h>
48 #import "playlistinfo.h"
53 #import <vlc_interface.h>
55 /*****************************************************************************
56 * VLCPlaylistView implementation
57 *****************************************************************************/
58 @implementation VLCPlaylistView
60 - (NSMenu *)menuForEvent:(NSEvent *)o_event
62 return( [[self delegate] menuForEvent: o_event] );
65 - (void)keyDown:(NSEvent *)o_event
69 if( [[o_event characters] length] )
71 key = [[o_event characters] characterAtIndex: 0];
76 case NSDeleteCharacter:
77 case NSDeleteFunctionKey:
78 case NSDeleteCharFunctionKey:
79 case NSBackspaceCharacter:
80 [[self delegate] deleteItem:self];
83 case NSEnterCharacter:
84 case NSCarriageReturnCharacter:
85 [(VLCPlaylist *)[[VLCMain sharedInstance] getPlaylist]
90 [super keyDown: o_event];
98 /*****************************************************************************
99 * VLCPlaylistCommon implementation
101 * This class the superclass of the VLCPlaylist and VLCPlaylistWizard.
102 * It contains the common methods and elements of these 2 entities.
103 *****************************************************************************/
104 @implementation VLCPlaylistCommon
111 o_outline_dict = [[NSMutableDictionary alloc] init];
117 playlist_t * p_playlist = pl_Yield( VLCIntf );
118 [o_outline_view setTarget: self];
119 [o_outline_view setDelegate: self];
120 [o_outline_view setDataSource: self];
122 vlc_object_release( p_playlist );
128 [[o_tc_name headerCell] setStringValue:_NS("Name")];
129 [[o_tc_author headerCell] setStringValue:_NS("Author")];
130 [[o_tc_duration headerCell] setStringValue:_NS("Duration")];
133 - (NSOutlineView *)outlineView
135 return o_outline_view;
138 - (playlist_item_t *)selectedPlaylistItem
140 return [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
146 @implementation VLCPlaylistCommon (NSOutlineViewDataSource)
148 /* return the number of children for Obj-C pointer item */ /* DONE */
149 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
152 playlist_item_t *p_item = NULL;
153 playlist_t * p_playlist = pl_Yield( VLCIntf );
154 if( outlineView != o_outline_view )
156 vlc_object_release( p_playlist );
163 p_item = p_playlist->p_root_category;
167 p_item = (playlist_item_t *)[item pointerValue];
170 i_return = p_item->i_children;
171 vlc_object_release( p_playlist );
179 /* return the child at index for the Obj-C pointer item */ /* DONE */
180 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
182 playlist_item_t *p_return = NULL, *p_item = NULL;
184 playlist_t * p_playlist = pl_Yield( VLCIntf );
189 p_item = p_playlist->p_root_category;
193 p_item = (playlist_item_t *)[item pointerValue];
195 if( p_item && index < p_item->i_children && index >= 0 )
196 p_return = p_item->pp_children[index];
198 vlc_object_release( p_playlist );
200 o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]];
204 o_value = [[NSValue valueWithPointer: p_return] retain];
205 msg_Err( VLCIntf, "missing playlist item's pointer value" );
210 /* is the item expandable */
211 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
214 playlist_t *p_playlist = pl_Yield( VLCIntf );
219 if( p_playlist->p_root_category )
221 i_return = p_playlist->p_root_category->i_children;
226 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
228 i_return = p_item->i_children;
230 vlc_object_release( p_playlist );
232 return (i_return > 0);
235 /* retrieve the string values for the cells */
236 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)o_tc byItem:(id)item
239 playlist_item_t *p_item;
241 /* For error handling */
242 static BOOL attempted_reload = NO;
244 if( item == nil || ![item isKindOfClass: [NSValue class]] )
246 /* Attempt to fix the error by asking for a data redisplay
247 * This might cause infinite loop, so add a small check */
248 if( !attempted_reload )
250 attempted_reload = YES;
251 [outlineView reloadData];
256 p_item = (playlist_item_t *)[item pointerValue];
257 if( !p_item || !p_item->p_input )
259 /* Attempt to fix the error by asking for a data redisplay
260 * This might cause infinite loop, so add a small check */
261 if( !attempted_reload )
263 attempted_reload = YES;
264 [outlineView reloadData];
269 attempted_reload = NO;
271 if( [[o_tc identifier] isEqualToString:@"1"] )
273 /* sanity check to prevent the NSString class from crashing */
274 char *psz_title = input_item_GetTitle( p_item->p_input );
275 if( !EMPTY_STR( psz_title ) )
277 o_value = [NSString stringWithUTF8String: psz_title];
281 char *psz_name = input_item_GetName( p_item->p_input );
282 if( psz_name != NULL )
284 o_value = [NSString stringWithUTF8String: psz_name];
292 char *psz_artist = input_item_GetArtist( p_item->p_input );
293 if( [[o_tc identifier] isEqualToString:@"2"] && !EMPTY_STR( psz_artist ) )
295 o_value = [NSString stringWithUTF8String: psz_artist];
297 else if( [[o_tc identifier] isEqualToString:@"3"] )
299 char psz_duration[MSTRTIME_MAX_SIZE];
300 mtime_t dur = input_item_GetDuration( p_item->p_input );
303 secstotimestr( psz_duration, dur/1000000 );
304 o_value = [NSString stringWithUTF8String: psz_duration];
308 o_value = @"-:--:--";
319 /*****************************************************************************
320 * VLCPlaylistWizard implementation
321 *****************************************************************************/
322 @implementation VLCPlaylistWizard
324 - (IBAction)reloadOutlineView
326 /* Only reload the outlineview if the wizard window is open since this can
327 be quite long on big playlists */
328 if( [[o_outline_view window] isVisible] )
330 [o_outline_view reloadData];
336 /*****************************************************************************
337 * extension to NSOutlineView's interface to fix compilation warnings
338 * and let us access these 2 functions properly
339 * this uses a private Apple-API, but works fine on all current OSX releases
340 * keep checking for compatiblity with future releases though
341 *****************************************************************************/
343 @interface NSOutlineView (UndocumentedSortImages)
344 + (NSImage *)_defaultTableHeaderSortImage;
345 + (NSImage *)_defaultTableHeaderReverseSortImage;
349 /*****************************************************************************
350 * VLCPlaylist implementation
351 *****************************************************************************/
352 @implementation VLCPlaylist
359 o_nodes_array = [[NSMutableArray alloc] init];
360 o_items_array = [[NSMutableArray alloc] init];
367 playlist_t * p_playlist = pl_Yield( VLCIntf );
371 [super awakeFromNib];
373 [o_outline_view setDoubleAction: @selector(playItem:)];
375 [o_outline_view registerForDraggedTypes:
376 [NSArray arrayWithObjects: NSFilenamesPboardType,
377 @"VLCPlaylistItemPboardType", nil]];
378 [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
380 /* this uses private Apple API which works fine until 10.4,
381 * but keep checking in the future!
382 * These methods are being added artificially to NSOutlineView's interface above */
383 o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
384 o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
386 o_tc_sortColumn = nil;
389 char ** ppsz_services = services_discovery_GetServicesNames( p_playlist, &ppsz_name );
391 for( i = 0; ppsz_services[i]; i++ )
393 vlc_bool_t b_enabled;
397 char * name = ppsz_name[i] ? ppsz_name[i] : ppsz_services[i];
398 /* Check whether to enable these menuitems */
399 b_enabled = playlist_IsServicesDiscoveryLoaded( p_playlist, objectname );
401 /* Create the menu entries used in the playlist menu */
402 o_lmi = [[o_mi_services submenu] addItemWithTitle:
403 [NSString stringWithUTF8String: name]
404 action: @selector(servicesChange:)
406 [o_lmi setTarget: self];
407 [o_lmi setRepresentedObject: [NSString stringWithUTF8String: ppsz_services[i]]];
408 if( b_enabled ) [o_lmi setState: NSOnState];
410 /* Create the menu entries for the main menu */
411 o_lmi = [[o_mm_mi_services submenu] addItemWithTitle:
412 [NSString stringWithUTF8String: name]
413 action: @selector(servicesChange:)
415 [o_lmi setTarget: self];
416 [o_lmi setRepresentedObject: [NSString stringWithUTF8String: ppsz_services[i]]];
417 if( b_enabled ) [o_lmi setState: NSOnState];
419 free( ppsz_services[i] );
420 free( ppsz_name[i] );
422 free( ppsz_services );
425 vlc_object_release( p_playlist );
427 //[self playlistUpdated];
430 - (void)searchfieldChanged:(NSNotification *)o_notification
432 [o_search_field setStringValue:[[o_notification object] stringValue]];
439 [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
440 [o_mi_play setTitle: _NS("Play")];
441 [o_mi_delete setTitle: _NS("Delete")];
442 [o_mi_recursive_expand setTitle: _NS("Expand Node")];
443 [o_mi_selectall setTitle: _NS("Select All")];
444 [o_mi_info setTitle: _NS("Information")];
445 [o_mi_preparse setTitle: _NS("Get Stream Information")];
446 [o_mi_sort_name setTitle: _NS("Sort Node by Name")];
447 [o_mi_sort_author setTitle: _NS("Sort Node by Author")];
448 [o_mi_services setTitle: _NS("Services discovery")];
449 [o_status_field setStringValue: [NSString stringWithFormat:
450 _NS("No items in the playlist")]];
453 [o_search_button setTitle: _NS("Search")];
455 [o_search_field setToolTip: _NS("Search in Playlist")];
456 [o_mi_addNode setTitle: _NS("Add Folder to Playlist")];
458 [o_save_accessory_text setStringValue: _NS("File Format:")];
459 [[o_save_accessory_popup itemAtIndex:0] setTitle: _NS("Extended M3U")];
460 [[o_save_accessory_popup itemAtIndex:1] setTitle: _NS("XML Shareable Playlist Format (XSPF)")];
463 - (void)playlistUpdated
467 /* Clear indications of any existing column sorting */
468 for( i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )
470 [o_outline_view setIndicatorImage:nil inTableColumn:
471 [[o_outline_view tableColumns] objectAtIndex:i]];
474 [o_outline_view setHighlightedTableColumn:nil];
475 o_tc_sortColumn = nil;
476 // TODO Find a way to keep the dict size to a minimum
477 //[o_outline_dict removeAllObjects];
478 [o_outline_view reloadData];
479 [[[[VLCMain sharedInstance] getWizard] getPlaylistWizard] reloadOutlineView];
480 [[[[VLCMain sharedInstance] getBookmarks] getDataTable] reloadData];
482 playlist_t *p_playlist = pl_Yield( VLCIntf );
484 if( playlist_CurrentSize( p_playlist ) >= 2 )
486 [o_status_field setStringValue: [NSString stringWithFormat:
487 _NS("%i items in the playlist"),
488 playlist_CurrentSize( p_playlist )]];
492 if( playlist_IsEmpty( p_playlist ) )
493 [o_status_field setStringValue: _NS("No items in the playlist")];
495 [o_status_field setStringValue: _NS("1 item in the playlist")];
497 vlc_object_release( p_playlist );
500 - (void)playModeUpdated
502 playlist_t *p_playlist = pl_Yield( VLCIntf );
503 vlc_value_t val, val2;
505 var_Get( p_playlist, "loop", &val2 );
506 var_Get( p_playlist, "repeat", &val );
507 if( val.b_bool == VLC_TRUE )
509 [[[VLCMain sharedInstance] getControls] repeatOne];
511 else if( val2.b_bool == VLC_TRUE )
513 [[[VLCMain sharedInstance] getControls] repeatAll];
517 [[[VLCMain sharedInstance] getControls] repeatOff];
520 [[[VLCMain sharedInstance] getControls] shuffle];
522 vlc_object_release( p_playlist );
525 - (void)updateRowSelection
530 playlist_t *p_playlist = pl_Yield( VLCIntf );
531 playlist_item_t *p_item, *p_temp_item;
532 NSMutableArray *o_array = [NSMutableArray array];
534 p_item = p_playlist->status.p_item;
537 vlc_object_release(p_playlist);
541 p_temp_item = p_item;
542 while( p_temp_item->p_parent )
544 [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
545 p_temp_item = p_temp_item->p_parent;
546 /*for (i = 0 ; i < p_temp_item->i_parents ; i++)
548 if( p_temp_item->pp_parents[i]->i_view == i_current_view )
550 p_temp_item = p_temp_item->pp_parents[i]->p_parent;
556 for( j = 0; j < [o_array count] - 1; j++ )
559 if( ( o_item = [o_outline_dict objectForKey:
560 [NSString stringWithFormat: @"%p",
561 [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
563 [o_outline_view expandItem: o_item];
568 i_row = [o_outline_view rowForItem:[o_outline_dict
569 objectForKey:[NSString stringWithFormat: @"%p", p_item]]];
571 [o_outline_view selectRow: i_row byExtendingSelection: NO];
572 [o_outline_view scrollRowToVisible: i_row];
574 vlc_object_release( p_playlist );
576 /* update our info-panel to reflect the new item */
577 [[[VLCMain sharedInstance] getInfo] updatePanel];
580 /* Check if p_item is a child of p_node recursively. We need to check the item
581 existence first since OSX sometimes tries to redraw items that have been
582 deleted. We don't do it when not required since this verification takes
583 quite a long time on big playlists (yes, pretty hacky). */
584 - (BOOL)isItem: (playlist_item_t *)p_item
585 inNode: (playlist_item_t *)p_node
586 checkItemExistence:(BOOL)b_check
589 playlist_t * p_playlist = pl_Yield( VLCIntf );
590 playlist_item_t *p_temp_item = p_item;
592 if( p_node == p_item )
594 vlc_object_release(p_playlist);
598 if( p_node->i_children < 1)
600 vlc_object_release(p_playlist);
607 vlc_mutex_lock( &p_playlist->object_lock );
611 /* Since outlineView: willDisplayCell:... may call this function with
612 p_items that don't exist anymore, first check if the item is still
613 in the playlist. Any cleaner solution welcomed. */
614 for( i = 0; i < p_playlist->all_items.i_size; i++ )
616 if( ARRAY_VAL( p_playlist->all_items, i) == p_item ) break;
617 else if ( i == p_playlist->all_items.i_size - 1 )
619 vlc_object_release( p_playlist );
620 vlc_mutex_unlock( &p_playlist->object_lock );
628 p_temp_item = p_temp_item->p_parent;
629 if( p_temp_item == p_node )
631 vlc_mutex_unlock( &p_playlist->object_lock );
632 vlc_object_release( p_playlist );
636 vlc_mutex_unlock( &p_playlist->object_lock );
639 vlc_object_release( p_playlist );
643 /* This method is usefull for instance to remove the selected children of an
644 already selected node */
645 - (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
648 for( i = 0 ; i < [o_items count] ; i++ )
650 for ( j = 0 ; j < [o_nodes count] ; j++ )
652 if( o_items == o_nodes)
654 if( j == i ) continue;
656 if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
657 inNode: [[o_nodes objectAtIndex:j] pointerValue]
658 checkItemExistence: NO] )
660 [o_items removeObjectAtIndex:i];
661 /* We need to execute the next iteration with the same index
662 since the current item has been deleted */
671 - (IBAction)savePlaylist:(id)sender
673 intf_thread_t * p_intf = VLCIntf;
674 playlist_t * p_playlist = pl_Yield( p_intf );
676 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
677 NSString * o_name = [NSString stringWithFormat: @"%@", _NS("Untitled")];
679 //[o_save_panel setAllowedFileTypes: [NSArray arrayWithObjects: @"m3u", @"xpf", nil] ];
680 [o_save_panel setTitle: _NS("Save Playlist")];
681 [o_save_panel setPrompt: _NS("Save")];
682 [o_save_panel setAccessoryView: o_save_accessory_view];
684 if( [o_save_panel runModalForDirectory: nil
685 file: o_name] == NSOKButton )
687 NSString *o_filename = [o_save_panel filename];
689 if( [o_save_accessory_popup indexOfSelectedItem] == 1 )
691 NSString * o_real_filename;
693 range.location = [o_filename length] - [@".xspf" length];
694 range.length = [@".xspf" length];
696 if( [o_filename compare:@".xspf" options: NSCaseInsensitiveSearch
697 range: range] != NSOrderedSame )
699 o_real_filename = [NSString stringWithFormat: @"%@.xspf", o_filename];
703 o_real_filename = o_filename;
705 playlist_Export( p_playlist,
706 [o_real_filename fileSystemRepresentation],
707 p_playlist->p_local_category, "export-xspf" );
711 NSString * o_real_filename;
713 range.location = [o_filename length] - [@".m3u" length];
714 range.length = [@".m3u" length];
716 if( [o_filename compare:@".m3u" options: NSCaseInsensitiveSearch
717 range: range] != NSOrderedSame )
719 o_real_filename = [NSString stringWithFormat: @"%@.m3u", o_filename];
723 o_real_filename = o_filename;
725 playlist_Export( p_playlist,
726 [o_real_filename fileSystemRepresentation],
727 p_playlist->p_local_category, "export-m3u" );
730 vlc_object_release( p_playlist );
733 /* When called retrieves the selected outlineview row and plays that node or item */
734 - (IBAction)playItem:(id)sender
736 intf_thread_t * p_intf = VLCIntf;
737 playlist_t * p_playlist = pl_Yield( p_intf );
739 playlist_item_t *p_item;
740 playlist_item_t *p_node = NULL;
742 p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
746 if( p_item->i_children == -1 )
748 p_node = p_item->p_parent;
754 if( p_node->i_children > 0 && p_node->pp_children[0]->i_children == -1 )
756 p_item = p_node->pp_children[0];
763 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_node, p_item );
765 vlc_object_release( p_playlist );
768 /* When called retrieves the selected outlineview row and plays that node or item */
769 - (IBAction)preparseItem:(id)sender
772 NSMutableArray *o_to_preparse;
773 intf_thread_t * p_intf = VLCIntf;
774 playlist_t * p_playlist = pl_Yield( p_intf );
776 o_to_preparse = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
777 i_count = [o_to_preparse count];
781 playlist_item_t *p_item = NULL;
783 for( i = 0; i < i_count; i++ )
785 o_number = [o_to_preparse lastObject];
786 i_row = [o_number intValue];
787 p_item = [[o_outline_view itemAtRow:i_row] pointerValue];
788 [o_to_preparse removeObject: o_number];
789 [o_outline_view deselectRow: i_row];
793 if( p_item->i_children == -1 )
795 playlist_PreparseEnqueue( p_playlist, p_item->p_input );
799 msg_Dbg( p_intf, "preparse of nodes not yet implemented" );
803 vlc_object_release( p_playlist );
804 [self playlistUpdated];
807 - (IBAction)servicesChange:(id)sender
809 NSMenuItem *o_mi = (NSMenuItem *)sender;
810 NSString *o_string = [o_mi representedObject];
811 playlist_t * p_playlist = pl_Yield( VLCIntf );
812 if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string UTF8String] ) )
813 playlist_ServicesDiscoveryAdd( p_playlist, [o_string UTF8String] );
815 playlist_ServicesDiscoveryRemove( p_playlist, [o_string UTF8String] );
817 [o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,
818 [o_string UTF8String] ) ? YES : NO];
820 vlc_object_release( p_playlist );
821 [self playlistUpdated];
825 - (IBAction)selectAll:(id)sender
827 [o_outline_view selectAll: nil];
830 - (IBAction)deleteItem:(id)sender
832 int i, i_count, i_row;
833 NSMutableArray *o_to_delete;
836 playlist_t * p_playlist;
837 intf_thread_t * p_intf = VLCIntf;
839 p_playlist = pl_Yield( p_intf );
841 o_to_delete = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
842 i_count = [o_to_delete count];
844 for( i = 0; i < i_count; i++ )
846 o_number = [o_to_delete lastObject];
847 i_row = [o_number intValue];
848 id o_item = [o_outline_view itemAtRow: i_row];
849 playlist_item_t *p_item = [o_item pointerValue];
850 [o_to_delete removeObject: o_number];
851 [o_outline_view deselectRow: i_row];
853 if( [[o_outline_view dataSource] outlineView:o_outline_view
854 numberOfChildrenOfItem: o_item] > 0 )
855 //is a node and not an item
857 if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
858 [self isItem: p_playlist->status.p_item inNode:
859 ((playlist_item_t *)[o_item pointerValue])
860 checkItemExistence: NO] == YES )
862 // if current item is in selected node and is playing then stop playlist
863 playlist_Stop( p_playlist );
865 vlc_mutex_lock( &p_playlist->object_lock );
866 playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
867 vlc_mutex_unlock( &p_playlist->object_lock );
871 playlist_DeleteFromInput( p_playlist, p_item->p_input->i_id, VLC_FALSE );
874 [self playlistUpdated];
875 vlc_object_release( p_playlist );
878 - (IBAction)sortNodeByName:(id)sender
880 [self sortNode: SORT_TITLE];
883 - (IBAction)sortNodeByAuthor:(id)sender
885 [self sortNode: SORT_ARTIST];
888 - (void)sortNode:(int)i_mode
890 playlist_t * p_playlist = pl_Yield( VLCIntf );
891 playlist_item_t * p_item;
893 if( [o_outline_view selectedRow] > -1 )
895 p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
899 /*If no item is selected, sort the whole playlist*/
901 p_item = p_playlist->p_root_category;
904 if( p_item->i_children > -1 ) // the item is a node
906 vlc_mutex_lock( &p_playlist->object_lock );
907 playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
908 vlc_mutex_unlock( &p_playlist->object_lock );
912 vlc_mutex_lock( &p_playlist->object_lock );
913 playlist_RecursiveNodeSort( p_playlist,
914 p_item->p_parent, i_mode, ORDER_NORMAL );
915 vlc_mutex_unlock( &p_playlist->object_lock );
917 vlc_object_release( p_playlist );
918 [self playlistUpdated];
921 - (input_item_t *)createItem:(NSDictionary *)o_one_item
923 intf_thread_t * p_intf = VLCIntf;
924 playlist_t * p_playlist = pl_Yield( p_intf );
926 input_item_t *p_input;
928 BOOL b_rem = FALSE, b_dir = FALSE;
929 NSString *o_uri, *o_name;
934 o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
935 o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
936 o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
938 /* Find the name for a disc entry ( i know, can you believe the trouble?) */
939 if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound )
941 int i_count, i_index;
942 struct statfs *mounts = NULL;
944 i_count = getmntinfo (&mounts, MNT_NOWAIT);
945 /* getmntinfo returns a pointer to static data. Do not free. */
946 for( i_index = 0 ; i_index < i_count; i_index++ )
948 NSMutableString *o_temp, *o_temp2;
949 o_temp = [NSMutableString stringWithString: o_uri];
950 o_temp2 = [NSMutableString stringWithUTF8String: mounts[i_index].f_mntfromname];
951 [o_temp replaceOccurrencesOfString: @"/dev/rdisk" withString: @"/dev/disk" options:nil range:NSMakeRange(0, [o_temp length]) ];
952 [o_temp2 replaceOccurrencesOfString: @"s0" withString: @"" options:nil range:NSMakeRange(0, [o_temp2 length]) ];
953 [o_temp2 replaceOccurrencesOfString: @"s1" withString: @"" options:nil range:NSMakeRange(0, [o_temp2 length]) ];
955 if( strstr( [o_temp fileSystemRepresentation], [o_temp2 fileSystemRepresentation] ) != NULL )
957 o_name = [[NSFileManager defaultManager] displayNameAtPath: [NSString stringWithUTF8String:mounts[i_index].f_mntonname]];
961 /* If no name, then make a guess */
962 if( !o_name) o_name = [[NSFileManager defaultManager] displayNameAtPath: o_uri];
964 if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
965 [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
966 isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem )
968 /* All of this is to make sure CD's play when you D&D them on VLC */
969 /* Converts mountpoint to a /dev file */
972 NSMutableString *o_temp;
974 buf = (struct statfs *) malloc (sizeof(struct statfs));
975 statfs( [o_uri fileSystemRepresentation], buf );
976 psz_dev = strdup(buf->f_mntfromname);
977 o_temp = [NSMutableString stringWithUTF8String: psz_dev ];
978 [o_temp replaceOccurrencesOfString: @"/dev/disk" withString: @"/dev/rdisk" options:nil range:NSMakeRange(0, [o_temp length]) ];
979 [o_temp replaceOccurrencesOfString: @"s0" withString: @"" options:nil range:NSMakeRange(0, [o_temp length]) ];
980 [o_temp replaceOccurrencesOfString: @"s1" withString: @"" options:nil range:NSMakeRange(0, [o_temp length]) ];
984 p_input = input_ItemNew( p_playlist, [o_uri fileSystemRepresentation], [o_name UTF8String] );
990 for( i = 0; i < (int)[o_options count]; i++ )
992 input_ItemAddOption( p_input, strdup( [[o_options objectAtIndex:i] UTF8String] ) );
996 /* Recent documents menu */
997 o_true_file = [NSURL fileURLWithPath: o_uri];
998 if( o_true_file != nil )
1000 [[NSDocumentController sharedDocumentController]
1001 noteNewRecentDocumentURL: o_true_file];
1004 vlc_object_release( p_playlist );
1008 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
1011 playlist_t * p_playlist = pl_Yield( VLCIntf );
1013 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
1015 input_item_t *p_input;
1016 NSDictionary *o_one_item;
1019 o_one_item = [o_array objectAtIndex: i_item];
1020 p_input = [self createItem: o_one_item];
1027 playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
1028 i_position == -1 ? PLAYLIST_END : i_position + i_item, VLC_TRUE,
1031 if( i_item == 0 && !b_enqueue )
1033 playlist_item_t *p_item;
1034 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1035 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
1039 playlist_item_t *p_item;
1040 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1041 playlist_Control( p_playlist, PLAYLIST_SKIP, VLC_TRUE, p_item );
1044 [self playlistUpdated];
1045 vlc_object_release( p_playlist );
1048 - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue
1051 playlist_t * p_playlist = pl_Yield( VLCIntf );
1053 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
1055 input_item_t *p_input;
1056 NSDictionary *o_one_item;
1059 o_one_item = [o_array objectAtIndex: i_item];
1060 p_input = [self createItem: o_one_item];
1067 playlist_NodeAddInput( p_playlist, p_input, p_node,
1070 PLAYLIST_END : i_position + i_item, VLC_FALSE );
1073 if( i_item == 0 && !b_enqueue )
1075 playlist_item_t *p_item;
1076 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1077 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
1081 playlist_item_t *p_item;
1082 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1083 playlist_Control( p_playlist, PLAYLIST_SKIP, VLC_TRUE, p_item );
1086 [self playlistUpdated];
1087 vlc_object_release( p_playlist );
1090 - (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
1092 playlist_t *p_playlist = pl_Yield( VLCIntf );
1093 playlist_item_t *p_selected_item;
1094 int i_current, i_selected_row;
1096 i_selected_row = [o_outline_view selectedRow];
1097 if (i_selected_row < 0)
1100 p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow:
1101 i_selected_row] pointerValue];
1103 for( i_current = 0; i_current < p_item->i_children ; i_current++ )
1106 NSString *o_current_name, *o_current_author;
1108 vlc_mutex_lock( &p_playlist->object_lock );
1109 o_current_name = [NSString stringWithUTF8String:
1110 p_item->pp_children[i_current]->p_input->psz_name];
1111 psz_temp = input_ItemGetInfo( p_item->p_input ,
1112 _("Meta-information"),_("Artist") );
1113 o_current_author = [NSString stringWithUTF8String: psz_temp];
1115 vlc_mutex_unlock( &p_playlist->object_lock );
1117 if( p_selected_item == p_item->pp_children[i_current] &&
1118 b_selected_item_met == NO )
1120 b_selected_item_met = YES;
1122 else if( p_selected_item == p_item->pp_children[i_current] &&
1123 b_selected_item_met == YES )
1125 vlc_object_release( p_playlist );
1128 else if( b_selected_item_met == YES &&
1129 ( [o_current_name rangeOfString:[o_search_field
1130 stringValue] options:NSCaseInsensitiveSearch ].length ||
1131 [o_current_author rangeOfString:[o_search_field
1132 stringValue] options:NSCaseInsensitiveSearch ].length ) )
1134 vlc_object_release( p_playlist );
1135 /*Adds the parent items in the result array as well, so that we can
1137 return [NSMutableArray arrayWithObject: [NSValue
1138 valueWithPointer: p_item->pp_children[i_current]]];
1140 if( p_item->pp_children[i_current]->i_children > 0 )
1142 id o_result = [self subSearchItem:
1143 p_item->pp_children[i_current]];
1144 if( o_result != NULL )
1146 vlc_object_release( p_playlist );
1147 [o_result insertObject: [NSValue valueWithPointer:
1148 p_item->pp_children[i_current]] atIndex:0];
1153 vlc_object_release( p_playlist );
1157 - (IBAction)searchItem:(id)sender
1159 playlist_t * p_playlist = pl_Yield( VLCIntf );
1165 b_selected_item_met = NO;
1167 /*First, only search after the selected item:*
1168 *(b_selected_item_met = NO) */
1169 o_result = [self subSearchItem:p_playlist->p_root_category];
1170 if( o_result == NULL )
1172 /* If the first search failed, search again from the beginning */
1173 o_result = [self subSearchItem:p_playlist->p_root_category];
1175 if( o_result != NULL )
1178 if( [[o_result objectAtIndex: 0] pointerValue] ==
1179 p_playlist->p_local_category )
1184 for( i = i_start ; i < [o_result count] - 1 ; i++ )
1186 [o_outline_view expandItem: [o_outline_dict objectForKey:
1187 [NSString stringWithFormat: @"%p",
1188 [[o_result objectAtIndex: i] pointerValue]]]];
1190 i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey:
1191 [NSString stringWithFormat: @"%p",
1192 [[o_result objectAtIndex: [o_result count] - 1 ]
1197 [o_outline_view selectRow:i_row byExtendingSelection: NO];
1198 [o_outline_view scrollRowToVisible: i_row];
1200 vlc_object_release( p_playlist );
1203 - (IBAction)recursiveExpandNode:(id)sender
1205 id o_item = [o_outline_view itemAtRow: [o_outline_view selectedRow]];
1206 playlist_item_t *p_item = (playlist_item_t *)[o_item pointerValue];
1208 if( ![[o_outline_view dataSource] outlineView: o_outline_view
1209 isItemExpandable: o_item] )
1211 o_item = [o_outline_dict objectForKey: [NSString
1212 stringWithFormat: @"%p", p_item->p_parent]];
1215 /* We need to collapse the node first, since OSX refuses to recursively
1216 expand an already expanded node, even if children nodes are collapsed. */
1217 [o_outline_view collapseItem: o_item collapseChildren: YES];
1218 [o_outline_view expandItem: o_item expandChildren: YES];
1221 - (NSMenu *)menuForEvent:(NSEvent *)o_event
1225 vlc_bool_t b_item_sel;
1227 pt = [o_outline_view convertPoint: [o_event locationInWindow]
1229 b_item_sel = ( [o_outline_view rowAtPoint: pt] != -1 &&
1230 [o_outline_view selectedRow] != -1 );
1231 b_rows = [o_outline_view numberOfRows] != 0;
1233 [o_mi_play setEnabled: b_item_sel];
1234 [o_mi_delete setEnabled: b_item_sel];
1235 [o_mi_selectall setEnabled: b_rows];
1236 [o_mi_info setEnabled: b_item_sel];
1237 [o_mi_preparse setEnabled: b_item_sel];
1238 [o_mi_recursive_expand setEnabled: b_item_sel];
1239 [o_mi_sort_name setEnabled: b_item_sel];
1240 [o_mi_sort_author setEnabled: b_item_sel];
1242 return( o_ctx_menu );
1245 - (void)outlineView: (NSTableView*)o_tv
1246 didClickTableColumn:(NSTableColumn *)o_tc
1248 int i_mode = 0, i_type;
1249 intf_thread_t *p_intf = VLCIntf;
1251 playlist_t *p_playlist = pl_Yield( p_intf );
1253 /* Check whether the selected table column header corresponds to a
1254 sortable table column*/
1255 if( !( o_tc == o_tc_name || o_tc == o_tc_author ) )
1257 vlc_object_release( p_playlist );
1261 if( o_tc_sortColumn == o_tc )
1263 b_isSortDescending = !b_isSortDescending;
1267 b_isSortDescending = VLC_FALSE;
1270 if( o_tc == o_tc_name )
1272 i_mode = SORT_TITLE;
1274 else if( o_tc == o_tc_author )
1276 i_mode = SORT_ARTIST;
1279 if( b_isSortDescending )
1281 i_type = ORDER_REVERSE;
1285 i_type = ORDER_NORMAL;
1288 vlc_mutex_lock( &p_playlist->object_lock );
1289 playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_category, i_mode, i_type );
1290 vlc_mutex_unlock( &p_playlist->object_lock );
1292 vlc_object_release( p_playlist );
1293 [self playlistUpdated];
1295 o_tc_sortColumn = o_tc;
1296 [o_outline_view setHighlightedTableColumn:o_tc];
1298 if( b_isSortDescending )
1300 [o_outline_view setIndicatorImage:o_descendingSortingImage
1301 inTableColumn:o_tc];
1305 [o_outline_view setIndicatorImage:o_ascendingSortingImage
1306 inTableColumn:o_tc];
1311 - (void)outlineView:(NSOutlineView *)outlineView
1312 willDisplayCell:(id)cell
1313 forTableColumn:(NSTableColumn *)tableColumn
1316 playlist_t *p_playlist = pl_Yield( VLCIntf );
1320 o_playing_item = [o_outline_dict objectForKey:
1321 [NSString stringWithFormat:@"%p", p_playlist->status.p_item]];
1323 if( [self isItem: [o_playing_item pointerValue] inNode:
1324 [item pointerValue] checkItemExistence: YES]
1325 || [o_playing_item isEqual: item] )
1327 [cell setFont: [NSFont boldSystemFontOfSize: 0]];
1331 [cell setFont: [NSFont systemFontOfSize: 0]];
1333 vlc_object_release( p_playlist );
1336 - (IBAction)addNode:(id)sender
1338 /* we have to create a new thread here because otherwise we would block the
1339 * interface since the interaction-stuff and this code would run in the same
1341 [NSThread detachNewThreadSelector: @selector(addNodeThreadedly)
1342 toTarget: self withObject:nil];
1343 [self playlistUpdated];
1346 - (void)addNodeThreadedly
1348 NSAutoreleasePool * ourPool = [[NSAutoreleasePool alloc] init];
1350 /* simply adds a new node to the end of the playlist */
1351 playlist_t * p_playlist = pl_Yield( VLCIntf );
1352 vlc_thread_set_priority( p_playlist, VLC_THREAD_PRIORITY_LOW );
1355 char *psz_name = NULL;
1356 playlist_item_t * p_item;
1357 ret_v = intf_UserStringInput( p_playlist, _("New Node"),
1358 _("Please enter a name for the new node."), &psz_name );
1360 if( psz_name != NULL && psz_name != "" )
1361 p_item = playlist_NodeCreate( p_playlist, psz_name,
1362 p_playlist->p_local_category, 0, NULL );
1363 else if(! config_GetInt( p_playlist, "interact" ) )
1365 /* in case that the interaction is disabled, just give it a bogus name */
1366 p_item = playlist_NodeCreate( p_playlist, _("Empty Folder"),
1367 p_playlist->p_local_category, 0, NULL );
1371 msg_Warn( VLCIntf, "node creation failed or cancelled by user" );
1373 vlc_object_release( p_playlist );
1379 @implementation VLCPlaylist (NSOutlineViewDataSource)
1381 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
1383 id o_value = [super outlineView: outlineView child: index ofItem: item];
1384 playlist_t *p_playlist = pl_Yield( VLCIntf );
1386 if( playlist_CurrentSize( p_playlist ) >= 2 )
1388 [o_status_field setStringValue: [NSString stringWithFormat:
1389 _NS("%i items in the playlist"),
1390 playlist_CurrentSize( p_playlist )]];
1394 if( playlist_IsEmpty( p_playlist ) )
1396 [o_status_field setStringValue: _NS("No items in the playlist")];
1400 [o_status_field setStringValue: _NS("1 item in the playlist")];
1403 vlc_object_release( p_playlist );
1405 [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p",
1406 [o_value pointerValue]]];
1407 msg_Dbg( VLCIntf, "adding item %p", [o_value pointerValue] );
1412 /* Required for drag & drop and reordering */
1413 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
1416 playlist_t *p_playlist = pl_Yield( VLCIntf );
1418 /* First remove the items that were moved during the last drag & drop
1420 [o_items_array removeAllObjects];
1421 [o_nodes_array removeAllObjects];
1423 for( i = 0 ; i < [items count] ; i++ )
1425 id o_item = [items objectAtIndex: i];
1427 /* Refuse to move items that are not in the General Node
1428 (Service Discovery) */
1429 if( ![self isItem: [o_item pointerValue] inNode:
1430 p_playlist->p_local_category checkItemExistence: NO])
1432 vlc_object_release(p_playlist);
1435 /* Fill the items and nodes to move in 2 different arrays */
1436 if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 )
1437 [o_nodes_array addObject: o_item];
1439 [o_items_array addObject: o_item];
1442 /* Now we need to check if there are selected items that are in already
1443 selected nodes. In that case, we only want to move the nodes */
1444 [self removeItemsFrom: o_nodes_array ifChildrenOf: o_nodes_array];
1445 [self removeItemsFrom: o_items_array ifChildrenOf: o_nodes_array];
1447 /* We add the "VLCPlaylistItemPboardType" type to be able to recognize
1448 a Drop operation coming from the playlist. */
1450 [pboard declareTypes: [NSArray arrayWithObjects:
1451 @"VLCPlaylistItemPboardType", nil] owner: self];
1452 [pboard setData:[NSData data] forType:@"VLCPlaylistItemPboardType"];
1454 vlc_object_release(p_playlist);
1458 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
1460 playlist_t *p_playlist = pl_Yield( VLCIntf );
1461 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1463 if( !p_playlist ) return NSDragOperationNone;
1465 /* Dropping ON items is not allowed if item is not a node */
1468 if( index == NSOutlineViewDropOnItemIndex &&
1469 ((playlist_item_t *)[item pointerValue])->i_children == -1 )
1471 vlc_object_release( p_playlist );
1472 return NSDragOperationNone;
1476 /* Don't allow on drop on playlist root element's child */
1477 if( !item && index != NSOutlineViewDropOnItemIndex)
1479 vlc_object_release( p_playlist );
1480 return NSDragOperationNone;
1483 /* We refuse to drop an item in anything else than a child of the General
1484 Node. We still accept items that would be root nodes of the outlineview
1485 however, to allow drop in an empty playlist. */
1486 if( !([self isItem: [item pointerValue] inNode: p_playlist->p_local_category
1487 checkItemExistence: NO] || item == nil) )
1489 vlc_object_release( p_playlist );
1490 return NSDragOperationNone;
1493 /* Drop from the Playlist */
1494 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1497 for( i = 0 ; i < [o_nodes_array count] ; i++ )
1499 /* We refuse to Drop in a child of an item we are moving */
1500 if( [self isItem: [item pointerValue] inNode:
1501 [[o_nodes_array objectAtIndex: i] pointerValue]
1502 checkItemExistence: NO] )
1504 vlc_object_release( p_playlist );
1505 return NSDragOperationNone;
1508 vlc_object_release( p_playlist );
1509 return NSDragOperationMove;
1512 /* Drop from the Finder */
1513 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1515 vlc_object_release( p_playlist );
1516 return NSDragOperationGeneric;
1518 vlc_object_release( p_playlist );
1519 return NSDragOperationNone;
1522 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index
1524 playlist_t * p_playlist = pl_Yield( VLCIntf );
1525 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1527 /* Drag & Drop inside the playlist */
1528 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1530 int i_row, i_removed_from_node = 0;
1532 playlist_item_t *p_new_parent, *p_item = NULL;
1533 NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
1535 /* If the item is to be dropped as root item of the outline, make it a
1536 child of the General node.
1537 Else, choose the proposed parent as parent. */
1538 if( item == nil ) p_new_parent = p_playlist->p_local_category;
1539 else p_new_parent = [item pointerValue];
1541 /* Make sure the proposed parent is a node.
1542 (This should never be true) */
1543 if( p_new_parent->i_children < 0 )
1545 vlc_object_release( p_playlist );
1549 for( i = 0; i < [o_all_items count]; i++ )
1551 playlist_item_t *p_old_parent = NULL;
1552 int i_old_index = 0;
1554 p_item = [[o_all_items objectAtIndex:i] pointerValue];
1555 p_old_parent = p_item->p_parent;
1558 /* We may need the old index later */
1559 if( p_new_parent == p_old_parent )
1562 for( j = 0; j < p_old_parent->i_children; j++ )
1564 if( p_old_parent->pp_children[j] == p_item )
1572 vlc_mutex_lock( &p_playlist->object_lock );
1573 // Acually detach the item from the old position
1574 if( playlist_NodeRemoveItem( p_playlist, p_item, p_old_parent ) ==
1578 /* Calculate the new index */
1581 /* If we move the item in the same node, we need to take into
1582 account that one item will be deleted */
1585 if ((p_new_parent == p_old_parent &&
1586 i_old_index < index + (int)i) )
1588 i_removed_from_node++;
1590 i_new_index = index + i - i_removed_from_node;
1592 // Reattach the item to the new position
1593 playlist_NodeInsert( p_playlist, p_item, p_new_parent, i_new_index );
1595 vlc_mutex_unlock( &p_playlist->object_lock );
1597 [self playlistUpdated];
1598 i_row = [o_outline_view rowForItem:[o_outline_dict
1599 objectForKey:[NSString stringWithFormat: @"%p",
1600 [[o_all_items objectAtIndex: 0] pointerValue]]]];
1604 i_row = [o_outline_view rowForItem:[o_outline_dict
1605 objectForKey:[NSString stringWithFormat: @"%p", p_new_parent]]];
1608 [o_outline_view deselectAll: self];
1609 [o_outline_view selectRow: i_row byExtendingSelection: NO];
1610 [o_outline_view scrollRowToVisible: i_row];
1612 vlc_object_release( p_playlist );
1616 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1619 playlist_item_t *p_node = [item pointerValue];
1621 NSArray *o_array = [NSArray array];
1622 NSArray *o_values = [[o_pasteboard propertyListForType:
1623 NSFilenamesPboardType]
1624 sortedArrayUsingSelector:
1625 @selector(caseInsensitiveCompare:)];
1627 for( i = 0; i < (int)[o_values count]; i++)
1629 NSDictionary *o_dic;
1630 o_dic = [NSDictionary dictionaryWithObject:[o_values
1631 objectAtIndex:i] forKey:@"ITEM_URL"];
1632 o_array = [o_array arrayByAddingObject: o_dic];
1637 [self appendArray: o_array atPos: index enqueue: YES];
1639 /* This should never occur */
1640 else if( p_node->i_children == -1 )
1642 vlc_object_release( p_playlist );
1647 [self appendNodeArray: o_array inNode: p_node
1648 atPos: index enqueue: YES];
1650 vlc_object_release( p_playlist );
1653 vlc_object_release( p_playlist );