Changeset 48f29e4ecaca4cc3f56be35f206fd248078ea372

Show
Ignore:
Timestamp:
08/19/07 18:36:27 (1 year ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1187541387 +0000
git-parent:

[00eaa2707ccc4d073fca03f728697e308b2f9d4e]

git-author:
Pierre d'Herbemont <pdherbemont@videolan.org> 1187541387 +0000
Message:

module/services_discovery/bonjour.c: Use the new API.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/services_discovery/bonjour.c

    r8ffdf4d r48f29e4  
    3030#include <vlc/vlc.h> 
    3131#include <vlc_playlist.h> 
     32#include <vlc_arrays.h> 
    3233 
    3334#include <avahi-client/client.h> 
     
    6364struct services_discovery_sys_t 
    6465{ 
    65     /* playlist node */ 
    66     playlist_item_t     *p_node_cat, *p_node_one; 
    67     playlist_t          *p_playlist; 
    68  
    6966    AvahiSimplePoll     *simple_poll; 
    7067    AvahiClient         *client; 
    7168    AvahiServiceBrowser *sb; 
     69    vlc_dictionary_t    services_name_to_input_item; 
    7270}; 
    7371 
     
    182180        if( p_input != NULL ) 
    183181        { 
    184             services_discovery_AddItem( p_sd, p_input, NULL ); 
     182            vlc_dictionary_insert( &p_sys->services_name_to_input_item, 
     183                name, p_input ); 
     184            services_discovery_AddItem( p_sd, p_input, NULL /* no category */ ); 
    185185       } 
    186186    } 
     
    224224    { 
    225225        /** \todo Store the input id and search it, rather than searching the items */ 
    226         playlist_item_t *p_item; 
    227         p_item = playlist_ChildSearchName( p_sys->p_node_cat, name ); 
    228         if( p_item == NULL ) 
     226        input_item_t *p_item; 
     227        p_item = vlc_dictionary_value_for_key( 
     228                        &p_sys->services_name_to_input_item, 
     229                        name ); 
     230        if( !p_item ) 
    229231            msg_Err( p_sd, "failed to find service '%s' in playlist", name ); 
    230232        else 
    231233        { 
    232             playlist_DeleteFromInput( p_sys->p_playlist, p_item->p_input->i_id, 
    233                                       VLC_FALSE ); 
     234            services_discovery_RemoveItem( p_sd, p_item ); 
     235            vlc_dictionary_remove_value_for_key( 
     236                        &p_sys->services_name_to_input_item, 
     237                        name ); 
    234238        } 
    235239    } 
     
    255259    memset( p_sys, 0, sizeof(*p_sys) ); 
    256260 
     261    vlc_dictionary_init( &p_sys->services_name_to_input_item, 1 ); 
     262 
    257263    p_sys->simple_poll = avahi_simple_poll_new(); 
    258264    if( p_sys->simple_poll == NULL ) 
     
    287293    } 
    288294 
    289     /* Create our playlist node */ 
    290     p_sys->p_playlist = (playlist_t *)vlc_object_find( p_sd, 
    291                                                        VLC_OBJECT_PLAYLIST, 
    292                                                        FIND_ANYWHERE ); 
    293     if( !p_sys->p_playlist ) 
    294     { 
    295         msg_Warn( p_sd, "unable to find playlist, cancelling"); 
    296         goto error; 
    297     } 
    298  
    299295    services_discovery_SetLocalizedName( p_sd, _("Bonjour") ); 
    300296 
     
    304300 
    305301error: 
    306     if( p_sys->p_playlist != NULL ) 
    307         vlc_object_release( p_sys->p_playlist ); 
    308302    if( p_sys->sb != NULL ) 
    309303        avahi_service_browser_free( p_sys->sb ); 
     
    313307        avahi_simple_poll_free( p_sys->simple_poll ); 
    314308 
    315     free( (void *)p_sys ); 
     309    vlc_dictionary_clear( &p_sys->services_name_to_input_item ); 
     310    free( p_sys ); 
    316311 
    317312    return VLC_EGENERIC; 
     
    330325    avahi_simple_poll_free( p_sys->simple_poll ); 
    331326 
    332     playlist_NodeDelete( p_sys->p_playlist, p_sys->p_node_one, VLC_TRUE, VLC_TRUE ); 
    333     playlist_NodeDelete( p_sys->p_playlist, p_sys->p_node_cat, VLC_TRUE, VLC_TRUE ); 
    334     vlc_object_release( p_sys->p_playlist ); 
    335  
     327    vlc_dictionary_clear( &p_sys->services_name_to_input_item ); 
    336328    free( p_sys ); 
    337329}