-
- // build list of files to be played from message contents
- entry_ref ref;
- BList files;
-
- // if we should parse sub-folders as well
- bool askedAlready = false;
- bool parseSubFolders = askedAlready;
- // traverse refs in reverse order
- int32 count;
- type_code dummy;
- if ( p_message->GetInfo( "refs", &dummy, &count ) == B_OK && count > 0 )
- {
- int32 i = reverse ? count - 1 : 0;
- int32 increment = reverse ? -1 : 1;
- for ( ; p_message->FindRef( "refs", i, &ref ) == B_OK; i += increment )
- {
- BPath path( &ref );
- if ( path.InitCheck() == B_OK )
- {
- bool add = true;
- // has the user dropped a folder?
- BDirectory dir( &ref );
- if ( dir.InitCheck() == B_OK)
- {
- // has the user dropped a dvd disk icon?
- if ( dir.IsRootDirectory() )
- {
- BVolumeRoster volRoster;
- BVolume vol;
- BDirectory volumeRoot;
- status_t status = volRoster.GetNextVolume( &vol );
- while ( status == B_NO_ERROR )
- {
- if ( vol.GetRootDirectory( &volumeRoot ) == B_OK
- && dir == volumeRoot )
- {
- BString volumeName;
- BString deviceName;
- bool isCDROM;
- if ( get_volume_info( vol, volumeName, isCDROM, deviceName )
- && isCDROM )
- {
- BMessage msg( OPEN_DVD );
- msg.AddString( "device", deviceName.String() );
- PostMessage( &msg );
- add = false;
- }
- break;
- }
- else
- {
- vol.Unset();
- status = volRoster.GetNextVolume( &vol );
- }
- }
- }
- if ( add )
- {
- add = false;
- dir.Rewind(); // defensive programming
- BEntry entry;
- collect_folder_contents( dir, files,
- parseSubFolders,
- askedAlready,
- entry );
- }
- }
- if ( add )
- {
- BString* string = new BString( path.Path() );
- if ( !files.AddItem( string, 0 ) )
- delete string; // at least don't leak
- }
- }
- }
- // give the list to VLC
- // BString objects allocated here will be deleted there
- int32 index;
- if ( p_message->FindInt32("drop index", &index) != B_OK )
- index = -1;
- p_wrapper->OpenFiles( &files, replace, index );
- _UpdatePlaylist();
- }