Commit 38184c2e authored by Clément Stenac's avatar Clément Stenac

Fixes + use new API for directory demuxer

parent 4a253e8c
...@@ -108,7 +108,8 @@ static int Demux( demux_t *p_demux ); ...@@ -108,7 +108,8 @@ static int Demux( demux_t *p_demux );
static int DemuxControl( demux_t *p_demux, int i_query, va_list args ); static int DemuxControl( demux_t *p_demux, int i_query, va_list args );
static int ReadDir( playlist_t *, char *psz_name, int i_mode, int *pi_pos ); static int ReadDir( playlist_t *, char *psz_name, int i_mode, int *pi_pos,
playlist_item_t * );
/***************************************************************************** /*****************************************************************************
* Open: open the directory * Open: open the directory
...@@ -206,17 +207,24 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len) ...@@ -206,17 +207,24 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
free( psz ); free( psz );
/* Make sure we are deleted when we are done */ /* Make sure we are deleted when we are done */
p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = VLC_TRUE; // p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = VLC_TRUE;
/* The playlist position we will use for the add */ /* The playlist position we will use for the add */
i_pos = p_playlist->i_index + 1; i_pos = p_playlist->i_index + 1;
msg_Dbg( p_access, "opening directory `%s'", psz_name ); msg_Dbg( p_access, "opening directory `%s'", psz_name );
if( ReadDir( p_playlist, psz_name , i_mode, &i_pos ) != VLC_SUCCESS )
p_playlist->status.p_item->input.i_type = ITEM_TYPE_DIRECTORY;
if( ReadDir( p_playlist, psz_name , i_mode, &i_pos,
p_playlist->status.p_item
) != VLC_SUCCESS )
{ {
goto end; goto end;
} }
end: end:
/* Begin to read the directory */
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,p_playlist->status.i_view,
p_playlist->status.p_item, NULL );
if( psz_name ) free( psz_name ); if( psz_name ) free( psz_name );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
...@@ -307,11 +315,19 @@ static int DemuxControl( demux_t *p_demux, int i_query, va_list args ) ...@@ -307,11 +315,19 @@ static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
* ReadDir: read a directory and add its content to the list * ReadDir: read a directory and add its content to the list
*****************************************************************************/ *****************************************************************************/
static int ReadDir( playlist_t *p_playlist, static int ReadDir( playlist_t *p_playlist,
char *psz_name , int i_mode, int *pi_position ) char *psz_name , int i_mode, int *pi_position,
playlist_item_t *p_parent )
{ {
DIR * p_current_dir; DIR * p_current_dir;
struct dirent * p_dir_content; struct dirent * p_dir_content;
playlist_item_t *p_node;
int i;
/* Change the item to a node */
if( p_parent->i_children == -1)
{
playlist_ItemToNode( p_playlist,p_parent );
}
/* Open the dir */ /* Open the dir */
p_current_dir = opendir( psz_name ); p_current_dir = opendir( psz_name );
...@@ -361,8 +377,21 @@ static int ReadDir( playlist_t *p_playlist, ...@@ -361,8 +377,21 @@ static int ReadDir( playlist_t *p_playlist,
else if(i_mode == MODE_EXPAND ) else if(i_mode == MODE_EXPAND )
{ {
msg_Dbg(p_playlist, "Reading subdirectory %s", psz_uri ); msg_Dbg(p_playlist, "Reading subdirectory %s", psz_uri );
if( ReadDir( p_playlist, psz_uri , MODE_EXPAND, pi_position ) p_node = playlist_NodeCreate( p_playlist,
!= VLC_SUCCESS ) p_parent->pp_parents[0]->i_view,
psz_uri, p_parent );
p_node->input.i_type = ITEM_TYPE_DIRECTORY;
/* We need to declare the parents of the node as the
* same of the parent's ones */
for( i= 1 ; i< p_parent->i_parents; i ++ )
{
playlist_ItemAddParent( p_node,
p_parent->pp_parents[i]->i_view,
p_parent );
}
if( ReadDir( p_playlist, psz_uri , MODE_EXPAND,
pi_position, p_node ) != VLC_SUCCESS )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -370,9 +399,22 @@ static int ReadDir( playlist_t *p_playlist, ...@@ -370,9 +399,22 @@ static int ReadDir( playlist_t *p_playlist,
} }
else else
{ {
playlist_Add( p_playlist, psz_uri, p_dir_content->d_name, playlist_item_t *p_item = playlist_ItemNew( p_playlist,
PLAYLIST_INSERT, *pi_position ); psz_uri, p_dir_content->d_name );
(*pi_position)++; fprintf(stderr,"STARTTTTt\n");
playlist_NodeAddItem( p_playlist,p_item,
p_parent->pp_parents[0]->i_view,
p_parent,
PLAYLIST_APPEND, PLAYLIST_END );
fprintf(stderr,"DONE\n");
/* We need to declare the parents of the node as the
* same of the parent's ones */
for( i= 1 ; i< p_parent->i_parents; i ++ )
{
playlist_ItemAddParent( p_item,
p_parent->pp_parents[i]->i_view,
p_parent );
}
} }
} }
free( psz_uri ); free( psz_uri );
......
...@@ -526,7 +526,7 @@ static void FollowAnchor ( intf_thread_t *p_intf ) ...@@ -526,7 +526,7 @@ static void FollowAnchor ( intf_thread_t *p_intf )
msg_Dbg( p_intf, "calling browser_Open with \"%s\"", psz_url ); msg_Dbg( p_intf, "calling browser_Open with \"%s\"", psz_url );
#endif #endif
(void) browser_Open( psz_url ); (void) browser_Open( psz_url );
playlist_Command( p_playlist, PLAYLIST_PAUSE, 0 ); playlist_Control( p_playlist, PLAYLIST_PAUSE, 0 );
} }
free( psz_uri_to_load ); free( psz_uri_to_load );
......
...@@ -576,7 +576,19 @@ static void ParseVorbisComments( decoder_t *p_dec ) ...@@ -576,7 +576,19 @@ static void ParseVorbisComments( decoder_t *p_dec )
psz_value++; psz_value++;
input_Control( p_input, INPUT_ADD_INFO, _("Vorbis comment"), input_Control( p_input, INPUT_ADD_INFO, _("Vorbis comment"),
psz_name, psz_value ); psz_name, psz_value );
/* HACK, we should use meta */
if( strstr( psz_name, "artist" ) )
{
input_Control( p_input, INPUT_ADD_INFO, _("Meta-information"),
_("Artist"), psz_value );
}
else if( strstr( psz_name, "title" ) )
{
p_input->input.p_item->psz_name = strdup( psz_value );
}
} }
/* FIXME */
var_SetInteger( p_input, "item-change", p_input->input.p_item->i_id );
free( psz_comment ); free( psz_comment );
i++; i++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment