1 /*****************************************************************************
2 * freebox.c : Freebox interface module
3 *****************************************************************************
4 * Copyright (C) 2007 the VideoLAN team
7 * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
29 #include <vlc_services_discovery.h>
30 #include <vlc_interface.h>
32 #include <vlc_network.h>
34 /************************************************************************
36 ************************************************************************/
37 static const char kpsz_freebox_playlist_url[] = "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u";
39 /*****************************************************************************
41 *****************************************************************************/
44 static int Open ( vlc_object_t *, int );
45 static void Close( vlc_object_t * );
46 static void ItemAdded( const vlc_event_t * p_event, void * user_data );
47 static void Run( services_discovery_t *p_sd );
50 set_shortname( "Freebox");
51 set_description( _("Freebox TV listing (French ISP free.fr services)") );
52 add_shortcut( "freebox" );
53 set_category( CAT_PLAYLIST );
54 set_subcategory( SUBCAT_PLAYLIST_SD );
56 set_capability( "services_discovery", 0 );
57 set_callbacks( Open, Close );
61 /*****************************************************************************
63 *****************************************************************************/
64 static int Open( vlc_object_t *p_this, int i_type )
66 services_discovery_t *p_sd = ( services_discovery_t* )p_this;
68 services_discovery_SetLocalizedName( p_sd, _("Freebox TV") );
72 /*****************************************************************************
74 *****************************************************************************/
75 static void ItemAdded( const vlc_event_t * p_event, void * user_data )
77 services_discovery_t *p_sd = user_data;
78 services_discovery_AddItem( p_sd,
79 p_event->u.input_item_subitem_added.p_new_child,
80 NULL /* no category */ );
83 /*****************************************************************************
85 *****************************************************************************/
86 static void Run( services_discovery_t *p_sd )
88 input_item_t * p_input = input_ItemNewExt( p_sd, kpsz_freebox_playlist_url,
89 _("Freebox TV"), 0, NULL, -1 );
90 input_ItemAddOption( p_input, "no-playlist-autostart" );
91 vlc_gc_incref( p_input );
93 vlc_event_attach( &p_input->event_manager, vlc_InputItemSubItemAdded, ItemAdded, p_sd );
94 input_Read( p_sd, p_input, VLC_TRUE );
95 vlc_event_detach( &p_input->event_manager, vlc_InputItemSubItemAdded, ItemAdded, p_sd );
96 vlc_gc_decref( p_input );
99 /*****************************************************************************
101 *****************************************************************************/
102 static void Close( vlc_object_t *p_this )