/*****************************************************************************
* services_discovery.c : Manage playlist services_discovery modules
*****************************************************************************
- * Copyright (C) 1999-2004 the VideoLAN team
+ * Copyright (C) 1999-2004 VLC authors and VideoLAN
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
{
services_discovery_t *p_sd;
- p_sd = vlc_custom_create( p_super, sizeof( *p_sd ), VLC_OBJECT_GENERIC,
- "services discovery" );
+ p_sd = vlc_custom_create( p_super, sizeof( *p_sd ), "services discovery" );
if( !p_sd )
return NULL;
free(config_ChainCreate( &p_sd->psz_name, &p_sd->p_cfg, cfg ));
vlc_event_manager_t *em = &p_sd->event_manager;
- vlc_event_manager_init( em, p_sd, (vlc_object_t *)p_sd );
+ vlc_event_manager_init( em, p_sd );
vlc_event_manager_register_event_type(em, vlc_ServicesDiscoveryItemAdded);
vlc_event_manager_register_event_type(em, vlc_ServicesDiscoveryItemRemoved);
+ vlc_event_manager_register_event_type(em, vlc_ServicesDiscoveryItemRemoveAll);
vlc_event_manager_register_event_type(em, vlc_ServicesDiscoveryStarted);
vlc_event_manager_register_event_type(em, vlc_ServicesDiscoveryEnded);
return &p_sd->event_manager;
}
+/*******************************************************************//**
+ * Remove all items from the Service Discovery listing
+ ***********************************************************************/
+void
+services_discovery_RemoveAll ( services_discovery_t * p_sd )
+{
+ vlc_event_t event;
+ event.type = vlc_ServicesDiscoveryItemRemoveAll;
+
+ vlc_event_send( &p_sd->event_manager, &event );
+}
+
/*******************************************************************//**
* Add an item to the Service Discovery listing
***********************************************************************/
PL_UNLOCK;
}
+/* A request to remove all ideas from SD */
+static void playlist_sd_item_removeall( const vlc_event_t * p_event, void * user_data )
+{
+ VLC_UNUSED(p_event);
+ playlist_item_t* p_sd_node = user_data;
+ if( p_sd_node == NULL ) return;
+ playlist_t* p_playlist = p_sd_node->p_playlist;
+ PL_LOCK;
+ playlist_NodeEmpty( p_playlist, p_sd_node, true );
+ PL_UNLOCK;
+}
+
int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,
const char *psz_name )
{
vlc_event_attach( em, vlc_ServicesDiscoveryItemRemoved,
playlist_sd_item_removed, p_node );
+ vlc_event_attach( em, vlc_ServicesDiscoveryItemRemoveAll,
+ playlist_sd_item_removeall, p_node );
+
if( !vlc_sd_Start( p_sd ) )
{
vlc_sd_Destroy( p_sd );