Changeset acbd355a0bc946f82235ddce81a7b50d92f1b094

Show
Ignore:
Timestamp:
11/11/07 22:08:36 (1 year ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1194815316 +0000
git-parent:

[ffc3180d5c6e8968b20541caa02a1ba84ad759f1]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1194815316 +0000
Message:

Use the services_discovery_GetServicesNames() function in the qt4 and wxwidgets (i don't compile the wxwidgets module so there might be a few warnings/errors). This removes comprehension of how VLC modules work from the interface plugins. This change still needs to be done in the modules/gui/macosx/playlist.m file.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_services_discovery.h

    r07c7cdc racbd355  
    6363/* Get the services discovery modules names to use in Create(), in a null 
    6464 * terminated string array. Array and string must be freed after use. */ 
    65 VLC_EXPORT( char **, services_discovery_GetServicesNames, ( vlc_object_t * p_super, char ***pppsz_longnames ) ); 
     65VLC_EXPORT( char **, __services_discovery_GetServicesNames, ( vlc_object_t * p_super, char ***pppsz_longnames ) ); 
     66#define services_discovery_GetServicesNames(a,b) \ 
     67        __services_discovery_GetServicesNames(VLC_OBJECT(a),b) 
    6668 
    6769/* Creation of a service_discovery object */ 
  • modules/gui/qt4/menus.cpp

    r1ced729 racbd355  
    214214    QMenu *menu = new QMenu(); 
    215215    menu->addMenu( SDMenu( p_intf ) ); 
    216     menu->addAction ( QIcon( ":/pixmaps/playlist_16px.png" ), 
    217                       qtr( "Show Playlist" ), mi, SLOT( togglePlaylist() ) ); 
     216    menu->addAction( QIcon( ":/pixmaps/playlist_16px.png" ), 
     217                     qtr( "Show Playlist" ), mi, SLOT( togglePlaylist() ) ); 
    218218    menu->addSeparator(); 
    219219 
     
    222222    menu->addSeparator(); 
    223223    menu->addAction( qtr( "Undock from interface" ), mi, 
    224             SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) ); 
     224                     SLOT( undockPlaylist() ), qtr( "Ctrl+U" ) ); 
    225225    return menu; 
    226226} 
     
    413413    QMenu *menu = new QMenu(); 
    414414    menu->setTitle( qtr( I_PL_SD ) ); 
    415     vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, 
    416             FIND_ANYWHERE ); 
    417     int i_num = 0; 
    418     for( int i_index = 0 ; i_index < p_list->i_count; i_index++ ) 
    419     { 
    420         module_t * p_parser = ( module_t * )p_list->p_values[i_index].p_object ; 
    421         if( module_IsCapable( p_parser, "services_discovery" ) ) 
    422             i_num++; 
    423     } 
    424     for( int i_index = 0 ; i_index < p_list->i_count; i_index++ ) 
    425     { 
    426         module_t * p_parser = ( module_t * )p_list->p_values[i_index].p_object; 
    427         if( !module_IsCapable( p_parser, "services_discovery" ) ) 
    428             continue; 
    429  
    430         QAction *a = new QAction( qfu( module_GetLongName( p_parser ) ), menu ); 
     415    char **ppsz_longnames; 
     416    char **ppsz_names = services_discovery_GetServicesNames( p_intf, 
     417                                                             &ppsz_longnames ); 
     418    char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames; 
     419    for( ; *ppsz_name; ppsz_name++, ppsz_longname++ ) 
     420    { 
     421        QAction *a = new QAction( qfu( *ppsz_longname ), menu ); 
    431422        a->setCheckable( true ); 
    432         /* hack to handle submodules properly */ 
    433         int i = -1; 
    434         while( p_parser->pp_shortcuts[++i] != NULL ); 
    435         i--; 
    436         if( playlist_IsServicesDiscoveryLoaded( THEPL, 
    437                     i>=0?p_parser->pp_shortcuts[i] 
    438                     : module_GetObjName( p_parser ) ) ) 
     423        if( playlist_IsServicesDiscoveryLoaded( THEPL, *ppsz_name ) ) 
    439424            a->setChecked( true ); 
    440425        CONNECT( a , triggered(), THEDP->SDMapper, map() ); 
    441         THEDP->SDMapper->setMapping( a, i>=0? p_parser->pp_shortcuts[i] : 
    442                                               module_GetObjName( p_parser ) ); 
     426        THEDP->SDMapper->setMapping( a, QString( *ppsz_name ) ); 
    443427        menu->addAction( a ); 
    444428 
    445         if( !strcmp( p_parser->psz_object_name, "podcast" ) ) 
     429        if( !strcmp( *ppsz_name, "podcast" ) ) 
    446430        { 
    447431            QAction *b = new QAction( qfu( "Configure podcasts..." ), menu ); 
     
    450434            CONNECT( b, triggered(), THEDP, podcastConfigureDialog() ); 
    451435        } 
    452     } 
    453     vlc_list_release( p_list ); 
     436        free( *ppsz_name ); 
     437        free( *ppsz_longname ); 
     438    } 
     439    free( ppsz_names ); 
     440    free( ppsz_longnames ); 
    454441    return menu; 
    455442} 
  • modules/gui/wxwidgets/dialogs/playlist.cpp

    rf452c11 racbd355  
    412412Playlist::~Playlist() 
    413413{ 
    414     if( pp_sds != NULL ) free( pp_sds ); 
     414    if( pp_sds != NULL ) 
     415    { 
     416        char **pp_sd = pp_sds; 
     417        for( ; *pp_sd; pp_sd++ ) free( *pp_sd ); 
     418        free( pp_sds ); 
     419    } 
    415420 
    416421    if( p_playlist == NULL ) return; 
     
    14011406    p_sd_menu = new wxMenu; 
    14021407 
    1403     vlc_list_t *p_list = vlc_list_find( p_playlist, VLC_OBJECT_MODULE, 
    1404                                         FIND_ANYWHERE ); 
    1405  
    1406     int i_number = 0; 
    1407     for( int i_index = 0; i_index < p_list->i_count; i_index++ ) 
    1408     { 
    1409         module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ; 
    1410  
    1411         if( !strcmp( p_parser->psz_capability, "services_discovery" ) ) 
    1412             i_number++; 
    1413     } 
    1414     if( i_number ) pp_sds = (const char **)calloc( i_number, sizeof(void *) ); 
    1415  
    1416     i_number = 0; 
    1417     for( int i_index = 0; i_index < p_list->i_count; i_index++ ) 
    1418     { 
    1419         module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ; 
    1420  
    1421         if( !strcmp( p_parser->psz_capability, "services_discovery" ) ) 
    1422         { 
    1423             p_sd_menu->AppendCheckItem( FirstSD_Event + i_number , 
    1424                 wxU( p_parser->psz_longname ? p_parser->psz_longname : 
    1425                      (p_parser->psz_shortname ? 
    1426                       p_parser->psz_shortname : p_parser->psz_object_name) ) ); 
    1427  
    1428             /* hack to handle submodules properly */ 
    1429             int i = -1; 
    1430             while( p_parser->pp_shortcuts[++i] != NULL ); 
    1431             i--; 
    1432             if( playlist_IsServicesDiscoveryLoaded( p_playlist, 
    1433                                     i>=0?p_parser->pp_shortcuts[i] 
    1434                                     :p_parser->psz_object_name ) ) 
    1435             { 
    1436                 p_sd_menu->Check( FirstSD_Event + i_number, TRUE ); 
    1437             } 
    1438  
    1439             pp_sds[i_number++] = i>=0?p_parser->pp_shortcuts[i] 
    1440                                  :p_parser->psz_object_name; 
    1441         } 
    1442     } 
    1443     vlc_list_release( p_list ); 
     1408    char **ppsz_longnames; 
     1409    char **ppsz_names = services_discovery_GetServicesNames( p_playlist, 
     1410                                                             &ppsz_longnames ); 
     1411    char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames; 
     1412 
     1413    for( ; *ppsz_name; ppsz_name++, ppsz_longname++ ) 
     1414    { 
     1415        p_sd_menu->AppendCheckItem( FirstSD_Event + i_number , 
     1416                                    wxU( *ppsz_longname ) ); 
     1417 
     1418        if( playlist_IsServicesDiscoveryLoaded( p_playlist, *ppsz_name ) ) 
     1419            p_sd_menu->Check( FirstSD_Event + i_number, TRUE ); 
     1420 
     1421        free( *ppsz_longname ); 
     1422    } 
     1423    pp_sds = ppsz_names; 
     1424    free( ppsz_longnames ); 
    14441425    return p_sd_menu; 
    14451426} 
  • src/playlist/services_discovery.c

    r07c7cdc racbd355  
    3838 * GetServicesNames 
    3939 ***********************************************************************/ 
    40 char ** services_discovery_GetServicesNames( vlc_object_t * p_super, 
    41                                              char ***pppsz_longnames ) 
     40char ** __services_discovery_GetServicesNames( vlc_object_t * p_super, 
     41                                               char ***pppsz_longnames ) 
    4242{ 
    4343    return module_GetModulesNamesForCapability( p_super, "services_discovery",