Changeset 48f29e4ecaca4cc3f56be35f206fd248078ea372
- 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
| r8ffdf4d |
r48f29e4 |
|
| 30 | 30 | #include <vlc/vlc.h> |
|---|
| 31 | 31 | #include <vlc_playlist.h> |
|---|
| | 32 | #include <vlc_arrays.h> |
|---|
| 32 | 33 | |
|---|
| 33 | 34 | #include <avahi-client/client.h> |
|---|
| … | … | |
| 63 | 64 | struct services_discovery_sys_t |
|---|
| 64 | 65 | { |
|---|
| 65 | | /* playlist node */ |
|---|
| 66 | | playlist_item_t *p_node_cat, *p_node_one; |
|---|
| 67 | | playlist_t *p_playlist; |
|---|
| 68 | | |
|---|
| 69 | 66 | AvahiSimplePoll *simple_poll; |
|---|
| 70 | 67 | AvahiClient *client; |
|---|
| 71 | 68 | AvahiServiceBrowser *sb; |
|---|
| | 69 | vlc_dictionary_t services_name_to_input_item; |
|---|
| 72 | 70 | }; |
|---|
| 73 | 71 | |
|---|
| … | … | |
| 182 | 180 | if( p_input != NULL ) |
|---|
| 183 | 181 | { |
|---|
| 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 */ ); |
|---|
| 185 | 185 | } |
|---|
| 186 | 186 | } |
|---|
| … | … | |
| 224 | 224 | { |
|---|
| 225 | 225 | /** \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 ) |
|---|
| 229 | 231 | msg_Err( p_sd, "failed to find service '%s' in playlist", name ); |
|---|
| 230 | 232 | else |
|---|
| 231 | 233 | { |
|---|
| 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 ); |
|---|
| 234 | 238 | } |
|---|
| 235 | 239 | } |
|---|
| … | … | |
| 255 | 259 | memset( p_sys, 0, sizeof(*p_sys) ); |
|---|
| 256 | 260 | |
|---|
| | 261 | vlc_dictionary_init( &p_sys->services_name_to_input_item, 1 ); |
|---|
| | 262 | |
|---|
| 257 | 263 | p_sys->simple_poll = avahi_simple_poll_new(); |
|---|
| 258 | 264 | if( p_sys->simple_poll == NULL ) |
|---|
| … | … | |
| 287 | 293 | } |
|---|
| 288 | 294 | |
|---|
| 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 | | |
|---|
| 299 | 295 | services_discovery_SetLocalizedName( p_sd, _("Bonjour") ); |
|---|
| 300 | 296 | |
|---|
| … | … | |
| 304 | 300 | |
|---|
| 305 | 301 | error: |
|---|
| 306 | | if( p_sys->p_playlist != NULL ) |
|---|
| 307 | | vlc_object_release( p_sys->p_playlist ); |
|---|
| 308 | 302 | if( p_sys->sb != NULL ) |
|---|
| 309 | 303 | avahi_service_browser_free( p_sys->sb ); |
|---|
| … | … | |
| 313 | 307 | avahi_simple_poll_free( p_sys->simple_poll ); |
|---|
| 314 | 308 | |
|---|
| 315 | | free( (void *)p_sys ); |
|---|
| | 309 | vlc_dictionary_clear( &p_sys->services_name_to_input_item ); |
|---|
| | 310 | free( p_sys ); |
|---|
| 316 | 311 | |
|---|
| 317 | 312 | return VLC_EGENERIC; |
|---|
| … | … | |
| 330 | 325 | avahi_simple_poll_free( p_sys->simple_poll ); |
|---|
| 331 | 326 | |
|---|
| 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 ); |
|---|
| 336 | 328 | free( p_sys ); |
|---|
| 337 | 329 | } |
|---|