Index: modules/services_discovery/podcast.c
===================================================================
--- modules/services_discovery/podcast.c	(revision 19427)
+++ 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,7 +100,13 @@
 
 /* Main functions */
     static void Run    ( services_discovery_t *p_intf );
+    static int Subscribe ( vlc_object_t *p_this , const char *psz_url );
+    static int Unsubscribe ( vlc_object_t *p_this , input_item_t *p_input );
 
+/* Sub-functions */
+    static int SavePodcastList ( const services_discovery_t *p_sd ,
+                                 const services_discovery_sys_t *p_sys )
+
 /*****************************************************************************
  * Open: initialize and create stuff
  *****************************************************************************/
@@ -237,3 +251,130 @@
         msleep( 100000 );
     }
 }
+
+/*****************************************************************************
+ * Subscribe : add psz_url to podcast-urls (in vlcrc) and in playlist
+ *****************************************************************************/
+static int Subscribe( vlc_object_t *p_this , const char *psz_url )
+{
+    services_discovery_t *p_sd = ( services_discovery_t* )p_this;
+    services_discovery_sys_t *p_sys  = p_sd->p_sys;
+    input_item_t *p_input;
+
+    /* update the informations concerning podcast */
+    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 realloc */
+    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->i_urls++;
+
+    /* Create the playlist element */
+    p_sys->ppsz_urls[ p_sys->i_urls - 1 ] = strdup( psz_url );
+
+    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; /* why don't we pass VLC_TRUE to the function directly */
+    var_Set( p_playlist, "intf-change", val );
+    vlc_object_release( p_playlist );
+
+    /* Update vlcrc */
+    SavePodcastList( p_sd , p_sys );
+
+    return VLC_SUCCESS;
+}
+
+ /****************************************************************************
+  * Unsubscribe : delete the playlist node and the url in vlcrc
+  ****************************************************************************/
+static int Unsubscribe ( vlc_object_t *p_this , input_item_t *p_input );
+{
+    services_discovery_t *p_sd = ( services_discovery_t* )p_this;
+    services_discovery_sys_t *p_sys  = p_sd->p_sys;
+    int i;
+    char *psz_url = NULL;
+
+    /* FIXME : I don't know the category where the uri is into */
+    psz_url = input_ItemGetInfo( p_input, "psz_cat = ???????", "uri" );
+
+    /* find and delete the playlist node */
+    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;
+        }
+    }
+
+    SavePodcastList( p_sd , p_sys );
+
+    free( psz_url );
+
+    return VLC_SUCCESS;
+}
+
+ /****************************************************************************
+  * SavePodcastList : create the | separated list of url and save it
+  ****************************************************************************/
+static int SavePodcastList ( const services_discovery_t *p_sd ,
+                             const services_discovery_sys_t *p_sys )
+{
+    int i;
+    size_t len_list = 1;
+    char *psz_url_list = NULL, *ptr;
+
+    /* size of the url list */
+    for( i = 0; i < p_sys->i_urls; i++ )
+    {
+        if( p_sys->ppsz_urls[i][0] != 0 )
+        {
+            len_list += strlen( p_sys->ppsz_urls[i] ) + 1;
+        }
+    }
+
+    if( len_list == 1 ) /* url list empty */
+    {
+        var_SetString( p_sd, "podcast-urls" , "" );
+        return  VLC_SUCCESS;
+    }
+
+    psz_url_list = malloc( len_list * sizeof( char ) );
+    for( i = 0; i < p_sys->i_urls; i++ )
+    {
+        if( p_sys->ppsz_urls[i][0] != 0 )
+        {
+            strcat( psz_url_list , p_sys->ppsz_urls[i] );
+            strcat( psz_url_list , '|' );
+        }
+    }
+    /* Delete the last | */
+    ptr = psz_url_list + strlen (psz_url_list);
+	*ptr = '\0';
+
+	var_SetString( p_sd, "podcast-urls" , psz_url_list );
+
+	free( psz_url_list );
+
+	return VLC_SUCCESS;
+}
