Index: modules/services_discovery/podcast.c
===================================================================
--- modules/services_discovery/podcast.c	(revision 19348)
+++ modules/services_discovery/podcast.c	(working copy)
@@ -27,6 +27,8 @@
 #define _GNU_SOURCE
 #include <stdlib.h>                                      /* malloc(), free() */
 
+#include <string.h>
+
 #include <vlc/vlc.h>
 #include <vlc_playlist.h>
 #include <vlc_network.h>
@@ -56,6 +58,9 @@
 #define URLS_LONGTEXT N_("Enter the list of podcasts to retrieve, " \
                          "separated by '|' (pipe)." )
 
+#define PODCAST_PATH_TEXT N_("Download directory")
+#define PODCAST_PATH_LONGTEXT N_("Directory where Podcasts will be downloaded.")
+
 vlc_module_begin();
     set_shortname( "Podcast");
     set_description( _("Podcasts") );
@@ -65,6 +70,9 @@
     add_string( "podcast-urls", NULL, NULL,
                 URLS_TEXT, URLS_LONGTEXT, VLC_FALSE );
 
+    add_directory( "podcast-path", NULL, NULL,
+                PODCAST_PATH_TXT, PODCAST_PATH_LONGTXT, VLC_TRUE );
+
     set_capability( "services_discovery", 0 );
     set_callbacks( Open, Close );
 
@@ -92,6 +100,8 @@
 
 /* Main functions */
     static void Run    ( services_discovery_t *p_intf );
+    static int Subscribe ( char *psz_url , vlc_object_t *p_this );
+    static int Unsubscribe ( input_item_t *p_input , vlc_object_t *p_this );
 
 /*****************************************************************************
  * Open: initialize and create stuff
@@ -237,3 +247,133 @@
         msleep( 100000 );
     }
 }
+
+/*****************************************************************************
+ * Subscribe : add psz_url to podcast-urls (in vlcrc) and in playlist
+ *****************************************************************************/
+static int Subscribe( char *psz_url , vlc_object_t *p_this )
+{
+    services_discovery_t *p_sd = ( services_discovery_t* )p_this;
+    services_discovery_sys_t *p_sys  = p_sd->p_sys;
+
+    /* test of psz_url value */
+    /* I don't know if a test function already exist ? */
+    if ( strstr( psz_url , "http://" ) !== psz_url )
+    {
+        msg_Warn( p_sd, "Podcast url format not valid, subscribe canceled");
+        return VLC_EGENERIC;
+    }
+
+    /* Add psz_url to vlcrc */
+    char *psz_vlcrc = var_CreateGetString( p_sd, "podcast-urls" );
+    int len_vlcrc = strlen( psz_vlcrc );
+    int len_url = strlen( psz_url );
+
+    if ( len_vlcrc == 0 )
+    {
+        var_SetString( p_sd, "podcast-urls" , psz_url );
+        free( psz_vlcrc );
+    }
+    else
+    {
+        psz_vlcrc = realloc( psz_vlcrc ,
+                    (len_vlcrc + len_url + 2) * sizeof( char ));
+        strcat( psz_vlcrc , '|' );
+        strcat( psz_vlcrc , psz_url );
+        var_SetString( p_sd, "podcast-urls" , psz_vlcrc );
+        free( psz_vlcrc );
+    }
+
+
+    /* Create the playlist node */
+    input_item_t *p_input;
+
+    /* update the informations concerning podcast */
+    p_sys->i_urls++;
+    p_sys->ppsz_urls = realloc( p_sys->ppsz_urls,
+                                p_sys->i_urls * sizeof( char * ) );
+    p_sys->pp_input = realloc( p_sys->pp_input,
+                            p_sys->i_urls * sizeof( input_thread_t * ) );
+
+    /* Test the update */
+    if ( p_sys->ppsz_urls == NULL || p_sys->pp_input == NULL )
+    {
+        msg_Err( p_sd, "Realloc memory failled in podcast : fonction subscibe()");
+        return VLC_ENOMEM;
+    }
+    p_sys->ppsz_urls[ p_sys->i_urls - 1 ] = strdup( psz_url );
+
+
+    /* At the line 176 : why the second argument of the fonction
+    input_ItemNewExt() use a copie of p_sys->ppsz_urls[i] insted
+    of the direct pointer ? */
+    p_input = input_ItemNewExt( p_playlist, psz_url,
+                                psz_url, 0, NULL, -1 );
+    input_ItemAddOption( p_input, "demux=podcast" );
+    p_item = playlist_NodeAddInput( p_playlist, p_input, p_sys->p_node_cat,
+                                    PLAYLIST_APPEND, PLAYLIST_END,
+                                    VLC_FALSE );
+    p_item = playlist_NodeAddInput( p_playlist, p_input, p_sys->p_node_one,
+                                    PLAYLIST_APPEND, PLAYLIST_END,
+                                    VLC_FALSE );
+
+    p_sys->pp_input[ p_sys->i_urls - 1 ] = input_CreateThread( p_playlist, p_input );
+
+    val.b_bool = VLC_TRUE;
+    var_Set( p_playlist, "intf-change", val );
+
+    vlc_object_release( p_playlist );
+
+    return VLC_SUCCESS;
+}
+
+ /****************************************************************************
+  * Unsubscribe : delete the playlist node and the url in vlcrc
+  ****************************************************************************/
+
+static int Unsubscribe ( input_item_t *p_input , vlc_object_t *p_this );
+{
+    services_discovery_t *p_sd = ( services_discovery_t* )p_this;
+    services_discovery_sys_t *p_sys  = p_sd->p_sys;
+
+    /* I don't know the category where the uri is into */
+    char psz_cat[] = "??????????";
+    char *psz_url = input_ItemGetInfo( p_input, psz_cat, "uri" );
+
+    char *psz_vlcrc = var_CreateGetString( p_sd, "podcast-urls" );
+
+    /* delete the url in vlcrc and the playlist node*/
+    int i;
+    for( i = 0; i < p_sys->i_urls; i++ )
+    {
+        if ( p_sd->p_sys->pp_input[i] &&
+                strcmp( p_sd->p_sys->ppsz_urls[i] , psz_url ) == 0 )
+        {
+            /* Is this the right way to delete the playlist node ? */
+            input_StopThread( p_sd->p_sys->pp_input[i] );
+            input_DestroyThread( p_sd->p_sys->pp_input[i] );
+            p_sd->p_sys->pp_input[i] = NULL;
+
+            p_sd->p_sys->ppsz_urls[i][0] = 0;
+        }
+    }
+
+    /* over-write on psz_vlcrc */
+    psz_vlcrc[0] = 0;
+    for ( i = 0; i < p_sys->i_urls; i++ )
+    {
+        if ( p_sys->ppsz_urls[i][0] != 0 ) /* Does this work ??? */
+        {
+            strcat( psz_vlcrc , p_sys->ppsz_urls[i] );
+            strcat( psz_vlcrc , '|' );
+        }
+    }
+    int len = strlen( psz_vlcrc );
+    psz_vlcrc[len] = 0; /* Delete the last | */
+    var_SetString( p_sd, "podcast-urls" , psz_vlcrc );
+
+    free( psz_url );
+    free( psz_vlcrc );
+    
+    return VLC_SUCCESS;
+}
