From 61817460a63d12c6769c7cc25b04a5c092a64e97 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Wed, 12 Dec 2007 19:07:25 +0000 Subject: [PATCH] Hide module_t --- include/vlc_modules.h | 72 +------------------ .../qt4/components/complete_preferences.cpp | 49 ++++++------- .../qt4/components/complete_preferences.hpp | 1 - .../qt4/components/preferences_widgets.cpp | 43 ++++++----- src/modules/modules.h | 2 - 5 files changed, 55 insertions(+), 112 deletions(-) diff --git a/include/vlc_modules.h b/include/vlc_modules.h index c280485368..ded28f05bf 100644 --- a/include/vlc_modules.h +++ b/include/vlc_modules.h @@ -25,75 +25,6 @@ #error You are not libvlc or one of its plugins. You cannot include this file #endif -#if 1 -/* FIXME: scheduled for privatization */ -#define MODULE_SHORTCUT_MAX 50 - -/* The module handle type. */ -#if defined(HAVE_DL_DYLD) -# if defined (HAVE_MACH_O_DYLD_H) -# include -# endif -typedef NSModule module_handle_t; -#elif defined(HAVE_IMAGE_H) -typedef int module_handle_t; -#elif defined(WIN32) || defined(UNDER_CE) -typedef void * module_handle_t; -#elif defined(HAVE_DL_DLOPEN) -typedef void * module_handle_t; -#elif defined(HAVE_DL_SHL_LOAD) -typedef shl_t module_handle_t; -#endif - -/** - * Module descriptor - */ -struct module_t -{ - VLC_COMMON_MEMBERS - - /* - * Variables set by the module to identify itself - */ - const char *psz_shortname; /**< Module name */ - const char *psz_longname; /**< Module descriptive name */ - const char *psz_help; /**< Long help string for "special" modules */ - - /** Shortcuts to the module */ - const char *pp_shortcuts[ MODULE_SHORTCUT_MAX ]; - - char *psz_capability; /**< Capability */ - int i_score; /**< Score for the capability */ - uint32_t i_cpu; /**< Required CPU capabilities */ - - vlc_bool_t b_unloadable; /**< Can we be dlclosed? */ - vlc_bool_t b_reentrant; /**< Are we reentrant? */ - vlc_bool_t b_submodule; /**< Is this a submodule? */ - - /* Callbacks */ - int ( * pf_activate ) ( vlc_object_t * ); - void ( * pf_deactivate ) ( vlc_object_t * ); - - /* - * Variables set by the module to store its config options - */ - module_config_t *p_config; /* Module configuration structure */ - size_t confsize; /* Number of module_config_t items */ - unsigned int i_config_items; /* number of configuration items */ - unsigned int i_bool_items; /* number of bool config items */ - - /* - * Variables used internally by the module manager - */ - /* Plugin-specific stuff */ - module_handle_t handle; /* Unique handle */ - char * psz_filename; /* Module filename */ - - vlc_bool_t b_builtin; /* Set to true if the module is built in */ - vlc_bool_t b_loaded; /* Set to true if the dll is loaded */ -}; -#endif - /***************************************************************************** * Exported functions. *****************************************************************************/ @@ -109,6 +40,9 @@ VLC_EXPORT( vlc_bool_t, __module_Exists, ( vlc_object_t *, const char * ) ); VLC_EXPORT( module_t *, __module_FindName, ( vlc_object_t *, const char * ) ); VLC_EXPORT( void, module_Put, ( module_t *module ) ); +VLC_EXPORT( module_config_t *, module_GetConfig, ( const module_t *, unsigned * ) ); +VLC_EXPORT( void, module_PutConfig, ( module_config_t * ) ); + /* Return a NULL terminated array with the names of the modules that have a * certain capability. diff --git a/modules/gui/qt4/components/complete_preferences.cpp b/modules/gui/qt4/components/complete_preferences.cpp index 421f6ea221..84cb7943fe 100644 --- a/modules/gui/qt4/components/complete_preferences.cpp +++ b/modules/gui/qt4/components/complete_preferences.cpp @@ -85,9 +85,15 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) : PrefsItemData *data = NULL; QTreeWidgetItem *current_item = NULL; - for (size_t i = 0; i < p_module->confsize; i++) + unsigned confsize; + module_config_t *p_config; + + p_config = module_GetConfig (p_module, &confsize); + + for (size_t i = 0; i < confsize; i++) { - const module_config_t *p_item = p_module->p_config + i; + module_config_t *p_item = p_config + i; + const char *psz_help; QIcon icon; switch( p_item->i_type ) @@ -175,6 +181,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) : break; } } + module_PutConfig (p_config); /* Build the tree of plugins */ for( int i_index = 0; i_index < p_list->i_count; i_index++ ) @@ -184,15 +191,13 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) : // Main module excluded if( !strcmp( module_GetObjName( p_module ), "main" ) ) continue; - /* Exclude submodules; they have no config options of their own */ - if( p_module->b_submodule ) continue; - - unsigned i_subcategory = 0, i_category = 0; + unsigned i_subcategory = 0, i_category = 0, confsize; bool b_options = false; + module_config_t *p_config = module_GetConfig (p_module, &confsize); - for (size_t i = 0; i < p_module->confsize; i++) + for (size_t i = 0; i < confsize; i++) { - const module_config_t *p_item = p_module->p_config + i; + const module_config_t *p_item = p_config + i; if( p_item->i_type == CONFIG_CATEGORY ) i_category = p_item->value.i; @@ -205,6 +210,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) : if( b_options && i_category && i_subcategory ) break; } + module_PutConfig (p_config); if( !b_options || i_category == 0 || i_subcategory == 0 ) continue; // Locate the category item; @@ -241,12 +247,8 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) : if( !b_found ) continue; PrefsItemData *module_data = new PrefsItemData(); - module_data->b_submodule = p_module->b_submodule; module_data->i_type = TYPE_MODULE; module_data->psz_name = strdup( module_GetObjName( p_module ) ); - module_data->i_object_id = p_module->b_submodule ? - ((module_t *)p_module->p_parent)->i_object_id : - p_module->i_object_id; module_data->help.clear(); // TODO image QTreeWidgetItem *module_item = new QTreeWidgetItem(); @@ -336,20 +338,17 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, if( data->i_type == TYPE_CATEGORY ) return; else if( data->i_type == TYPE_MODULE ) - p_module = (module_t *) vlc_object_get( p_intf, data->i_object_id ); + p_module = module_FindName( VLC_OBJECT(p_intf), data->psz_name ); else { - p_module = config_FindModule( VLC_OBJECT(p_intf), "main" ); + p_module = module_FindName( VLC_OBJECT(p_intf), "main" ); assert( p_module ); - vlc_object_yield( p_module ); } - module_t *p_realmodule = p_module->b_submodule - ? (module_t *)(p_module->p_parent) - : p_module; - - module_config_t *p_item = p_realmodule->p_config; - module_config_t *p_end = p_item + p_realmodule->confsize; + unsigned confsize; + module_config_t *p_config = module_GetConfig (p_module, &confsize), + *p_item = p_config, + *p_end = p_config + confsize; if( data->i_type == TYPE_SUBCATEGORY || data->i_type == TYPE_CATSUBCAT ) { @@ -364,6 +363,7 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, p_item++; } } + module_PutConfig (p_config); /* Widgets now */ global_layout = new QVBoxLayout(); @@ -380,11 +380,12 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, } else { + const char *psz_help = module_GetHelp (p_module); head = QString( qtr( module_GetLongName( p_module ) ) ); - if( p_module->psz_help ) + if( psz_help ) { help.append( "\n" ); - help.append( qtr( module_GetHelp( p_module ) ) ); + help.append( qtr( psz_help ) ); } } @@ -473,7 +474,7 @@ AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, layout->addWidget( box, i_line, 0, 1, 2 ); } - vlc_object_release( p_module ); + module_Put( p_module ); scrolled_area->setSizePolicy( QSizePolicy::Preferred,QSizePolicy::Fixed ); scrolled_area->setLayout( layout ); diff --git a/modules/gui/qt4/components/complete_preferences.hpp b/modules/gui/qt4/components/complete_preferences.hpp index 5c7cd89515..ebdcb4c99c 100644 --- a/modules/gui/qt4/components/complete_preferences.hpp +++ b/modules/gui/qt4/components/complete_preferences.hpp @@ -51,7 +51,6 @@ public: int i_object_id; int i_subcat_id; int i_type; - bool b_submodule; char *psz_name; QString name; QString help; diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp index 0f08e26d3c..5102f8ce5c 100644 --- a/modules/gui/qt4/components/preferences_widgets.cpp +++ b/modules/gui/qt4/components/preferences_widgets.cpp @@ -507,18 +507,23 @@ void ModuleConfigControl::finish( bool bycat ) { if( !strcmp( module_GetObjName( p_parser ), "main" ) ) continue; - for (size_t i = 0; i < p_parser->confsize; i++) + unsigned confsize; + module_config_t *p_config; + + p_config = module_GetConfig (p_parser, &confsize); + for (size_t i = 0; i < confsize; i++) { - module_config_t *p_config = p_parser->p_config + i; /* Hack: required subcategory is stored in i_min */ - if( p_config->i_type == CONFIG_SUBCATEGORY && - p_config->value.i == p_item->min.i ) + const module_config_t *p_cfg = p_config + i; + if( p_cfg->i_type == CONFIG_SUBCATEGORY && + p_cfg->value.i == p_item->min.i ) combo->addItem( qtr( module_GetLongName( p_parser )), QVariant( module_GetObjName( p_parser ) ) ); if( p_item->value.psz && !strcmp( p_item->value.psz, module_GetObjName( p_parser ) ) ) combo->setCurrentIndex( combo->count() - 1 ); } + module_PutConfig (p_config); } else if( module_IsCapable( p_parser, p_item->psz_type ) ) { @@ -594,12 +599,7 @@ ModuleListConfigControl::~ModuleListConfigControl() cb->setToolTip( formatTooltip( qtr( module_GetLongName( p_parser ))));\ cbl->checkBox = cb; \ \ - int i = -1; \ - while( p_parser->pp_shortcuts[++i] != NULL); \ - i--; \ -\ - cbl->psz_module = strdup( i>=0?p_parser->pp_shortcuts[i] \ - : module_GetObjName( p_parser ) ); \ + cbl->psz_module = strdup( module_GetObjName( p_parser ) ); \ modules.push_back( cbl ); \ } @@ -619,16 +619,20 @@ void ModuleListConfigControl::finish( bool bycat ) { if( !strcmp( module_GetObjName( p_parser ), "main" ) ) continue; - for (size_t i = 0; i < p_parser->confsize; i++) + unsigned confsize; + module_config_t *p_config = module_GetConfig (p_parser, &confsize); + + for (size_t i = 0; i < confsize; i++) { - module_config_t *p_config = p_parser->p_config + i; + module_config_t *p_cfg = p_config + i; /* Hack: required subcategory is stored in i_min */ - if( p_config->i_type == CONFIG_SUBCATEGORY && - p_config->value.i == p_item->min.i ) + if( p_cfg->i_type == CONFIG_SUBCATEGORY && + p_cfg->value.i == p_item->min.i ) { CHECKBOX_LISTS; } } + module_PutConfig (p_config); } else if( module_IsCapable( p_parser, p_item->psz_type ) ) { @@ -1030,9 +1034,14 @@ void KeySelectorControl::finish() module_t *p_main = config_FindModule( p_this, "main" ); assert( p_main ); - for (size_t i = 0; i < p_main->confsize; i++) + unsigned confsize; + module_config_t *p_config; + + p_config = module_GetConfig (p_main, &confsize); + + for (size_t i = 0; i < confsize; i++) { - module_config_t *p_item = p_main->p_config + i; + module_config_t *p_item = p_config + i; if( p_item->i_type & CONFIG_ITEM && p_item->psz_name && strstr( p_item->psz_name , "key-" ) && !EMPTY_STR( p_item->psz_text ) ) @@ -1046,6 +1055,8 @@ void KeySelectorControl::finish() table->addTopLevelItem( treeItem ); } } + module_PutConfig (p_config); + table->resizeColumnToContents( 0 ); CONNECT( table, itemClicked( QTreeWidgetItem *, int ), diff --git a/src/modules/modules.h b/src/modules/modules.h index 7b235593af..92acaf42f4 100644 --- a/src/modules/modules.h +++ b/src/modules/modules.h @@ -76,7 +76,6 @@ struct module_cache_t }; -#if 0 #define MODULE_SHORTCUT_MAX 50 /* The module handle type. */ @@ -142,7 +141,6 @@ struct module_t vlc_bool_t b_builtin; /* Set to true if the module is built in */ vlc_bool_t b_loaded; /* Set to true if the dll is loaded */ }; -#endif #define module_InitBank(a) __module_InitBank(VLC_OBJECT(a)) -- 2.39.2