]> git.sesse.net Git - vlc/blob - modules/services_discovery/freebox.c
vlc_common.h:
[vlc] / modules / services_discovery / freebox.c
1 /*****************************************************************************
2  * freebox.c :  Freebox interface module
3  *****************************************************************************
4  * Copyright (C) 2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Includes
26  *****************************************************************************/
27
28 #include <vlc/vlc.h>
29 #include <vlc_services_discovery.h>
30 #include <vlc_interface.h>
31
32 #include <vlc_network.h>
33
34 /************************************************************************
35  * definitions
36  ************************************************************************/
37 static const char kpsz_freebox_playlist_url[] = "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u";
38
39 /*****************************************************************************
40  * Module descriptor
41  *****************************************************************************/
42
43 /* Callbacks */
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 );
48
49 vlc_module_begin();
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 );
55
56     set_capability( "services_discovery", 0 );
57     set_callbacks( Open, Close );
58 vlc_module_end();
59
60
61 /*****************************************************************************
62  * Open: initialize
63  *****************************************************************************/
64 static int Open( vlc_object_t *p_this, int i_type )
65 {
66     services_discovery_t *p_sd = ( services_discovery_t* )p_this;
67     p_sd->pf_run = Run;
68     services_discovery_SetLocalizedName( p_sd, _("Freebox TV") );
69     return VLC_SUCCESS;
70 }
71
72 /*****************************************************************************
73  * ItemAdded:
74  *****************************************************************************/
75 static void ItemAdded( const vlc_event_t * p_event, void * user_data )
76 {
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 */ );
81 }
82
83 /*****************************************************************************
84  * Run:
85  *****************************************************************************/
86 static void Run( services_discovery_t *p_sd )
87 {
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
92     vlc_event_attach( &p_input->event_manager, vlc_InputItemSubItemAdded, ItemAdded, p_sd );
93     input_Read( p_sd, p_input, VLC_TRUE );
94     vlc_event_detach( &p_input->event_manager, vlc_InputItemSubItemAdded, ItemAdded, p_sd );
95     vlc_gc_decref( p_input );
96 }
97
98 /*****************************************************************************
99  * Close:
100  *****************************************************************************/
101 static void Close( vlc_object_t *p_this )
102 {
103 }