medialibrary: allow changing folder public state

This is the main mechanism that will be exposed to the user to
allow/disallow multiple media to be publicly exposed on the network by
VLC.
This commit is contained in:
Alaric Senat 2024-04-08 17:00:06 +02:00 committed by Steve Lhomme
parent 2bb616a50c
commit baed3b02ec
2 changed files with 28 additions and 0 deletions

View File

@ -578,6 +578,9 @@ enum vlc_ml_control
*/
VLC_ML_RELOAD_FOLDER,
VLC_ML_SET_FOLDER_PUBLIC, /**< arg1: mrl (const char *); res: can't fail */
VLC_ML_SET_FOLDER_PRIVATE, /**< arg1: mrl (const char *); res: can't fail */
/* Pause/resume background operations, such as media discovery & media analysis */
VLC_ML_PAUSE_BACKGROUND, /**< no args; can't fail */
VLC_ML_RESUME_BACKGROUND, /**< no args; can't fail */
@ -1012,6 +1015,16 @@ static inline int vlc_ml_reload_folder( vlc_medialibrary_t* p_ml, const char* ps
return vlc_ml_control( p_ml, VLC_ML_RELOAD_FOLDER, psz_mrl );
}
static inline int vlc_ml_set_folder_public( vlc_medialibrary_t* p_ml, const char* psz_mrl )
{
return vlc_ml_control( p_ml, VLC_ML_SET_FOLDER_PUBLIC, psz_mrl );
}
static inline int vlc_ml_set_folder_private( vlc_medialibrary_t* p_ml, const char* psz_mrl )
{
return vlc_ml_control( p_ml, VLC_ML_SET_FOLDER_PRIVATE, psz_mrl );
}
static inline int vlc_ml_pause_background( vlc_medialibrary_t* p_ml )
{
return vlc_ml_control( p_ml, VLC_ML_PAUSE_BACKGROUND );

View File

@ -522,6 +522,8 @@ int MediaLibrary::Control( int query, va_list args )
case VLC_ML_BAN_FOLDER:
case VLC_ML_UNBAN_FOLDER:
case VLC_ML_RELOAD_FOLDER:
case VLC_ML_SET_FOLDER_PUBLIC:
case VLC_ML_SET_FOLDER_PRIVATE:
case VLC_ML_RESUME_BACKGROUND:
case VLC_ML_NEW_EXTERNAL_MEDIA:
case VLC_ML_NEW_STREAM:
@ -544,6 +546,8 @@ int MediaLibrary::Control( int query, va_list args )
case VLC_ML_REMOVE_FOLDER:
case VLC_ML_BAN_FOLDER:
case VLC_ML_UNBAN_FOLDER:
case VLC_ML_SET_FOLDER_PUBLIC:
case VLC_ML_SET_FOLDER_PRIVATE:
{
const char* mrl = va_arg( args, const char* );
switch( query )
@ -560,6 +564,17 @@ int MediaLibrary::Control( int query, va_list args )
case VLC_ML_UNBAN_FOLDER:
m_ml->unbanFolder( mrl );
break;
case VLC_ML_SET_FOLDER_PUBLIC:
case VLC_ML_SET_FOLDER_PRIVATE:
{
auto folder = m_ml->folder(mrl);
const bool is_public = query == VLC_ML_SET_FOLDER_PUBLIC;
if (folder)
folder->setPublic(is_public);
break;
}
}
break;
}