]> git.sesse.net Git - vlc/blobdiff - modules/services_discovery/mediadirs.c
SD mediadirs: set module priority to 0
[vlc] / modules / services_discovery / mediadirs.c
index 425beb59b59c75cf3a766c5d0c602c70ff68a6cf..b644fb6883373d4e782c12e1cf3b3f5fd683cc8b 100644 (file)
@@ -32,7 +32,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_url.h>
-#include <vlc_charset.h>
+#include <vlc_fs.h>
 #include <vlc_services_discovery.h>
 
 #include <sys/stat.h>
@@ -61,30 +61,33 @@ OPEN_MODULE( Picture )
 
 #undef OPEN_MODULE
 
+static int vlc_sd_probe_Open( vlc_object_t * );
+
 vlc_module_begin ()
     set_category( CAT_PLAYLIST )
     set_subcategory( SUBCAT_PLAYLIST_SD )
 
-        set_shortname( "Video" )
+        set_shortname( N_("Video") )
         set_description( N_("My Videos") )
-        set_capability( "services_discovery", 10 )
+        set_capability( "services_discovery", 0 )
         set_callbacks( OpenVideo, Close )
         add_shortcut( "video_dir" )
 
     add_submodule ()
-        set_shortname( "Audio" )
+        set_shortname( N_("Audio") )
         set_description( N_("My Music") )
-        set_capability( "services_discovery", 10 )
+        set_capability( "services_discovery", 0 )
         set_callbacks( OpenAudio, Close )
         add_shortcut( "audio_dir" )
 
     add_submodule ()
-        set_shortname( "Picture")
+        set_shortname( N_("Picture") )
         set_description( N_("My Pictures") )
-        set_capability( "services_discovery", 10 )
+        set_capability( "services_discovery", 0 )
         set_callbacks( OpenPicture, Close )
         add_shortcut( "picture_dir" )
 
+    VLC_SD_PROBE_SUBMODULE
 vlc_module_end ()
 
 
@@ -107,7 +110,7 @@ struct services_discovery_sys_t
     enum type_e i_type;
 
     char* psz_dir[2];
-    char* psz_var;
+    const char* psz_var;
 };
 
 /*****************************************************************************
@@ -129,21 +132,21 @@ static int Open( vlc_object_t *p_this, enum type_e i_type )
         p_sys->psz_dir[0] = config_GetUserDir( VLC_VIDEOS_DIR );
         p_sys->psz_dir[1] = var_CreateGetString( p_sd, "input-record-path" );
 
-        p_sys->psz_var = strdup( "record-file" );
+        p_sys->psz_var = "record-file";
     }
     else if( p_sys->i_type == Audio )
     {
         p_sys->psz_dir[0] = config_GetUserDir( VLC_MUSIC_DIR );
         p_sys->psz_dir[1] = var_CreateGetString( p_sd, "input-record-path" );
 
-        p_sys->psz_var = strdup( "record-file" );
+        p_sys->psz_var = "record-file";
     }
     else if( p_sys->i_type == Picture )
     {
         p_sys->psz_dir[0] = config_GetUserDir( VLC_PICTURES_DIR );
         p_sys->psz_dir[1] = var_CreateGetString( p_sd, "snapshot-path" );
 
-        p_sys->psz_var = strdup( "snapshot-file" );
+        p_sys->psz_var = "snapshot-file";
     }
     else
     {
@@ -156,7 +159,6 @@ static int Open( vlc_object_t *p_this, enum type_e i_type )
     if( vlc_clone( &p_sys->thread, Run, p_sd, VLC_THREAD_PRIORITY_LOW ) )
     {
         var_DelCallback( p_sd->p_libvlc, p_sys->psz_var, onNewFileAdded, p_sd );
-        free( p_sys->psz_var );
         free( p_sys->psz_dir[1] );
         free( p_sys->psz_dir[0] );
         free( p_sys );
@@ -184,15 +186,11 @@ static void *Run( void *data )
         /* make sure the directory exists */
         struct stat st;
         if( psz_dir == NULL            ||
-            utf8_stat( psz_dir, &st )  ||
+            vlc_stat( psz_dir, &st )  ||
             !S_ISDIR( st.st_mode ) )
             continue;
 
-        // TODO:  make_URI is only for file://, what about dir:// ?
-        // char* psz_uri = make_URI( psz_dir );
-        char* psz_uri;
-        if( asprintf( &psz_uri, "dir://%s",  psz_dir ) == -1 )
-            continue;
+        char* psz_uri = make_URI( psz_dir );
 
         input_item_t* p_root = input_item_New( p_sd, psz_uri, NULL );
         if( p_sys->i_type == Picture )
@@ -233,7 +231,6 @@ static void Close( vlc_object_t *p_this )
 
     var_DelCallback( p_sd->p_libvlc, p_sys->psz_var, onNewFileAdded, p_sd );
 
-    free( p_sys->psz_var );
     free( p_sys->psz_dir[1] );
     free( p_sys->psz_dir[0] );
     free( p_sys );
@@ -349,3 +346,16 @@ enum type_e fileType( services_discovery_t *p_sd, const char* psz_file )
     free( psz_dir );
     return i_ret;
 }
+
+static int vlc_sd_probe_Open( vlc_object_t *obj )
+{
+    vlc_probe_t *probe = (vlc_probe_t *)obj;
+
+    vlc_sd_probe_Add( probe, "video_dir{longname=\"My Videos\"}",
+                      N_("My Videos"), SD_CAT_MYCOMPUTER );
+    vlc_sd_probe_Add( probe, "audio_dir{longname=\"My Music\"}",
+                      N_("My Music"), SD_CAT_MYCOMPUTER );
+    vlc_sd_probe_Add( probe, "picture_dir{longname=\"My Pictures\"}",
+                      N_("My Pictures"), SD_CAT_MYCOMPUTER );
+    return VLC_PROBE_CONTINUE;
+}