1 /*****************************************************************************
2 * playlist.m: MacOS X interface module
3 *****************************************************************************
4 * Copyright (C) 2002-2008 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 * reimplement enable/disable item
29 * create a new 'tool' button (see the gear button in the Finder window) for 'actions'
30 (adding service discovery, other views, new node/playlist, save node/playlist) stuff like that
34 /*****************************************************************************
36 *****************************************************************************/
37 #include <stdlib.h> /* malloc(), free() */
38 #include <sys/param.h> /* for MAXPATHLEN */
41 #include <sys/mount.h>
47 #import "playlistinfo.h"
52 #import <vlc_interface.h>
54 /*****************************************************************************
55 * VLCPlaylistView implementation
56 *****************************************************************************/
57 @implementation VLCPlaylistView
59 - (NSMenu *)menuForEvent:(NSEvent *)o_event
61 return( [[self delegate] menuForEvent: o_event] );
64 - (void)keyDown:(NSEvent *)o_event
68 if( [[o_event characters] length] )
70 key = [[o_event characters] characterAtIndex: 0];
75 case NSDeleteCharacter:
76 case NSDeleteFunctionKey:
77 case NSDeleteCharFunctionKey:
78 case NSBackspaceCharacter:
79 [[self delegate] deleteItem:self];
82 case NSEnterCharacter:
83 case NSCarriageReturnCharacter:
84 [(VLCPlaylist *)[[VLCMain sharedInstance] getPlaylist] playItem:self];
88 [super keyDown: o_event];
96 /*****************************************************************************
97 * VLCPlaylistCommon implementation
99 * This class the superclass of the VLCPlaylist and VLCPlaylistWizard.
100 * It contains the common methods and elements of these 2 entities.
101 *****************************************************************************/
102 @implementation VLCPlaylistCommon
109 o_outline_dict = [[NSMutableDictionary alloc] init];
115 playlist_t * p_playlist = pl_Yield( VLCIntf );
116 [o_outline_view setTarget: self];
117 [o_outline_view setDelegate: self];
118 [o_outline_view setDataSource: self];
120 vlc_object_release( p_playlist );
126 [[o_tc_name headerCell] setStringValue:_NS("Name")];
127 [[o_tc_author headerCell] setStringValue:_NS("Author")];
128 [[o_tc_duration headerCell] setStringValue:_NS("Duration")];
131 - (NSOutlineView *)outlineView
133 return o_outline_view;
136 - (playlist_item_t *)selectedPlaylistItem
138 return [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
144 @implementation VLCPlaylistCommon (NSOutlineViewDataSource)
146 /* return the number of children for Obj-C pointer item */ /* DONE */
147 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
150 playlist_item_t *p_item = NULL;
151 playlist_t * p_playlist = pl_Yield( VLCIntf );
152 if( outlineView != o_outline_view )
154 vlc_object_release( p_playlist );
161 p_item = p_playlist->p_root_category;
165 p_item = (playlist_item_t *)[item pointerValue];
168 i_return = p_item->i_children;
169 vlc_object_release( p_playlist );
171 return i_return > 0 ? i_return : 0;
174 /* return the child at index for the Obj-C pointer item */ /* DONE */
175 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
177 playlist_item_t *p_return = NULL, *p_item = NULL;
179 playlist_t * p_playlist = pl_Yield( VLCIntf );
184 p_item = p_playlist->p_root_category;
188 p_item = (playlist_item_t *)[item pointerValue];
190 if( p_item && index < p_item->i_children && index >= 0 )
191 p_return = p_item->pp_children[index];
193 vlc_object_release( p_playlist );
195 o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]];
199 msg_Warn( VLCIntf, "playlist item misses pointer value, adding one" );
200 o_value = [[NSValue valueWithPointer: p_return] retain];
205 /* is the item expandable */
206 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
209 playlist_t *p_playlist = pl_Yield( VLCIntf );
214 if( p_playlist->p_root_category )
216 i_return = p_playlist->p_root_category->i_children;
221 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
223 i_return = p_item->i_children;
225 vlc_object_release( p_playlist );
227 return (i_return > 0);
230 /* retrieve the string values for the cells */
231 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)o_tc byItem:(id)item
234 playlist_item_t *p_item;
236 /* For error handling */
237 static BOOL attempted_reload = NO;
239 if( item == nil || ![item isKindOfClass: [NSValue class]] )
241 /* Attempt to fix the error by asking for a data redisplay
242 * This might cause infinite loop, so add a small check */
243 if( !attempted_reload )
245 attempted_reload = YES;
246 [outlineView reloadData];
251 p_item = (playlist_item_t *)[item pointerValue];
252 if( !p_item || !p_item->p_input )
254 /* Attempt to fix the error by asking for a data redisplay
255 * This might cause infinite loop, so add a small check */
256 if( !attempted_reload )
258 attempted_reload = YES;
259 [outlineView reloadData];
264 attempted_reload = NO;
266 if( [[o_tc identifier] isEqualToString:@"1"] )
268 /* sanity check to prevent the NSString class from crashing */
269 char *psz_title = input_item_GetTitle( p_item->p_input );
270 if( !EMPTY_STR( psz_title ) )
272 o_value = [NSString stringWithUTF8String: psz_title];
276 char *psz_name = input_item_GetName( p_item->p_input );
277 if( psz_name != NULL )
279 o_value = [NSString stringWithUTF8String: psz_name];
287 char *psz_artist = input_item_GetArtist( p_item->p_input );
288 if( [[o_tc identifier] isEqualToString:@"2"] && !EMPTY_STR( psz_artist ) )
290 o_value = [NSString stringWithUTF8String: psz_artist];
292 else if( [[o_tc identifier] isEqualToString:@"3"] )
294 char psz_duration[MSTRTIME_MAX_SIZE];
295 mtime_t dur = input_item_GetDuration( p_item->p_input );
298 secstotimestr( psz_duration, dur/1000000 );
299 o_value = [NSString stringWithUTF8String: psz_duration];
303 o_value = @"-:--:--";
314 /*****************************************************************************
315 * VLCPlaylistWizard implementation
316 *****************************************************************************/
317 @implementation VLCPlaylistWizard
319 - (IBAction)reloadOutlineView
321 /* Only reload the outlineview if the wizard window is open since this can
322 be quite long on big playlists */
323 if( [[o_outline_view window] isVisible] )
325 [o_outline_view reloadData];
331 /*****************************************************************************
332 * extension to NSOutlineView's interface to fix compilation warnings
333 * and let us access these 2 functions properly
334 * this uses a private Apple-API, but works fine on all current OSX releases
335 * keep checking for compatiblity with future releases though
336 *****************************************************************************/
338 @interface NSOutlineView (UndocumentedSortImages)
339 + (NSImage *)_defaultTableHeaderSortImage;
340 + (NSImage *)_defaultTableHeaderReverseSortImage;
344 /*****************************************************************************
345 * VLCPlaylist implementation
346 *****************************************************************************/
347 @implementation VLCPlaylist
354 o_nodes_array = [[NSMutableArray alloc] init];
355 o_items_array = [[NSMutableArray alloc] init];
362 playlist_t * p_playlist = pl_Yield( VLCIntf );
366 [super awakeFromNib];
368 [o_outline_view setDoubleAction: @selector(playItem:)];
370 [o_outline_view registerForDraggedTypes:
371 [NSArray arrayWithObjects: NSFilenamesPboardType,
372 @"VLCPlaylistItemPboardType", nil]];
373 [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
375 /* This uses private Apple API which works fine until 10.4.
376 * We need to keep checking in the future!
377 * These methods are being added artificially to NSOutlineView's interface above */
378 o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
379 o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
381 o_tc_sortColumn = nil;
384 char ** ppsz_services = services_discovery_GetServicesNames( p_playlist, &ppsz_name );
387 vlc_object_release( p_playlist );
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 );
428 - (void)searchfieldChanged:(NSNotification *)o_notification
430 [o_search_field setStringValue:[[o_notification object] stringValue]];
437 [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
438 [o_mi_play setTitle: _NS("Play")];
439 [o_mi_delete setTitle: _NS("Delete")];
440 [o_mi_recursive_expand setTitle: _NS("Expand Node")];
441 [o_mi_selectall setTitle: _NS("Select All")];
442 [o_mi_info setTitle: _NS("Information")];
443 [o_mi_preparse setTitle: _NS("Get Stream Information")];
444 [o_mi_sort_name setTitle: _NS("Sort Node by Name")];
445 [o_mi_sort_author setTitle: _NS("Sort Node by Author")];
446 [o_mi_services setTitle: _NS("Services discovery")];
447 [o_status_field setStringValue: _NS("No items in the playlist")];
449 [o_search_field setToolTip: _NS("Search in Playlist")];
450 [o_mi_addNode setTitle: _NS("Add Folder to Playlist")];
452 [o_save_accessory_text setStringValue: _NS("File Format:")];
453 [[o_save_accessory_popup itemAtIndex:0] setTitle: _NS("Extended M3U")];
454 [[o_save_accessory_popup itemAtIndex:1] setTitle: _NS("XML Shareable Playlist Format (XSPF)")];
457 - (void)playlistUpdated
461 /* Clear indications of any existing column sorting */
462 for( i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )
464 [o_outline_view setIndicatorImage:nil inTableColumn:
465 [[o_outline_view tableColumns] objectAtIndex:i]];
468 [o_outline_view setHighlightedTableColumn:nil];
469 o_tc_sortColumn = nil;
470 // TODO Find a way to keep the dict size to a minimum
471 //[o_outline_dict removeAllObjects];
472 [o_outline_view reloadData];
473 [[[[VLCMain sharedInstance] getWizard] getPlaylistWizard] reloadOutlineView];
474 [[[[VLCMain sharedInstance] getBookmarks] getDataTable] reloadData];
476 playlist_t *p_playlist = pl_Yield( VLCIntf );
478 if( playlist_CurrentSize( p_playlist ) >= 2 )
480 [o_status_field setStringValue: [NSString stringWithFormat:
481 _NS("%i items in the playlist"),
482 playlist_CurrentSize( p_playlist )]];
486 if( playlist_IsEmpty( p_playlist ) )
487 [o_status_field setStringValue: _NS("No items in the playlist")];
489 [o_status_field setStringValue: _NS("1 item in the playlist")];
491 vlc_object_release( p_playlist );
494 - (void)playModeUpdated
496 playlist_t *p_playlist = pl_Yield( VLCIntf );
497 vlc_value_t val, val2;
499 var_Get( p_playlist, "loop", &val2 );
500 var_Get( p_playlist, "repeat", &val );
501 if( val.b_bool == VLC_TRUE )
503 [[[VLCMain sharedInstance] getControls] repeatOne];
505 else if( val2.b_bool == VLC_TRUE )
507 [[[VLCMain sharedInstance] getControls] repeatAll];
511 [[[VLCMain sharedInstance] getControls] repeatOff];
514 [[[VLCMain sharedInstance] getControls] shuffle];
516 vlc_object_release( p_playlist );
519 - (void)updateRowSelection
524 playlist_t *p_playlist = pl_Yield( VLCIntf );
525 playlist_item_t *p_item, *p_temp_item;
526 NSMutableArray *o_array = [NSMutableArray array];
528 p_item = p_playlist->status.p_item;
531 vlc_object_release(p_playlist);
535 p_temp_item = p_item;
536 while( p_temp_item->p_parent )
538 [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
539 p_temp_item = p_temp_item->p_parent;
542 for( j = 0; j < [o_array count] - 1; j++ )
545 if( ( o_item = [o_outline_dict objectForKey:
546 [NSString stringWithFormat: @"%p",
547 [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
549 [o_outline_view expandItem: o_item];
554 vlc_object_release( p_playlist );
556 /* update our info-panel to reflect the new item */
557 [[[VLCMain sharedInstance] getInfo] updatePanel];
560 /* Check if p_item is a child of p_node recursively. We need to check the item
561 existence first since OSX sometimes tries to redraw items that have been
562 deleted. We don't do it when not required since this verification takes
563 quite a long time on big playlists (yes, pretty hacky). */
564 - (BOOL)isItem: (playlist_item_t *)p_item
565 inNode: (playlist_item_t *)p_node
566 checkItemExistence:(BOOL)b_check
569 playlist_t * p_playlist = pl_Yield( VLCIntf );
570 playlist_item_t *p_temp_item = p_item;
572 if( p_node == p_item )
574 vlc_object_release(p_playlist);
578 if( p_node->i_children < 1)
580 vlc_object_release(p_playlist);
587 vlc_mutex_lock( &p_playlist->object_lock );
591 /* Since outlineView: willDisplayCell:... may call this function with
592 p_items that don't exist anymore, first check if the item is still
593 in the playlist. Any cleaner solution welcomed. */
594 for( i = 0; i < p_playlist->all_items.i_size; i++ )
596 if( ARRAY_VAL( p_playlist->all_items, i) == p_item ) break;
597 else if ( i == p_playlist->all_items.i_size - 1 )
599 vlc_object_release( p_playlist );
600 vlc_mutex_unlock( &p_playlist->object_lock );
608 p_temp_item = p_temp_item->p_parent;
609 if( p_temp_item == p_node )
611 vlc_mutex_unlock( &p_playlist->object_lock );
612 vlc_object_release( p_playlist );
616 vlc_mutex_unlock( &p_playlist->object_lock );
619 vlc_object_release( p_playlist );
623 /* This method is usefull for instance to remove the selected children of an
624 already selected node */
625 - (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
628 for( i = 0 ; i < [o_items count] ; i++ )
630 for ( j = 0 ; j < [o_nodes count] ; j++ )
632 if( o_items == o_nodes)
634 if( j == i ) continue;
636 if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
637 inNode: [[o_nodes objectAtIndex:j] pointerValue]
638 checkItemExistence: NO] )
640 [o_items removeObjectAtIndex:i];
641 /* We need to execute the next iteration with the same index
642 since the current item has been deleted */
651 - (IBAction)savePlaylist:(id)sender
653 playlist_t * p_playlist = pl_Yield( VLCIntf );
655 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
656 NSString * o_name = [NSString stringWithFormat: @"%@", _NS("Untitled")];
658 //[o_save_panel setAllowedFileTypes: [NSArray arrayWithObjects: @"m3u", @"xpf", nil] ];
659 [o_save_panel setTitle: _NS("Save Playlist")];
660 [o_save_panel setPrompt: _NS("Save")];
661 [o_save_panel setAccessoryView: o_save_accessory_view];
663 if( [o_save_panel runModalForDirectory: nil
664 file: o_name] == NSOKButton )
666 NSString *o_filename = [o_save_panel filename];
668 if( [o_save_accessory_popup indexOfSelectedItem] == 1 )
670 NSString * o_real_filename;
672 range.location = [o_filename length] - [@".xspf" length];
673 range.length = [@".xspf" length];
675 if( [o_filename compare:@".xspf" options: NSCaseInsensitiveSearch
676 range: range] != NSOrderedSame )
678 o_real_filename = [NSString stringWithFormat: @"%@.xspf", o_filename];
682 o_real_filename = o_filename;
684 playlist_Export( p_playlist,
685 [o_real_filename fileSystemRepresentation],
686 p_playlist->p_local_category, "export-xspf" );
690 NSString * o_real_filename;
692 range.location = [o_filename length] - [@".m3u" length];
693 range.length = [@".m3u" length];
695 if( [o_filename compare:@".m3u" options: NSCaseInsensitiveSearch
696 range: range] != NSOrderedSame )
698 o_real_filename = [NSString stringWithFormat: @"%@.m3u", o_filename];
702 o_real_filename = o_filename;
704 playlist_Export( p_playlist,
705 [o_real_filename fileSystemRepresentation],
706 p_playlist->p_local_category, "export-m3u" );
709 vlc_object_release( p_playlist );
712 /* When called retrieves the selected outlineview row and plays that node or item */
713 - (IBAction)playItem:(id)sender
715 intf_thread_t * p_intf = VLCIntf;
716 playlist_t * p_playlist = pl_Yield( p_intf );
718 playlist_item_t *p_item;
719 playlist_item_t *p_node = NULL;
721 p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
725 if( p_item->i_children == -1 )
727 p_node = p_item->p_parent;
733 if( p_node->i_children > 0 && p_node->pp_children[0]->i_children == -1 )
735 p_item = p_node->pp_children[0];
742 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_node, p_item );
744 vlc_object_release( p_playlist );
747 /* When called retrieves the selected outlineview row and plays that node or item */
748 - (IBAction)preparseItem:(id)sender
751 NSMutableArray *o_to_preparse;
752 intf_thread_t * p_intf = VLCIntf;
753 playlist_t * p_playlist = pl_Yield( p_intf );
755 o_to_preparse = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
756 i_count = [o_to_preparse count];
760 playlist_item_t *p_item = NULL;
762 for( i = 0; i < i_count; i++ )
764 o_number = [o_to_preparse lastObject];
765 i_row = [o_number intValue];
766 p_item = [[o_outline_view itemAtRow:i_row] pointerValue];
767 [o_to_preparse removeObject: o_number];
768 [o_outline_view deselectRow: i_row];
772 if( p_item->i_children == -1 )
774 playlist_PreparseEnqueue( p_playlist, p_item->p_input );
778 msg_Dbg( p_intf, "preparsing nodes not implemented" );
782 vlc_object_release( p_playlist );
783 [self playlistUpdated];
786 - (IBAction)servicesChange:(id)sender
788 NSMenuItem *o_mi = (NSMenuItem *)sender;
789 NSString *o_string = [o_mi representedObject];
790 playlist_t * p_playlist = pl_Yield( VLCIntf );
791 if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string UTF8String] ) )
792 playlist_ServicesDiscoveryAdd( p_playlist, [o_string UTF8String] );
794 playlist_ServicesDiscoveryRemove( p_playlist, [o_string UTF8String] );
796 [o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,
797 [o_string UTF8String] ) ? YES : NO];
799 vlc_object_release( p_playlist );
800 [self playlistUpdated];
804 - (IBAction)selectAll:(id)sender
806 [o_outline_view selectAll: nil];
809 - (IBAction)deleteItem:(id)sender
812 NSMutableArray *o_to_delete;
815 playlist_t * p_playlist;
816 intf_thread_t * p_intf = VLCIntf;
818 o_to_delete = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
819 i_count = [o_to_delete count];
821 p_playlist = pl_Yield( p_intf );
824 for( int i = 0; i < i_count; i++ )
826 o_number = [o_to_delete lastObject];
827 i_row = [o_number intValue];
828 id o_item = [o_outline_view itemAtRow: i_row];
829 playlist_item_t *p_item = [o_item pointerValue];
831 msg_Dbg( p_intf, "deleting item %i (of %i) with id \"%i\", pointerValue \"%p\" and %i children", i+1, i_count,
832 p_item->p_input->i_id, [o_item pointerValue], p_item->i_children +1 );
834 [o_to_delete removeObject: o_number];
835 [o_outline_view deselectRow: i_row];
837 if( p_item->i_children != -1 )
838 //is a node and not an item
840 if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
841 [self isItem: p_playlist->status.p_item inNode:
842 ((playlist_item_t *)[o_item pointerValue])
843 checkItemExistence: NO] == YES )
844 // if current item is in selected node and is playing then stop playlist
845 playlist_Stop( p_playlist );
847 playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
850 playlist_DeleteFromInput( p_playlist, p_item->p_input->i_id, VLC_TRUE );
854 [self playlistUpdated];
855 vlc_object_release( p_playlist );
858 - (IBAction)sortNodeByName:(id)sender
860 [self sortNode: SORT_TITLE];
863 - (IBAction)sortNodeByAuthor:(id)sender
865 [self sortNode: SORT_ARTIST];
868 - (void)sortNode:(int)i_mode
870 playlist_t * p_playlist = pl_Yield( VLCIntf );
871 playlist_item_t * p_item;
873 if( [o_outline_view selectedRow] > -1 )
875 p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]] pointerValue];
878 /*If no item is selected, sort the whole playlist*/
880 p_item = p_playlist->p_root_category;
883 if( p_item->i_children > -1 ) // the item is a node
885 vlc_mutex_lock( &p_playlist->object_lock );
886 playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
887 vlc_mutex_unlock( &p_playlist->object_lock );
891 vlc_mutex_lock( &p_playlist->object_lock );
892 playlist_RecursiveNodeSort( p_playlist,
893 p_item->p_parent, i_mode, ORDER_NORMAL );
894 vlc_mutex_unlock( &p_playlist->object_lock );
896 vlc_object_release( p_playlist );
897 [self playlistUpdated];
900 - (input_item_t *)createItem:(NSDictionary *)o_one_item
902 intf_thread_t * p_intf = VLCIntf;
903 playlist_t * p_playlist = pl_Yield( p_intf );
905 input_item_t *p_input;
907 BOOL b_rem = FALSE, b_dir = FALSE;
908 NSString *o_uri, *o_name;
913 o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
914 o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
915 o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
917 /* Find the name for a disc entry (i know, can you believe the trouble?) */
918 if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound )
920 int i_count, i_index;
921 struct statfs *mounts = NULL;
923 i_count = getmntinfo (&mounts, MNT_NOWAIT);
924 /* getmntinfo returns a pointer to static data. Do not free. */
925 for( i_index = 0 ; i_index < i_count; i_index++ )
927 NSMutableString *o_temp, *o_temp2;
928 o_temp = [NSMutableString stringWithString: o_uri];
929 o_temp2 = [NSMutableString stringWithUTF8String: mounts[i_index].f_mntfromname];
930 [o_temp replaceOccurrencesOfString: @"/dev/rdisk" withString: @"/dev/disk" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
931 [o_temp2 replaceOccurrencesOfString: @"s0" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp2 length]) ];
932 [o_temp2 replaceOccurrencesOfString: @"s1" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp2 length]) ];
934 if( strstr( [o_temp fileSystemRepresentation], [o_temp2 fileSystemRepresentation] ) != NULL )
936 o_name = [[NSFileManager defaultManager] displayNameAtPath: [NSString stringWithUTF8String:mounts[i_index].f_mntonname]];
940 /* If no name, then make a guess */
941 if( !o_name) o_name = [[NSFileManager defaultManager] displayNameAtPath: o_uri];
943 if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
944 [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
945 isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem )
947 /* All of this is to make sure CD's play when you D&D them on VLC */
948 /* Converts mountpoint to a /dev file */
951 NSMutableString *o_temp;
953 buf = (struct statfs *) malloc (sizeof(struct statfs));
954 statfs( [o_uri fileSystemRepresentation], buf );
955 psz_dev = strdup(buf->f_mntfromname);
956 o_temp = [NSMutableString stringWithUTF8String: psz_dev ];
957 [o_temp replaceOccurrencesOfString: @"/dev/disk" withString: @"/dev/rdisk" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
958 [o_temp replaceOccurrencesOfString: @"s0" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
959 [o_temp replaceOccurrencesOfString: @"s1" withString: @"" options:NSLiteralSearch range:NSMakeRange(0, [o_temp length]) ];
963 p_input = input_ItemNew( p_playlist, [o_uri fileSystemRepresentation], [o_name UTF8String] );
969 for( i = 0; i < (int)[o_options count]; i++ )
971 input_ItemAddOption( p_input, strdup( [[o_options objectAtIndex:i] UTF8String] ) );
975 /* Recent documents menu */
976 o_true_file = [NSURL fileURLWithPath: o_uri];
977 if( o_true_file != nil && (BOOL)config_GetInt( p_playlist, "macosx-recentitems" ) == YES )
979 [[NSDocumentController sharedDocumentController]
980 noteNewRecentDocumentURL: o_true_file];
983 vlc_object_release( p_playlist );
987 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
990 playlist_t * p_playlist = pl_Yield( VLCIntf );
992 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
994 input_item_t *p_input;
995 NSDictionary *o_one_item;
998 o_one_item = [o_array objectAtIndex: i_item];
999 p_input = [self createItem: o_one_item];
1006 /* FIXME: playlist_AddInput() can fail */
1007 playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
1008 i_position == -1 ? PLAYLIST_END : i_position + i_item, VLC_TRUE,
1011 if( i_item == 0 && !b_enqueue )
1013 playlist_item_t *p_item;
1014 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1015 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
1019 playlist_item_t *p_item;
1020 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1021 playlist_Control( p_playlist, PLAYLIST_SKIP, VLC_TRUE, p_item );
1023 vlc_gc_decref( p_input );
1025 [self playlistUpdated];
1026 vlc_object_release( p_playlist );
1029 - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue
1032 playlist_t * p_playlist = pl_Yield( VLCIntf );
1034 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
1036 input_item_t *p_input;
1037 NSDictionary *o_one_item;
1040 o_one_item = [o_array objectAtIndex: i_item];
1041 p_input = [self createItem: o_one_item];
1048 /* FIXME: playlist_NodeAddInput() can fail */
1049 playlist_NodeAddInput( p_playlist, p_input, p_node,
1052 PLAYLIST_END : i_position + i_item, VLC_FALSE );
1055 if( i_item == 0 && !b_enqueue )
1057 playlist_item_t *p_item;
1058 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1059 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
1063 playlist_item_t *p_item;
1064 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1065 playlist_Control( p_playlist, PLAYLIST_SKIP, VLC_TRUE, p_item );
1067 vlc_gc_decref( p_input );
1069 [self playlistUpdated];
1070 vlc_object_release( p_playlist );
1073 - (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
1075 playlist_t *p_playlist = pl_Yield( VLCIntf );
1076 playlist_item_t *p_selected_item;
1077 int i_current, i_selected_row;
1079 i_selected_row = [o_outline_view selectedRow];
1080 if (i_selected_row < 0)
1083 p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow:
1084 i_selected_row] pointerValue];
1086 for( i_current = 0; i_current < p_item->i_children ; i_current++ )
1089 NSString *o_current_name, *o_current_author;
1091 vlc_mutex_lock( &p_playlist->object_lock );
1092 o_current_name = [NSString stringWithUTF8String:
1093 p_item->pp_children[i_current]->p_input->psz_name];
1094 psz_temp = input_ItemGetInfo( p_item->p_input ,
1095 _("Meta-information"),_("Artist") );
1096 o_current_author = [NSString stringWithUTF8String: psz_temp];
1098 vlc_mutex_unlock( &p_playlist->object_lock );
1100 if( p_selected_item == p_item->pp_children[i_current] &&
1101 b_selected_item_met == NO )
1103 b_selected_item_met = YES;
1105 else if( p_selected_item == p_item->pp_children[i_current] &&
1106 b_selected_item_met == YES )
1108 vlc_object_release( p_playlist );
1111 else if( b_selected_item_met == YES &&
1112 ( [o_current_name rangeOfString:[o_search_field
1113 stringValue] options:NSCaseInsensitiveSearch ].length ||
1114 [o_current_author rangeOfString:[o_search_field
1115 stringValue] options:NSCaseInsensitiveSearch ].length ) )
1117 vlc_object_release( p_playlist );
1118 /*Adds the parent items in the result array as well, so that we can
1120 return [NSMutableArray arrayWithObject: [NSValue
1121 valueWithPointer: p_item->pp_children[i_current]]];
1123 if( p_item->pp_children[i_current]->i_children > 0 )
1125 id o_result = [self subSearchItem:
1126 p_item->pp_children[i_current]];
1127 if( o_result != NULL )
1129 vlc_object_release( p_playlist );
1130 [o_result insertObject: [NSValue valueWithPointer:
1131 p_item->pp_children[i_current]] atIndex:0];
1136 vlc_object_release( p_playlist );
1140 - (IBAction)searchItem:(id)sender
1142 playlist_t * p_playlist = pl_Yield( VLCIntf );
1148 b_selected_item_met = NO;
1150 /*First, only search after the selected item:*
1151 *(b_selected_item_met = NO) */
1152 o_result = [self subSearchItem:p_playlist->p_root_category];
1153 if( o_result == NULL )
1155 /* If the first search failed, search again from the beginning */
1156 o_result = [self subSearchItem:p_playlist->p_root_category];
1158 if( o_result != NULL )
1161 if( [[o_result objectAtIndex: 0] pointerValue] ==
1162 p_playlist->p_local_category )
1167 for( i = i_start ; i < [o_result count] - 1 ; i++ )
1169 [o_outline_view expandItem: [o_outline_dict objectForKey:
1170 [NSString stringWithFormat: @"%p",
1171 [[o_result objectAtIndex: i] pointerValue]]]];
1173 i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey:
1174 [NSString stringWithFormat: @"%p",
1175 [[o_result objectAtIndex: [o_result count] - 1 ]
1180 [o_outline_view selectRow:i_row byExtendingSelection: NO];
1181 [o_outline_view scrollRowToVisible: i_row];
1183 vlc_object_release( p_playlist );
1186 - (IBAction)recursiveExpandNode:(id)sender
1188 id o_item = [o_outline_view itemAtRow: [o_outline_view selectedRow]];
1189 playlist_item_t *p_item = (playlist_item_t *)[o_item pointerValue];
1191 if( ![[o_outline_view dataSource] outlineView: o_outline_view
1192 isItemExpandable: o_item] )
1194 o_item = [o_outline_dict objectForKey: [NSString
1195 stringWithFormat: @"%p", p_item->p_parent]];
1198 /* We need to collapse the node first, since OSX refuses to recursively
1199 expand an already expanded node, even if children nodes are collapsed. */
1200 [o_outline_view collapseItem: o_item collapseChildren: YES];
1201 [o_outline_view expandItem: o_item expandChildren: YES];
1204 - (NSMenu *)menuForEvent:(NSEvent *)o_event
1208 vlc_bool_t b_item_sel;
1210 pt = [o_outline_view convertPoint: [o_event locationInWindow]
1212 b_item_sel = ( [o_outline_view rowAtPoint: pt] != -1 &&
1213 [o_outline_view selectedRow] != -1 );
1214 b_rows = [o_outline_view numberOfRows] != 0;
1216 [o_mi_play setEnabled: b_item_sel];
1217 [o_mi_delete setEnabled: b_item_sel];
1218 [o_mi_selectall setEnabled: b_rows];
1219 [o_mi_info setEnabled: b_item_sel];
1220 [o_mi_preparse setEnabled: b_item_sel];
1221 [o_mi_recursive_expand setEnabled: b_item_sel];
1222 [o_mi_sort_name setEnabled: b_item_sel];
1223 [o_mi_sort_author setEnabled: b_item_sel];
1225 return( o_ctx_menu );
1228 - (void)outlineView: (NSTableView*)o_tv
1229 didClickTableColumn:(NSTableColumn *)o_tc
1231 int i_mode = 0, i_type;
1232 intf_thread_t *p_intf = VLCIntf;
1234 playlist_t *p_playlist = pl_Yield( p_intf );
1236 /* Check whether the selected table column header corresponds to a
1237 sortable table column*/
1238 if( !( o_tc == o_tc_name || o_tc == o_tc_author ) )
1240 vlc_object_release( p_playlist );
1244 if( o_tc_sortColumn == o_tc )
1246 b_isSortDescending = !b_isSortDescending;
1250 b_isSortDescending = VLC_FALSE;
1253 if( o_tc == o_tc_name )
1255 i_mode = SORT_TITLE;
1257 else if( o_tc == o_tc_author )
1259 i_mode = SORT_ARTIST;
1262 if( b_isSortDescending )
1264 i_type = ORDER_REVERSE;
1268 i_type = ORDER_NORMAL;
1271 vlc_mutex_lock( &p_playlist->object_lock );
1272 playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_category, i_mode, i_type );
1273 vlc_mutex_unlock( &p_playlist->object_lock );
1275 vlc_object_release( p_playlist );
1276 [self playlistUpdated];
1278 o_tc_sortColumn = o_tc;
1279 [o_outline_view setHighlightedTableColumn:o_tc];
1281 if( b_isSortDescending )
1283 [o_outline_view setIndicatorImage:o_descendingSortingImage
1284 inTableColumn:o_tc];
1288 [o_outline_view setIndicatorImage:o_ascendingSortingImage
1289 inTableColumn:o_tc];
1294 - (void)outlineView:(NSOutlineView *)outlineView
1295 willDisplayCell:(id)cell
1296 forTableColumn:(NSTableColumn *)tableColumn
1299 playlist_t *p_playlist = pl_Yield( VLCIntf );
1303 o_playing_item = [o_outline_dict objectForKey:
1304 [NSString stringWithFormat:@"%p", p_playlist->status.p_item]];
1306 if( [self isItem: [o_playing_item pointerValue] inNode:
1307 [item pointerValue] checkItemExistence: YES]
1308 || [o_playing_item isEqual: item] )
1310 [cell setFont: [NSFont boldSystemFontOfSize: 0]];
1314 [cell setFont: [NSFont systemFontOfSize: 0]];
1316 vlc_object_release( p_playlist );
1319 - (IBAction)addNode:(id)sender
1321 /* we have to create a new thread here because otherwise we would block the
1322 * interface since the interaction-stuff and this code would run in the same
1324 [NSThread detachNewThreadSelector: @selector(addNodeThreadedly)
1325 toTarget: self withObject:nil];
1326 [self playlistUpdated];
1329 - (void)addNodeThreadedly
1331 NSAutoreleasePool * ourPool = [[NSAutoreleasePool alloc] init];
1333 /* simply adds a new node to the end of the playlist */
1334 playlist_t * p_playlist = pl_Yield( VLCIntf );
1335 vlc_thread_set_priority( p_playlist, VLC_THREAD_PRIORITY_LOW );
1338 char *psz_name = NULL;
1339 playlist_item_t * p_item;
1340 ret_v = intf_UserStringInput( p_playlist, _("New Node"),
1341 _("Please enter a name for the new node."), &psz_name );
1343 if( psz_name != NULL && psz_name != "" )
1344 p_item = playlist_NodeCreate( p_playlist, psz_name,
1345 p_playlist->p_local_category, 0, NULL );
1346 else if(! config_GetInt( p_playlist, "interact" ) )
1348 /* in case that the interaction is disabled, just give it a bogus name */
1349 p_item = playlist_NodeCreate( p_playlist, _("Empty Folder"),
1350 p_playlist->p_local_category, 0, NULL );
1354 msg_Warn( VLCIntf, "node creation failed or cancelled by user" );
1356 vlc_object_release( p_playlist );
1362 @implementation VLCPlaylist (NSOutlineViewDataSource)
1364 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
1366 id o_value = [super outlineView: outlineView child: index ofItem: item];
1367 playlist_t *p_playlist = pl_Yield( VLCIntf );
1369 if( playlist_CurrentSize( p_playlist ) >= 2 )
1371 [o_status_field setStringValue: [NSString stringWithFormat:
1372 _NS("%i items in the playlist"),
1373 playlist_CurrentSize( p_playlist )]];
1377 if( playlist_IsEmpty( p_playlist ) )
1379 [o_status_field setStringValue: _NS("No items in the playlist")];
1383 [o_status_field setStringValue: _NS("1 item in the playlist")];
1386 vlc_object_release( p_playlist );
1388 [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p",
1389 [o_value pointerValue]]];
1391 msg_Dbg( VLCIntf, "adding item %p", [o_value pointerValue] );
1397 /* Required for drag & drop and reordering */
1398 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
1401 playlist_t *p_playlist = pl_Yield( VLCIntf );
1403 /* First remove the items that were moved during the last drag & drop
1405 [o_items_array removeAllObjects];
1406 [o_nodes_array removeAllObjects];
1408 for( i = 0 ; i < [items count] ; i++ )
1410 id o_item = [items objectAtIndex: i];
1412 /* Refuse to move items that are not in the General Node
1413 (Service Discovery) */
1414 if( ![self isItem: [o_item pointerValue] inNode:
1415 p_playlist->p_local_category checkItemExistence: NO] &&
1416 ( var_CreateGetBool( p_playlist, "media-library" ) &&
1417 ![self isItem: [o_item pointerValue] inNode:
1418 p_playlist->p_ml_category checkItemExistence: NO]) )
1420 vlc_object_release(p_playlist);
1423 /* Fill the items and nodes to move in 2 different arrays */
1424 if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 )
1425 [o_nodes_array addObject: o_item];
1427 [o_items_array addObject: o_item];
1430 /* Now we need to check if there are selected items that are in already
1431 selected nodes. In that case, we only want to move the nodes */
1432 [self removeItemsFrom: o_nodes_array ifChildrenOf: o_nodes_array];
1433 [self removeItemsFrom: o_items_array ifChildrenOf: o_nodes_array];
1435 /* We add the "VLCPlaylistItemPboardType" type to be able to recognize
1436 a Drop operation coming from the playlist. */
1438 [pboard declareTypes: [NSArray arrayWithObjects:
1439 @"VLCPlaylistItemPboardType", nil] owner: self];
1440 [pboard setData:[NSData data] forType:@"VLCPlaylistItemPboardType"];
1442 vlc_object_release(p_playlist);
1446 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
1448 playlist_t *p_playlist = pl_Yield( VLCIntf );
1449 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1451 if( !p_playlist ) return NSDragOperationNone;
1453 /* Dropping ON items is not allowed if item is not a node */
1456 if( index == NSOutlineViewDropOnItemIndex &&
1457 ((playlist_item_t *)[item pointerValue])->i_children == -1 )
1459 vlc_object_release( p_playlist );
1460 return NSDragOperationNone;
1464 /* Don't allow on drop on playlist root element's child */
1465 if( !item && index != NSOutlineViewDropOnItemIndex)
1467 vlc_object_release( p_playlist );
1468 return NSDragOperationNone;
1471 /* We refuse to drop an item in anything else than a child of the General
1472 Node. We still accept items that would be root nodes of the outlineview
1473 however, to allow drop in an empty playlist. */
1474 if( !( ([self isItem: [item pointerValue] inNode: p_playlist->p_local_category checkItemExistence: NO] ||
1475 ( var_CreateGetBool( p_playlist, "media-library" ) && [self isItem: [item pointerValue] inNode: p_playlist->p_ml_category checkItemExistence: NO] ) ) || item == nil ) )
1477 vlc_object_release( p_playlist );
1478 return NSDragOperationNone;
1481 /* Drop from the Playlist */
1482 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1485 for( i = 0 ; i < [o_nodes_array count] ; i++ )
1487 /* We refuse to Drop in a child of an item we are moving */
1488 if( [self isItem: [item pointerValue] inNode:
1489 [[o_nodes_array objectAtIndex: i] pointerValue]
1490 checkItemExistence: NO] )
1492 vlc_object_release( p_playlist );
1493 return NSDragOperationNone;
1496 vlc_object_release( p_playlist );
1497 return NSDragOperationMove;
1500 /* Drop from the Finder */
1501 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1503 vlc_object_release( p_playlist );
1504 return NSDragOperationGeneric;
1506 vlc_object_release( p_playlist );
1507 return NSDragOperationNone;
1510 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index
1512 playlist_t * p_playlist = pl_Yield( VLCIntf );
1513 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1515 /* Drag & Drop inside the playlist */
1516 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1518 int i_row, i_removed_from_node = 0;
1520 playlist_item_t *p_new_parent, *p_item = NULL;
1521 NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
1523 /* If the item is to be dropped as root item of the outline, make it a
1524 child of the General node.
1525 Else, choose the proposed parent as parent. */
1526 if( item == nil ) p_new_parent = p_playlist->p_local_category;
1527 else p_new_parent = [item pointerValue];
1529 /* Make sure the proposed parent is a node.
1530 (This should never be true) */
1531 if( p_new_parent->i_children < 0 )
1533 vlc_object_release( p_playlist );
1537 for( i = 0; i < [o_all_items count]; i++ )
1539 playlist_item_t *p_old_parent = NULL;
1540 int i_old_index = 0;
1542 p_item = [[o_all_items objectAtIndex:i] pointerValue];
1543 p_old_parent = p_item->p_parent;
1546 /* We may need the old index later */
1547 if( p_new_parent == p_old_parent )
1550 for( j = 0; j < p_old_parent->i_children; j++ )
1552 if( p_old_parent->pp_children[j] == p_item )
1560 vlc_mutex_lock( &p_playlist->object_lock );
1561 // Acually detach the item from the old position
1562 if( playlist_NodeRemoveItem( p_playlist, p_item, p_old_parent ) ==
1566 /* Calculate the new index */
1569 /* If we move the item in the same node, we need to take into
1570 account that one item will be deleted */
1573 if ((p_new_parent == p_old_parent &&
1574 i_old_index < index + (int)i) )
1576 i_removed_from_node++;
1578 i_new_index = index + i - i_removed_from_node;
1580 // Reattach the item to the new position
1581 playlist_NodeInsert( p_playlist, p_item, p_new_parent, i_new_index );
1583 vlc_mutex_unlock( &p_playlist->object_lock );
1585 [self playlistUpdated];
1586 i_row = [o_outline_view rowForItem:[o_outline_dict
1587 objectForKey:[NSString stringWithFormat: @"%p",
1588 [[o_all_items objectAtIndex: 0] pointerValue]]]];
1592 i_row = [o_outline_view rowForItem:[o_outline_dict
1593 objectForKey:[NSString stringWithFormat: @"%p", p_new_parent]]];
1596 [o_outline_view deselectAll: self];
1597 [o_outline_view selectRow: i_row byExtendingSelection: NO];
1598 [o_outline_view scrollRowToVisible: i_row];
1600 vlc_object_release( p_playlist );
1604 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1607 playlist_item_t *p_node = [item pointerValue];
1609 NSArray *o_array = [NSArray array];
1610 NSArray *o_values = [[o_pasteboard propertyListForType:
1611 NSFilenamesPboardType]
1612 sortedArrayUsingSelector:
1613 @selector(caseInsensitiveCompare:)];
1615 for( i = 0; i < (int)[o_values count]; i++)
1617 NSDictionary *o_dic;
1618 o_dic = [NSDictionary dictionaryWithObject:[o_values
1619 objectAtIndex:i] forKey:@"ITEM_URL"];
1620 o_array = [o_array arrayByAddingObject: o_dic];
1625 [self appendArray: o_array atPos: index enqueue: YES];
1627 /* This should never occur */
1628 else if( p_node->i_children == -1 )
1630 vlc_object_release( p_playlist );
1635 [self appendNodeArray: o_array inNode: p_node
1636 atPos: index enqueue: YES];
1638 vlc_object_release( p_playlist );
1641 vlc_object_release( p_playlist );