Commit c7e71cb6 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

control/media_list.c: Implement read-only media_list.

parent ee9c15aa
......@@ -546,6 +546,10 @@ VLC_PUBLIC_API int
libvlc_media_descriptor_t *,
libvlc_exception_t * );
/* This indicates if this media list is read-only from a user point of view */
VLC_PUBLIC_API vlc_bool_t
libvlc_media_list_is_readonly( libvlc_media_list_t * p_mlist );
VLC_PUBLIC_API void
libvlc_media_list_lock( libvlc_media_list_t * );
VLC_PUBLIC_API void
......
......@@ -114,6 +114,10 @@ struct libvlc_media_list_t
/* Other way to see that media list */
/* Used in flat_media_list.c */
libvlc_media_list_t * p_flat_mlist;
/* This indicates if this media list is read-only
* from a user point of view */
vlc_bool_t b_read_only;
};
typedef void (*libvlc_media_list_view_release_func_t)( libvlc_media_list_view_t * p_mlv ) ;
......@@ -297,6 +301,18 @@ VLC_EXPORT (libvlc_media_descriptor_t *, libvlc_media_descriptor_duplicate,
VLC_EXPORT (void, libvlc_media_descriptor_set_state,
( libvlc_media_descriptor_t *, libvlc_state_t, libvlc_exception_t * ) );
/* Media List */
VLC_EXPORT ( void, _libvlc_media_list_insert_media_descriptor,
( libvlc_media_list_t * p_mlist,
libvlc_media_descriptor_t * p_md,
int index,
libvlc_exception_t * p_e ) );
VLC_EXPORT ( void, _libvlc_media_list_remove_index,
( libvlc_media_list_t * p_mlist,
int index,
libvlc_exception_t * p_e ) );
/* Media List View */
VLC_EXPORT ( libvlc_media_list_view_t *, libvlc_media_list_view_new,
( libvlc_media_list_t * p_mlist,
......
......@@ -124,6 +124,7 @@ libvlc_media_list_new( libvlc_instance_t * p_inst,
/* Code for that one should be handled in flat_media_list.c */
p_mlist->p_flat_mlist = NULL;
p_mlist->b_read_only = VLC_FALSE;
libvlc_event_manager_register_event_type( p_mlist->p_event_manager,
libvlc_MediaListItemAdded, p_e );
......@@ -322,6 +323,22 @@ void libvlc_media_list_insert_media_descriptor(
libvlc_media_descriptor_t * p_md,
int index,
libvlc_exception_t * p_e )
{
if( p_mlist->b_read_only )
{
/* We are read only from user side */
libvlc_exception_raise( p_e, "Trying to write into a read-only media list." );
return;
}
_libvlc_media_list_insert_media_descriptor( p_mlist, p_md, index, p_e );
}
/* LibVLC internal version */
void _libvlc_media_list_insert_media_descriptor(
libvlc_media_list_t * p_mlist,
libvlc_media_descriptor_t * p_md,
int index,
libvlc_exception_t * p_e )
{
(void)p_e;
libvlc_media_descriptor_retain( p_md );
......@@ -339,6 +356,20 @@ void libvlc_media_list_insert_media_descriptor(
void libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist,
int index,
libvlc_exception_t * p_e )
{
if( p_mlist->b_read_only )
{
/* We are read only from user side */
libvlc_exception_raise( p_e, "Trying to write into a read-only media list." );
return;
}
_libvlc_media_list_remove_index( p_mlist, index, p_e );
}
/* LibVLC internal version */
void _libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist,
int index,
libvlc_exception_t * p_e )
{
libvlc_media_descriptor_t * p_md;
......@@ -388,6 +419,16 @@ int libvlc_media_list_index_of_item( libvlc_media_list_t * p_mlist,
return -1;
}
/**************************************************************************
* libvlc_media_list_is_readonly (Public)
*
* This indicates if this media list is read-only from a user point of view
**************************************************************************/
vlc_bool_t libvlc_media_list_is_readonly( libvlc_media_list_t * p_mlist )
{
return p_mlist->b_read_only;
}
/**************************************************************************
* libvlc_media_list_lock (Public)
*
......@@ -411,7 +452,6 @@ void libvlc_media_list_unlock( libvlc_media_list_t * p_mlist )
}
/**************************************************************************
* libvlc_media_list_p_event_manager (Public)
*
......
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