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] playItem:self];
89 [super keyDown: o_event];
97 /*****************************************************************************
98 * VLCPlaylistCommon implementation
100 * This class the superclass of the VLCPlaylist and VLCPlaylistWizard.
101 * It contains the common methods and elements of these 2 entities.
102 *****************************************************************************/
103 @implementation VLCPlaylistCommon
110 o_outline_dict = [[NSMutableDictionary alloc] init];
116 playlist_t * p_playlist = pl_Yield( VLCIntf );
117 [o_outline_view setTarget: self];
118 [o_outline_view setDelegate: self];
119 [o_outline_view setDataSource: self];
121 vlc_object_release( p_playlist );
127 [[o_tc_name headerCell] setStringValue:_NS("Name")];
128 [[o_tc_author headerCell] setStringValue:_NS("Author")];
129 [[o_tc_duration headerCell] setStringValue:_NS("Duration")];
132 - (NSOutlineView *)outlineView
134 return o_outline_view;
137 - (playlist_item_t *)selectedPlaylistItem
139 return [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
145 @implementation VLCPlaylistCommon (NSOutlineViewDataSource)
147 /* return the number of children for Obj-C pointer item */ /* DONE */
148 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
151 playlist_item_t *p_item = NULL;
152 playlist_t * p_playlist = pl_Yield( VLCIntf );
153 if( outlineView != o_outline_view )
155 vlc_object_release( p_playlist );
162 p_item = p_playlist->p_root_category;
166 p_item = (playlist_item_t *)[item pointerValue];
169 i_return = p_item->i_children;
170 vlc_object_release( p_playlist );
178 /* return the child at index for the Obj-C pointer item */ /* DONE */
179 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
181 playlist_item_t *p_return = NULL, *p_item = NULL;
183 playlist_t * p_playlist = pl_Yield( VLCIntf );
188 p_item = p_playlist->p_root_category;
192 p_item = (playlist_item_t *)[item pointerValue];
194 if( p_item && index < p_item->i_children && index >= 0 )
195 p_return = p_item->pp_children[index];
197 vlc_object_release( p_playlist );
199 o_value = [o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", p_return]];
203 msg_Warn( VLCIntf, "playlist item misses pointer value, adding one" );
204 o_value = [[NSValue valueWithPointer: p_return] retain];
209 /* is the item expandable */
210 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
213 playlist_t *p_playlist = pl_Yield( VLCIntf );
218 if( p_playlist->p_root_category )
220 i_return = p_playlist->p_root_category->i_children;
225 playlist_item_t *p_item = (playlist_item_t *)[item pointerValue];
227 i_return = p_item->i_children;
229 vlc_object_release( p_playlist );
231 return (i_return > 0);
234 /* retrieve the string values for the cells */
235 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)o_tc byItem:(id)item
238 playlist_item_t *p_item;
240 /* For error handling */
241 static BOOL attempted_reload = NO;
243 if( item == nil || ![item isKindOfClass: [NSValue class]] )
245 /* Attempt to fix the error by asking for a data redisplay
246 * This might cause infinite loop, so add a small check */
247 if( !attempted_reload )
249 attempted_reload = YES;
250 [outlineView reloadData];
255 p_item = (playlist_item_t *)[item pointerValue];
256 if( !p_item || !p_item->p_input )
258 /* Attempt to fix the error by asking for a data redisplay
259 * This might cause infinite loop, so add a small check */
260 if( !attempted_reload )
262 attempted_reload = YES;
263 [outlineView reloadData];
268 attempted_reload = NO;
270 if( [[o_tc identifier] isEqualToString:@"1"] )
272 /* sanity check to prevent the NSString class from crashing */
273 char *psz_title = input_item_GetTitle( p_item->p_input );
274 if( !EMPTY_STR( psz_title ) )
276 o_value = [NSString stringWithUTF8String: psz_title];
280 char *psz_name = input_item_GetName( p_item->p_input );
281 if( psz_name != NULL )
283 o_value = [NSString stringWithUTF8String: psz_name];
291 char *psz_artist = input_item_GetArtist( p_item->p_input );
292 if( [[o_tc identifier] isEqualToString:@"2"] && !EMPTY_STR( psz_artist ) )
294 o_value = [NSString stringWithUTF8String: psz_artist];
296 else if( [[o_tc identifier] isEqualToString:@"3"] )
298 char psz_duration[MSTRTIME_MAX_SIZE];
299 mtime_t dur = input_item_GetDuration( p_item->p_input );
302 secstotimestr( psz_duration, dur/1000000 );
303 o_value = [NSString stringWithUTF8String: psz_duration];
307 o_value = @"-:--:--";
318 /*****************************************************************************
319 * VLCPlaylistWizard implementation
320 *****************************************************************************/
321 @implementation VLCPlaylistWizard
323 - (IBAction)reloadOutlineView
325 /* Only reload the outlineview if the wizard window is open since this can
326 be quite long on big playlists */
327 if( [[o_outline_view window] isVisible] )
329 [o_outline_view reloadData];
335 /*****************************************************************************
336 * extension to NSOutlineView's interface to fix compilation warnings
337 * and let us access these 2 functions properly
338 * this uses a private Apple-API, but works fine on all current OSX releases
339 * keep checking for compatiblity with future releases though
340 *****************************************************************************/
342 @interface NSOutlineView (UndocumentedSortImages)
343 + (NSImage *)_defaultTableHeaderSortImage;
344 + (NSImage *)_defaultTableHeaderReverseSortImage;
348 /*****************************************************************************
349 * VLCPlaylist implementation
350 *****************************************************************************/
351 @implementation VLCPlaylist
358 o_nodes_array = [[NSMutableArray alloc] init];
359 o_items_array = [[NSMutableArray alloc] init];
366 playlist_t * p_playlist = pl_Yield( VLCIntf );
370 [super awakeFromNib];
372 [o_outline_view setDoubleAction: @selector(playItem:)];
374 [o_outline_view registerForDraggedTypes:
375 [NSArray arrayWithObjects: NSFilenamesPboardType,
376 @"VLCPlaylistItemPboardType", nil]];
377 [o_outline_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
379 /* this uses private Apple API which works fine until 10.4,
380 * but keep checking in the future!
381 * These methods are being added artificially to NSOutlineView's interface above */
382 o_ascendingSortingImage = [[NSOutlineView class] _defaultTableHeaderSortImage];
383 o_descendingSortingImage = [[NSOutlineView class] _defaultTableHeaderReverseSortImage];
385 o_tc_sortColumn = nil;
388 char ** ppsz_services = services_discovery_GetServicesNames( p_playlist, &ppsz_name );
390 for( i = 0; ppsz_services[i]; i++ )
392 vlc_bool_t b_enabled;
396 char * name = ppsz_name[i] ? ppsz_name[i] : ppsz_services[i];
397 /* Check whether to enable these menuitems */
398 b_enabled = playlist_IsServicesDiscoveryLoaded( p_playlist, objectname );
400 /* Create the menu entries used in the playlist menu */
401 o_lmi = [[o_mi_services submenu] addItemWithTitle:
402 [NSString stringWithUTF8String: name]
403 action: @selector(servicesChange:)
405 [o_lmi setTarget: self];
406 [o_lmi setRepresentedObject: [NSString stringWithUTF8String: ppsz_services[i]]];
407 if( b_enabled ) [o_lmi setState: NSOnState];
409 /* Create the menu entries for the main menu */
410 o_lmi = [[o_mm_mi_services submenu] addItemWithTitle:
411 [NSString stringWithUTF8String: name]
412 action: @selector(servicesChange:)
414 [o_lmi setTarget: self];
415 [o_lmi setRepresentedObject: [NSString stringWithUTF8String: ppsz_services[i]]];
416 if( b_enabled ) [o_lmi setState: NSOnState];
418 free( ppsz_services[i] );
419 free( ppsz_name[i] );
421 free( ppsz_services );
424 vlc_object_release( p_playlist );
426 //[self playlistUpdated];
429 - (void)searchfieldChanged:(NSNotification *)o_notification
431 [o_search_field setStringValue:[[o_notification object] stringValue]];
438 [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
439 [o_mi_play setTitle: _NS("Play")];
440 [o_mi_delete setTitle: _NS("Delete")];
441 [o_mi_recursive_expand setTitle: _NS("Expand Node")];
442 [o_mi_selectall setTitle: _NS("Select All")];
443 [o_mi_info setTitle: _NS("Information")];
444 [o_mi_preparse setTitle: _NS("Get Stream Information")];
445 [o_mi_sort_name setTitle: _NS("Sort Node by Name")];
446 [o_mi_sort_author setTitle: _NS("Sort Node by Author")];
447 [o_mi_services setTitle: _NS("Services discovery")];
448 [o_status_field setStringValue: [NSString stringWithFormat:
449 _NS("No items in the playlist")]];
452 [o_search_button setTitle: _NS("Search")];
454 [o_search_field setToolTip: _NS("Search in Playlist")];
455 [o_mi_addNode setTitle: _NS("Add Folder to Playlist")];
457 [o_save_accessory_text setStringValue: _NS("File Format:")];
458 [[o_save_accessory_popup itemAtIndex:0] setTitle: _NS("Extended M3U")];
459 [[o_save_accessory_popup itemAtIndex:1] setTitle: _NS("XML Shareable Playlist Format (XSPF)")];
462 - (void)playlistUpdated
466 /* Clear indications of any existing column sorting */
467 for( i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ )
469 [o_outline_view setIndicatorImage:nil inTableColumn:
470 [[o_outline_view tableColumns] objectAtIndex:i]];
473 [o_outline_view setHighlightedTableColumn:nil];
474 o_tc_sortColumn = nil;
475 // TODO Find a way to keep the dict size to a minimum
476 //[o_outline_dict removeAllObjects];
477 [o_outline_view reloadData];
478 [[[[VLCMain sharedInstance] getWizard] getPlaylistWizard] reloadOutlineView];
479 [[[[VLCMain sharedInstance] getBookmarks] getDataTable] reloadData];
481 playlist_t *p_playlist = pl_Yield( VLCIntf );
483 if( playlist_CurrentSize( p_playlist ) >= 2 )
485 [o_status_field setStringValue: [NSString stringWithFormat:
486 _NS("%i items in the playlist"),
487 playlist_CurrentSize( p_playlist )]];
491 if( playlist_IsEmpty( p_playlist ) )
492 [o_status_field setStringValue: _NS("No items in the playlist")];
494 [o_status_field setStringValue: _NS("1 item in the playlist")];
496 vlc_object_release( p_playlist );
499 - (void)playModeUpdated
501 playlist_t *p_playlist = pl_Yield( VLCIntf );
502 vlc_value_t val, val2;
504 var_Get( p_playlist, "loop", &val2 );
505 var_Get( p_playlist, "repeat", &val );
506 if( val.b_bool == VLC_TRUE )
508 [[[VLCMain sharedInstance] getControls] repeatOne];
510 else if( val2.b_bool == VLC_TRUE )
512 [[[VLCMain sharedInstance] getControls] repeatAll];
516 [[[VLCMain sharedInstance] getControls] repeatOff];
519 [[[VLCMain sharedInstance] getControls] shuffle];
521 vlc_object_release( p_playlist );
524 - (void)updateRowSelection
529 playlist_t *p_playlist = pl_Yield( VLCIntf );
530 playlist_item_t *p_item, *p_temp_item;
531 NSMutableArray *o_array = [NSMutableArray array];
533 p_item = p_playlist->status.p_item;
536 vlc_object_release(p_playlist);
540 p_temp_item = p_item;
541 while( p_temp_item->p_parent )
543 [o_array insertObject: [NSValue valueWithPointer: p_temp_item] atIndex: 0];
544 p_temp_item = p_temp_item->p_parent;
545 /*for (i = 0 ; i < p_temp_item->i_parents ; i++)
547 if( p_temp_item->pp_parents[i]->i_view == i_current_view )
549 p_temp_item = p_temp_item->pp_parents[i]->p_parent;
555 for( j = 0; j < [o_array count] - 1; j++ )
558 if( ( o_item = [o_outline_dict objectForKey:
559 [NSString stringWithFormat: @"%p",
560 [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
562 [o_outline_view expandItem: o_item];
567 i_row = [o_outline_view rowForItem:[o_outline_dict
568 objectForKey:[NSString stringWithFormat: @"%p", p_item]]];
570 [o_outline_view selectRow: i_row byExtendingSelection: NO];
571 [o_outline_view scrollRowToVisible: i_row];
573 vlc_object_release( p_playlist );
575 /* update our info-panel to reflect the new item */
576 [[[VLCMain sharedInstance] getInfo] updatePanel];
579 /* Check if p_item is a child of p_node recursively. We need to check the item
580 existence first since OSX sometimes tries to redraw items that have been
581 deleted. We don't do it when not required since this verification takes
582 quite a long time on big playlists (yes, pretty hacky). */
583 - (BOOL)isItem: (playlist_item_t *)p_item
584 inNode: (playlist_item_t *)p_node
585 checkItemExistence:(BOOL)b_check
588 playlist_t * p_playlist = pl_Yield( VLCIntf );
589 playlist_item_t *p_temp_item = p_item;
591 if( p_node == p_item )
593 vlc_object_release(p_playlist);
597 if( p_node->i_children < 1)
599 vlc_object_release(p_playlist);
606 vlc_mutex_lock( &p_playlist->object_lock );
610 /* Since outlineView: willDisplayCell:... may call this function with
611 p_items that don't exist anymore, first check if the item is still
612 in the playlist. Any cleaner solution welcomed. */
613 for( i = 0; i < p_playlist->all_items.i_size; i++ )
615 if( ARRAY_VAL( p_playlist->all_items, i) == p_item ) break;
616 else if ( i == p_playlist->all_items.i_size - 1 )
618 vlc_object_release( p_playlist );
619 vlc_mutex_unlock( &p_playlist->object_lock );
627 p_temp_item = p_temp_item->p_parent;
628 if( p_temp_item == p_node )
630 vlc_mutex_unlock( &p_playlist->object_lock );
631 vlc_object_release( p_playlist );
635 vlc_mutex_unlock( &p_playlist->object_lock );
638 vlc_object_release( p_playlist );
642 /* This method is usefull for instance to remove the selected children of an
643 already selected node */
644 - (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
647 for( i = 0 ; i < [o_items count] ; i++ )
649 for ( j = 0 ; j < [o_nodes count] ; j++ )
651 if( o_items == o_nodes)
653 if( j == i ) continue;
655 if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
656 inNode: [[o_nodes objectAtIndex:j] pointerValue]
657 checkItemExistence: NO] )
659 [o_items removeObjectAtIndex:i];
660 /* We need to execute the next iteration with the same index
661 since the current item has been deleted */
670 - (IBAction)savePlaylist:(id)sender
672 intf_thread_t * p_intf = VLCIntf;
673 playlist_t * p_playlist = pl_Yield( p_intf );
675 NSSavePanel *o_save_panel = [NSSavePanel savePanel];
676 NSString * o_name = [NSString stringWithFormat: @"%@", _NS("Untitled")];
678 //[o_save_panel setAllowedFileTypes: [NSArray arrayWithObjects: @"m3u", @"xpf", nil] ];
679 [o_save_panel setTitle: _NS("Save Playlist")];
680 [o_save_panel setPrompt: _NS("Save")];
681 [o_save_panel setAccessoryView: o_save_accessory_view];
683 if( [o_save_panel runModalForDirectory: nil
684 file: o_name] == NSOKButton )
686 NSString *o_filename = [o_save_panel filename];
688 if( [o_save_accessory_popup indexOfSelectedItem] == 1 )
690 NSString * o_real_filename;
692 range.location = [o_filename length] - [@".xspf" length];
693 range.length = [@".xspf" length];
695 if( [o_filename compare:@".xspf" options: NSCaseInsensitiveSearch
696 range: range] != NSOrderedSame )
698 o_real_filename = [NSString stringWithFormat: @"%@.xspf", 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-xspf" );
710 NSString * o_real_filename;
712 range.location = [o_filename length] - [@".m3u" length];
713 range.length = [@".m3u" length];
715 if( [o_filename compare:@".m3u" options: NSCaseInsensitiveSearch
716 range: range] != NSOrderedSame )
718 o_real_filename = [NSString stringWithFormat: @"%@.m3u", o_filename];
722 o_real_filename = o_filename;
724 playlist_Export( p_playlist,
725 [o_real_filename fileSystemRepresentation],
726 p_playlist->p_local_category, "export-m3u" );
729 vlc_object_release( p_playlist );
732 /* When called retrieves the selected outlineview row and plays that node or item */
733 - (IBAction)playItem:(id)sender
735 intf_thread_t * p_intf = VLCIntf;
736 playlist_t * p_playlist = pl_Yield( p_intf );
738 playlist_item_t *p_item;
739 playlist_item_t *p_node = NULL;
741 p_item = [[o_outline_view itemAtRow:[o_outline_view selectedRow]] pointerValue];
745 if( p_item->i_children == -1 )
747 p_node = p_item->p_parent;
753 if( p_node->i_children > 0 && p_node->pp_children[0]->i_children == -1 )
755 p_item = p_node->pp_children[0];
762 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, p_node, p_item );
764 vlc_object_release( p_playlist );
767 /* When called retrieves the selected outlineview row and plays that node or item */
768 - (IBAction)preparseItem:(id)sender
771 NSMutableArray *o_to_preparse;
772 intf_thread_t * p_intf = VLCIntf;
773 playlist_t * p_playlist = pl_Yield( p_intf );
775 o_to_preparse = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
776 i_count = [o_to_preparse count];
780 playlist_item_t *p_item = NULL;
782 for( i = 0; i < i_count; i++ )
784 o_number = [o_to_preparse lastObject];
785 i_row = [o_number intValue];
786 p_item = [[o_outline_view itemAtRow:i_row] pointerValue];
787 [o_to_preparse removeObject: o_number];
788 [o_outline_view deselectRow: i_row];
792 if( p_item->i_children == -1 )
794 playlist_PreparseEnqueue( p_playlist, p_item->p_input );
798 msg_Dbg( p_intf, "preparse of nodes not yet implemented" );
802 vlc_object_release( p_playlist );
803 [self playlistUpdated];
806 - (IBAction)servicesChange:(id)sender
808 NSMenuItem *o_mi = (NSMenuItem *)sender;
809 NSString *o_string = [o_mi representedObject];
810 playlist_t * p_playlist = pl_Yield( VLCIntf );
811 if( !playlist_IsServicesDiscoveryLoaded( p_playlist, [o_string UTF8String] ) )
812 playlist_ServicesDiscoveryAdd( p_playlist, [o_string UTF8String] );
814 playlist_ServicesDiscoveryRemove( p_playlist, [o_string UTF8String] );
816 [o_mi setState: playlist_IsServicesDiscoveryLoaded( p_playlist,
817 [o_string UTF8String] ) ? YES : NO];
819 vlc_object_release( p_playlist );
820 [self playlistUpdated];
824 - (IBAction)selectAll:(id)sender
826 [o_outline_view selectAll: nil];
829 - (IBAction)deleteItem:(id)sender
831 int i, i_count, i_row;
832 NSMutableArray *o_to_delete;
835 playlist_t * p_playlist;
836 intf_thread_t * p_intf = VLCIntf;
838 p_playlist = pl_Yield( p_intf );
840 o_to_delete = [NSMutableArray arrayWithArray:[[o_outline_view selectedRowEnumerator] allObjects]];
841 i_count = [o_to_delete count];
843 for( i = 0; i < i_count; i++ )
845 o_number = [o_to_delete lastObject];
846 i_row = [o_number intValue];
847 id o_item = [o_outline_view itemAtRow: i_row];
848 playlist_item_t *p_item = [o_item pointerValue];
849 [o_to_delete removeObject: o_number];
850 [o_outline_view deselectRow: i_row];
852 if( [[o_outline_view dataSource] outlineView:o_outline_view
853 numberOfChildrenOfItem: o_item] > 0 )
854 //is a node and not an item
856 if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
857 [self isItem: p_playlist->status.p_item inNode:
858 ((playlist_item_t *)[o_item pointerValue])
859 checkItemExistence: NO] == YES )
861 // if current item is in selected node and is playing then stop playlist
862 playlist_Stop( p_playlist );
864 vlc_mutex_lock( &p_playlist->object_lock );
865 playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE );
866 vlc_mutex_unlock( &p_playlist->object_lock );
870 playlist_DeleteFromInput( p_playlist, p_item->p_input->i_id, VLC_FALSE );
873 [self playlistUpdated];
874 vlc_object_release( p_playlist );
877 - (IBAction)sortNodeByName:(id)sender
879 [self sortNode: SORT_TITLE];
882 - (IBAction)sortNodeByAuthor:(id)sender
884 [self sortNode: SORT_ARTIST];
887 - (void)sortNode:(int)i_mode
889 playlist_t * p_playlist = pl_Yield( VLCIntf );
890 playlist_item_t * p_item;
892 if( [o_outline_view selectedRow] > -1 )
894 p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
898 /*If no item is selected, sort the whole playlist*/
900 p_item = p_playlist->p_root_category;
903 if( p_item->i_children > -1 ) // the item is a node
905 vlc_mutex_lock( &p_playlist->object_lock );
906 playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
907 vlc_mutex_unlock( &p_playlist->object_lock );
911 vlc_mutex_lock( &p_playlist->object_lock );
912 playlist_RecursiveNodeSort( p_playlist,
913 p_item->p_parent, i_mode, ORDER_NORMAL );
914 vlc_mutex_unlock( &p_playlist->object_lock );
916 vlc_object_release( p_playlist );
917 [self playlistUpdated];
920 - (input_item_t *)createItem:(NSDictionary *)o_one_item
922 intf_thread_t * p_intf = VLCIntf;
923 playlist_t * p_playlist = pl_Yield( p_intf );
925 input_item_t *p_input;
927 BOOL b_rem = FALSE, b_dir = FALSE;
928 NSString *o_uri, *o_name;
933 o_uri = (NSString *)[o_one_item objectForKey: @"ITEM_URL"];
934 o_name = (NSString *)[o_one_item objectForKey: @"ITEM_NAME"];
935 o_options = (NSArray *)[o_one_item objectForKey: @"ITEM_OPTIONS"];
937 /* Find the name for a disc entry ( i know, can you believe the trouble?) */
938 if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound )
940 int i_count, i_index;
941 struct statfs *mounts = NULL;
943 i_count = getmntinfo (&mounts, MNT_NOWAIT);
944 /* getmntinfo returns a pointer to static data. Do not free. */
945 for( i_index = 0 ; i_index < i_count; i_index++ )
947 NSMutableString *o_temp, *o_temp2;
948 o_temp = [NSMutableString stringWithString: o_uri];
949 o_temp2 = [NSMutableString stringWithUTF8String: mounts[i_index].f_mntfromname];
950 [o_temp replaceOccurrencesOfString: @"/dev/rdisk" withString: @"/dev/disk" options:nil range:NSMakeRange(0, [o_temp length]) ];
951 [o_temp2 replaceOccurrencesOfString: @"s0" withString: @"" options:nil range:NSMakeRange(0, [o_temp2 length]) ];
952 [o_temp2 replaceOccurrencesOfString: @"s1" withString: @"" options:nil range:NSMakeRange(0, [o_temp2 length]) ];
954 if( strstr( [o_temp fileSystemRepresentation], [o_temp2 fileSystemRepresentation] ) != NULL )
956 o_name = [[NSFileManager defaultManager] displayNameAtPath: [NSString stringWithUTF8String:mounts[i_index].f_mntonname]];
960 /* If no name, then make a guess */
961 if( !o_name) o_name = [[NSFileManager defaultManager] displayNameAtPath: o_uri];
963 if( [[NSFileManager defaultManager] fileExistsAtPath:o_uri isDirectory:&b_dir] && b_dir &&
964 [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath: o_uri isRemovable: &b_rem
965 isWritable:NULL isUnmountable:NULL description:NULL type:NULL] && b_rem )
967 /* All of this is to make sure CD's play when you D&D them on VLC */
968 /* Converts mountpoint to a /dev file */
971 NSMutableString *o_temp;
973 buf = (struct statfs *) malloc (sizeof(struct statfs));
974 statfs( [o_uri fileSystemRepresentation], buf );
975 psz_dev = strdup(buf->f_mntfromname);
976 o_temp = [NSMutableString stringWithUTF8String: psz_dev ];
977 [o_temp replaceOccurrencesOfString: @"/dev/disk" withString: @"/dev/rdisk" options:nil range:NSMakeRange(0, [o_temp length]) ];
978 [o_temp replaceOccurrencesOfString: @"s0" withString: @"" options:nil range:NSMakeRange(0, [o_temp length]) ];
979 [o_temp replaceOccurrencesOfString: @"s1" withString: @"" options:nil range:NSMakeRange(0, [o_temp length]) ];
983 p_input = input_ItemNew( p_playlist, [o_uri fileSystemRepresentation], [o_name UTF8String] );
989 for( i = 0; i < (int)[o_options count]; i++ )
991 input_ItemAddOption( p_input, strdup( [[o_options objectAtIndex:i] UTF8String] ) );
995 /* Recent documents menu */
996 o_true_file = [NSURL fileURLWithPath: o_uri];
997 if( o_true_file != nil && (BOOL)config_GetInt( p_playlist, "macosx-recentitems" ) == YES )
999 [[NSDocumentController sharedDocumentController]
1000 noteNewRecentDocumentURL: o_true_file];
1003 vlc_object_release( p_playlist );
1007 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
1010 playlist_t * p_playlist = pl_Yield( VLCIntf );
1012 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
1014 input_item_t *p_input;
1015 NSDictionary *o_one_item;
1018 o_one_item = [o_array objectAtIndex: i_item];
1019 p_input = [self createItem: o_one_item];
1026 playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT,
1027 i_position == -1 ? PLAYLIST_END : i_position + i_item, VLC_TRUE,
1030 if( i_item == 0 && !b_enqueue )
1032 playlist_item_t *p_item;
1033 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1034 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
1038 playlist_item_t *p_item;
1039 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1040 playlist_Control( p_playlist, PLAYLIST_SKIP, VLC_TRUE, p_item );
1043 [self playlistUpdated];
1044 vlc_object_release( p_playlist );
1047 - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue
1050 playlist_t * p_playlist = pl_Yield( VLCIntf );
1052 for( i_item = 0; i_item < (int)[o_array count]; i_item++ )
1054 input_item_t *p_input;
1055 NSDictionary *o_one_item;
1058 o_one_item = [o_array objectAtIndex: i_item];
1059 p_input = [self createItem: o_one_item];
1066 playlist_NodeAddInput( p_playlist, p_input, p_node,
1069 PLAYLIST_END : i_position + i_item, VLC_FALSE );
1072 if( i_item == 0 && !b_enqueue )
1074 playlist_item_t *p_item;
1075 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1076 playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE, NULL, p_item );
1080 playlist_item_t *p_item;
1081 p_item = playlist_ItemGetByInput( p_playlist, p_input, VLC_TRUE );
1082 playlist_Control( p_playlist, PLAYLIST_SKIP, VLC_TRUE, p_item );
1085 [self playlistUpdated];
1086 vlc_object_release( p_playlist );
1089 - (NSMutableArray *)subSearchItem:(playlist_item_t *)p_item
1091 playlist_t *p_playlist = pl_Yield( VLCIntf );
1092 playlist_item_t *p_selected_item;
1093 int i_current, i_selected_row;
1095 i_selected_row = [o_outline_view selectedRow];
1096 if (i_selected_row < 0)
1099 p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow:
1100 i_selected_row] pointerValue];
1102 for( i_current = 0; i_current < p_item->i_children ; i_current++ )
1105 NSString *o_current_name, *o_current_author;
1107 vlc_mutex_lock( &p_playlist->object_lock );
1108 o_current_name = [NSString stringWithUTF8String:
1109 p_item->pp_children[i_current]->p_input->psz_name];
1110 psz_temp = input_ItemGetInfo( p_item->p_input ,
1111 _("Meta-information"),_("Artist") );
1112 o_current_author = [NSString stringWithUTF8String: psz_temp];
1114 vlc_mutex_unlock( &p_playlist->object_lock );
1116 if( p_selected_item == p_item->pp_children[i_current] &&
1117 b_selected_item_met == NO )
1119 b_selected_item_met = YES;
1121 else if( p_selected_item == p_item->pp_children[i_current] &&
1122 b_selected_item_met == YES )
1124 vlc_object_release( p_playlist );
1127 else if( b_selected_item_met == YES &&
1128 ( [o_current_name rangeOfString:[o_search_field
1129 stringValue] options:NSCaseInsensitiveSearch ].length ||
1130 [o_current_author rangeOfString:[o_search_field
1131 stringValue] options:NSCaseInsensitiveSearch ].length ) )
1133 vlc_object_release( p_playlist );
1134 /*Adds the parent items in the result array as well, so that we can
1136 return [NSMutableArray arrayWithObject: [NSValue
1137 valueWithPointer: p_item->pp_children[i_current]]];
1139 if( p_item->pp_children[i_current]->i_children > 0 )
1141 id o_result = [self subSearchItem:
1142 p_item->pp_children[i_current]];
1143 if( o_result != NULL )
1145 vlc_object_release( p_playlist );
1146 [o_result insertObject: [NSValue valueWithPointer:
1147 p_item->pp_children[i_current]] atIndex:0];
1152 vlc_object_release( p_playlist );
1156 - (IBAction)searchItem:(id)sender
1158 playlist_t * p_playlist = pl_Yield( VLCIntf );
1164 b_selected_item_met = NO;
1166 /*First, only search after the selected item:*
1167 *(b_selected_item_met = NO) */
1168 o_result = [self subSearchItem:p_playlist->p_root_category];
1169 if( o_result == NULL )
1171 /* If the first search failed, search again from the beginning */
1172 o_result = [self subSearchItem:p_playlist->p_root_category];
1174 if( o_result != NULL )
1177 if( [[o_result objectAtIndex: 0] pointerValue] ==
1178 p_playlist->p_local_category )
1183 for( i = i_start ; i < [o_result count] - 1 ; i++ )
1185 [o_outline_view expandItem: [o_outline_dict objectForKey:
1186 [NSString stringWithFormat: @"%p",
1187 [[o_result objectAtIndex: i] pointerValue]]]];
1189 i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey:
1190 [NSString stringWithFormat: @"%p",
1191 [[o_result objectAtIndex: [o_result count] - 1 ]
1196 [o_outline_view selectRow:i_row byExtendingSelection: NO];
1197 [o_outline_view scrollRowToVisible: i_row];
1199 vlc_object_release( p_playlist );
1202 - (IBAction)recursiveExpandNode:(id)sender
1204 id o_item = [o_outline_view itemAtRow: [o_outline_view selectedRow]];
1205 playlist_item_t *p_item = (playlist_item_t *)[o_item pointerValue];
1207 if( ![[o_outline_view dataSource] outlineView: o_outline_view
1208 isItemExpandable: o_item] )
1210 o_item = [o_outline_dict objectForKey: [NSString
1211 stringWithFormat: @"%p", p_item->p_parent]];
1214 /* We need to collapse the node first, since OSX refuses to recursively
1215 expand an already expanded node, even if children nodes are collapsed. */
1216 [o_outline_view collapseItem: o_item collapseChildren: YES];
1217 [o_outline_view expandItem: o_item expandChildren: YES];
1220 - (NSMenu *)menuForEvent:(NSEvent *)o_event
1224 vlc_bool_t b_item_sel;
1226 pt = [o_outline_view convertPoint: [o_event locationInWindow]
1228 b_item_sel = ( [o_outline_view rowAtPoint: pt] != -1 &&
1229 [o_outline_view selectedRow] != -1 );
1230 b_rows = [o_outline_view numberOfRows] != 0;
1232 [o_mi_play setEnabled: b_item_sel];
1233 [o_mi_delete setEnabled: b_item_sel];
1234 [o_mi_selectall setEnabled: b_rows];
1235 [o_mi_info setEnabled: b_item_sel];
1236 [o_mi_preparse setEnabled: b_item_sel];
1237 [o_mi_recursive_expand setEnabled: b_item_sel];
1238 [o_mi_sort_name setEnabled: b_item_sel];
1239 [o_mi_sort_author setEnabled: b_item_sel];
1241 return( o_ctx_menu );
1244 - (void)outlineView: (NSTableView*)o_tv
1245 didClickTableColumn:(NSTableColumn *)o_tc
1247 int i_mode = 0, i_type;
1248 intf_thread_t *p_intf = VLCIntf;
1250 playlist_t *p_playlist = pl_Yield( p_intf );
1252 /* Check whether the selected table column header corresponds to a
1253 sortable table column*/
1254 if( !( o_tc == o_tc_name || o_tc == o_tc_author ) )
1256 vlc_object_release( p_playlist );
1260 if( o_tc_sortColumn == o_tc )
1262 b_isSortDescending = !b_isSortDescending;
1266 b_isSortDescending = VLC_FALSE;
1269 if( o_tc == o_tc_name )
1271 i_mode = SORT_TITLE;
1273 else if( o_tc == o_tc_author )
1275 i_mode = SORT_ARTIST;
1278 if( b_isSortDescending )
1280 i_type = ORDER_REVERSE;
1284 i_type = ORDER_NORMAL;
1287 vlc_mutex_lock( &p_playlist->object_lock );
1288 playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_category, i_mode, i_type );
1289 vlc_mutex_unlock( &p_playlist->object_lock );
1291 vlc_object_release( p_playlist );
1292 [self playlistUpdated];
1294 o_tc_sortColumn = o_tc;
1295 [o_outline_view setHighlightedTableColumn:o_tc];
1297 if( b_isSortDescending )
1299 [o_outline_view setIndicatorImage:o_descendingSortingImage
1300 inTableColumn:o_tc];
1304 [o_outline_view setIndicatorImage:o_ascendingSortingImage
1305 inTableColumn:o_tc];
1310 - (void)outlineView:(NSOutlineView *)outlineView
1311 willDisplayCell:(id)cell
1312 forTableColumn:(NSTableColumn *)tableColumn
1315 playlist_t *p_playlist = pl_Yield( VLCIntf );
1319 o_playing_item = [o_outline_dict objectForKey:
1320 [NSString stringWithFormat:@"%p", p_playlist->status.p_item]];
1322 if( [self isItem: [o_playing_item pointerValue] inNode:
1323 [item pointerValue] checkItemExistence: YES]
1324 || [o_playing_item isEqual: item] )
1326 [cell setFont: [NSFont boldSystemFontOfSize: 0]];
1330 [cell setFont: [NSFont systemFontOfSize: 0]];
1332 vlc_object_release( p_playlist );
1335 - (IBAction)addNode:(id)sender
1337 /* we have to create a new thread here because otherwise we would block the
1338 * interface since the interaction-stuff and this code would run in the same
1340 [NSThread detachNewThreadSelector: @selector(addNodeThreadedly)
1341 toTarget: self withObject:nil];
1342 [self playlistUpdated];
1345 - (void)addNodeThreadedly
1347 NSAutoreleasePool * ourPool = [[NSAutoreleasePool alloc] init];
1349 /* simply adds a new node to the end of the playlist */
1350 playlist_t * p_playlist = pl_Yield( VLCIntf );
1351 vlc_thread_set_priority( p_playlist, VLC_THREAD_PRIORITY_LOW );
1354 char *psz_name = NULL;
1355 playlist_item_t * p_item;
1356 ret_v = intf_UserStringInput( p_playlist, _("New Node"),
1357 _("Please enter a name for the new node."), &psz_name );
1359 if( psz_name != NULL && psz_name != "" )
1360 p_item = playlist_NodeCreate( p_playlist, psz_name,
1361 p_playlist->p_local_category, 0, NULL );
1362 else if(! config_GetInt( p_playlist, "interact" ) )
1364 /* in case that the interaction is disabled, just give it a bogus name */
1365 p_item = playlist_NodeCreate( p_playlist, _("Empty Folder"),
1366 p_playlist->p_local_category, 0, NULL );
1370 msg_Warn( VLCIntf, "node creation failed or cancelled by user" );
1372 vlc_object_release( p_playlist );
1378 @implementation VLCPlaylist (NSOutlineViewDataSource)
1380 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
1382 id o_value = [super outlineView: outlineView child: index ofItem: item];
1383 playlist_t *p_playlist = pl_Yield( VLCIntf );
1385 if( playlist_CurrentSize( p_playlist ) >= 2 )
1387 [o_status_field setStringValue: [NSString stringWithFormat:
1388 _NS("%i items in the playlist"),
1389 playlist_CurrentSize( p_playlist )]];
1393 if( playlist_IsEmpty( p_playlist ) )
1395 [o_status_field setStringValue: _NS("No items in the playlist")];
1399 [o_status_field setStringValue: _NS("1 item in the playlist")];
1402 vlc_object_release( p_playlist );
1404 [o_outline_dict setObject:o_value forKey:[NSString stringWithFormat:@"%p",
1405 [o_value pointerValue]]];
1406 msg_Dbg( VLCIntf, "adding item %p", [o_value pointerValue] );
1411 /* Required for drag & drop and reordering */
1412 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
1415 playlist_t *p_playlist = pl_Yield( VLCIntf );
1417 /* First remove the items that were moved during the last drag & drop
1419 [o_items_array removeAllObjects];
1420 [o_nodes_array removeAllObjects];
1422 for( i = 0 ; i < [items count] ; i++ )
1424 id o_item = [items objectAtIndex: i];
1426 /* Refuse to move items that are not in the General Node
1427 (Service Discovery) */
1428 if( ![self isItem: [o_item pointerValue] inNode:
1429 p_playlist->p_local_category checkItemExistence: NO])
1431 vlc_object_release(p_playlist);
1434 /* Fill the items and nodes to move in 2 different arrays */
1435 if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 )
1436 [o_nodes_array addObject: o_item];
1438 [o_items_array addObject: o_item];
1441 /* Now we need to check if there are selected items that are in already
1442 selected nodes. In that case, we only want to move the nodes */
1443 [self removeItemsFrom: o_nodes_array ifChildrenOf: o_nodes_array];
1444 [self removeItemsFrom: o_items_array ifChildrenOf: o_nodes_array];
1446 /* We add the "VLCPlaylistItemPboardType" type to be able to recognize
1447 a Drop operation coming from the playlist. */
1449 [pboard declareTypes: [NSArray arrayWithObjects:
1450 @"VLCPlaylistItemPboardType", nil] owner: self];
1451 [pboard setData:[NSData data] forType:@"VLCPlaylistItemPboardType"];
1453 vlc_object_release(p_playlist);
1457 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
1459 playlist_t *p_playlist = pl_Yield( VLCIntf );
1460 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1462 if( !p_playlist ) return NSDragOperationNone;
1464 /* Dropping ON items is not allowed if item is not a node */
1467 if( index == NSOutlineViewDropOnItemIndex &&
1468 ((playlist_item_t *)[item pointerValue])->i_children == -1 )
1470 vlc_object_release( p_playlist );
1471 return NSDragOperationNone;
1475 /* Don't allow on drop on playlist root element's child */
1476 if( !item && index != NSOutlineViewDropOnItemIndex)
1478 vlc_object_release( p_playlist );
1479 return NSDragOperationNone;
1482 /* We refuse to drop an item in anything else than a child of the General
1483 Node. We still accept items that would be root nodes of the outlineview
1484 however, to allow drop in an empty playlist. */
1485 if( !([self isItem: [item pointerValue] inNode: p_playlist->p_local_category
1486 checkItemExistence: NO] || item == nil) )
1488 vlc_object_release( p_playlist );
1489 return NSDragOperationNone;
1492 /* Drop from the Playlist */
1493 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1496 for( i = 0 ; i < [o_nodes_array count] ; i++ )
1498 /* We refuse to Drop in a child of an item we are moving */
1499 if( [self isItem: [item pointerValue] inNode:
1500 [[o_nodes_array objectAtIndex: i] pointerValue]
1501 checkItemExistence: NO] )
1503 vlc_object_release( p_playlist );
1504 return NSDragOperationNone;
1507 vlc_object_release( p_playlist );
1508 return NSDragOperationMove;
1511 /* Drop from the Finder */
1512 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1514 vlc_object_release( p_playlist );
1515 return NSDragOperationGeneric;
1517 vlc_object_release( p_playlist );
1518 return NSDragOperationNone;
1521 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index
1523 playlist_t * p_playlist = pl_Yield( VLCIntf );
1524 NSPasteboard *o_pasteboard = [info draggingPasteboard];
1526 /* Drag & Drop inside the playlist */
1527 if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1529 int i_row, i_removed_from_node = 0;
1531 playlist_item_t *p_new_parent, *p_item = NULL;
1532 NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
1534 /* If the item is to be dropped as root item of the outline, make it a
1535 child of the General node.
1536 Else, choose the proposed parent as parent. */
1537 if( item == nil ) p_new_parent = p_playlist->p_local_category;
1538 else p_new_parent = [item pointerValue];
1540 /* Make sure the proposed parent is a node.
1541 (This should never be true) */
1542 if( p_new_parent->i_children < 0 )
1544 vlc_object_release( p_playlist );
1548 for( i = 0; i < [o_all_items count]; i++ )
1550 playlist_item_t *p_old_parent = NULL;
1551 int i_old_index = 0;
1553 p_item = [[o_all_items objectAtIndex:i] pointerValue];
1554 p_old_parent = p_item->p_parent;
1557 /* We may need the old index later */
1558 if( p_new_parent == p_old_parent )
1561 for( j = 0; j < p_old_parent->i_children; j++ )
1563 if( p_old_parent->pp_children[j] == p_item )
1571 vlc_mutex_lock( &p_playlist->object_lock );
1572 // Acually detach the item from the old position
1573 if( playlist_NodeRemoveItem( p_playlist, p_item, p_old_parent ) ==
1577 /* Calculate the new index */
1580 /* If we move the item in the same node, we need to take into
1581 account that one item will be deleted */
1584 if ((p_new_parent == p_old_parent &&
1585 i_old_index < index + (int)i) )
1587 i_removed_from_node++;
1589 i_new_index = index + i - i_removed_from_node;
1591 // Reattach the item to the new position
1592 playlist_NodeInsert( p_playlist, p_item, p_new_parent, i_new_index );
1594 vlc_mutex_unlock( &p_playlist->object_lock );
1596 [self playlistUpdated];
1597 i_row = [o_outline_view rowForItem:[o_outline_dict
1598 objectForKey:[NSString stringWithFormat: @"%p",
1599 [[o_all_items objectAtIndex: 0] pointerValue]]]];
1603 i_row = [o_outline_view rowForItem:[o_outline_dict
1604 objectForKey:[NSString stringWithFormat: @"%p", p_new_parent]]];
1607 [o_outline_view deselectAll: self];
1608 [o_outline_view selectRow: i_row byExtendingSelection: NO];
1609 [o_outline_view scrollRowToVisible: i_row];
1611 vlc_object_release( p_playlist );
1615 else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
1618 playlist_item_t *p_node = [item pointerValue];
1620 NSArray *o_array = [NSArray array];
1621 NSArray *o_values = [[o_pasteboard propertyListForType:
1622 NSFilenamesPboardType]
1623 sortedArrayUsingSelector:
1624 @selector(caseInsensitiveCompare:)];
1626 for( i = 0; i < (int)[o_values count]; i++)
1628 NSDictionary *o_dic;
1629 o_dic = [NSDictionary dictionaryWithObject:[o_values
1630 objectAtIndex:i] forKey:@"ITEM_URL"];
1631 o_array = [o_array arrayByAddingObject: o_dic];
1636 [self appendArray: o_array atPos: index enqueue: YES];
1638 /* This should never occur */
1639 else if( p_node->i_children == -1 )
1641 vlc_object_release( p_playlist );
1646 [self appendNodeArray: o_array inNode: p_node
1647 atPos: index enqueue: YES];
1649 vlc_object_release( p_playlist );
1652 vlc_object_release( p_playlist );